removed hardcoded values for more add less work in the long run.

pull/6658/head
Michael 5 years ago
parent 69b4203a85
commit 15cbc4cf0d
  1. 51
      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:
'''

Loading…
Cancel
Save