aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minit.py
diff options
context:
space:
mode:
authorMichael <michaelbrockus@gmail.com>2020-02-19 18:40:15 -0800
committerMichael <michaelbrockus@gmail.com>2020-02-19 18:40:15 -0800
commit15cbc4cf0d9fcd7f4faab0c947b82fdee5cfa2c6 (patch)
tree3931173c568495ebb2d6cf3a86e9d98d626ffe9d /mesonbuild/minit.py
parent69b4203a8510eeeca4e769b7ddf5ef1ca3fb9f16 (diff)
downloadmeson-15cbc4cf0d9fcd7f4faab0c947b82fdee5cfa2c6.zip
meson-15cbc4cf0d9fcd7f4faab0c947b82fdee5cfa2c6.tar.gz
meson-15cbc4cf0d9fcd7f4faab0c947b82fdee5cfa2c6.tar.bz2
removed hardcoded values for more add less work in the long run.
Diffstat (limited to 'mesonbuild/minit.py')
-rw-r--r--mesonbuild/minit.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/mesonbuild/minit.py b/mesonbuild/minit.py
index 090f004..f16c305 100644
--- a/mesonbuild/minit.py
+++ b/mesonbuild/minit.py
@@ -41,8 +41,11 @@ from mesonbuild.templates.mesontemplates import create_meson_build
FORTRAN_SUFFIXES = ('.f', '.for', '.F', '.f90', '.F90')
LANG_SUFFIXES = ('.c', '.cc', '.cpp', '.cs', '.cu', '.d', '.m', '.mm', '.rs', '.java') + FORTRAN_SUFFIXES
LANG_SUPPORTED = ('c', 'cpp', 'cs', 'cuda', 'd', 'fortran', 'java', 'rust', 'objc', 'objcpp')
-TYPE_EXE = 'executable'
-TYPE_LIB = 'library'
+
+DEFAULT_EXE = 'executable'
+DEFAULT_LIB = 'library'
+DEFAULT_PROJECT = 'executable'
+DEFAULT_VERSION = '0.1'
UNREACHABLE_CODE_ERROR = 'Unreachable code'
@@ -60,72 +63,72 @@ def create_sample(options) -> None:
then check for project type and create new Meson samples project.
'''
if options.language == 'c':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_c_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_c_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'cpp':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_cpp_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_cpp_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'cs':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_cs_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_cs_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'cuda':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_cuda_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_cuda_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'd':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_d_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_d_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'fortran':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_fortran_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_fortran_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'rust':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_rust_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_rust_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'objc':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_objc_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_objc_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'objcpp':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_objcpp_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_objcpp_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
elif options.language == 'java':
- if options.type == TYPE_EXE:
+ if options.type == DEFAULT_EXE:
create_exe_java_sample(options.name, options.version)
- elif options.type == TYPE_LIB:
+ elif options.type == DEFAULT_LIB:
create_lib_java_sample(options.name, options.version)
else:
raise RuntimeError(UNREACHABLE_CODE_ERROR)
@@ -212,8 +215,8 @@ def add_arguments(parser):
parser.add_argument("-b", "--build", action='store_true', help="build after generation")
parser.add_argument("--builddir", default='build', help="directory for build")
parser.add_argument("-f", "--force", action="store_true", help="force overwrite of existing files and directories.")
- parser.add_argument('--type', default='executable', choices=('executable', 'library'), help="project type. default: executable based project")
- parser.add_argument('--version', default='0.1', help="project version. default: 0.1")
+ parser.add_argument('--type', default='executable', choices=('executable', 'library'), help="project type. default: {} based project".format(DEFAULT_PROJECT))
+ parser.add_argument('--version', default=DEFAULT_VERSION, help="project version. default: {}".format(DEFAULT_VERSION))
def run(options) -> int:
'''