def main(): m = ManageScript() args_parser = argparse.ArgumentParser( description='Helper to build and install Langkit_Support' ) args_parser.add_argument( '--build-dir', default='build', help='Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.' ) args_parser.add_argument( '--enable-static', action='store_true', help='Enable the generation of static libraries (default:' ' disabled)' ) args_parser.add_argument( '--disable-static', action='store_false', dest='enable_static', help='Disable the generation of static libraries' ) args_parser.add_argument( '--enable-shared', action='store_true', default=True, help='Enable the generation (and testing) of shared libraries' ' (default: enabled)' ) args_parser.add_argument( '--disable-shared', action='store_false', dest='enable_shared', help='Disable the generation (and testing) of shared libraries' ) args_parser.add_argument( '--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level' ) subparsers = args_parser.add_subparsers() # Generate generate_parser = subparsers.add_parser( 'generate', help='Generate build tree and project file for Langkit_Support.' ) generate_parser.set_defaults(cmd='generate-langkit-support') # Build build_parser = subparsers.add_parser( 'build', help='Build Langkit_Support.' ) build_parser.add_argument( '--jobs', '-j', type=int, default=get_cpu_count(), help='Number of parallel jobs to spawn in parallel ' '(default: your number of cpu)' ) build_parser.add_argument( '--build-mode', '-b', choices=list(m.BUILD_MODES), default='dev', help='Selects a preset for build options' ) build_parser.set_defaults(cmd='build-langkit-support') # Install install_parser = subparsers.add_parser( 'install', help='Install Langkit_Support.' ) install_parser.add_argument( 'install-dir', help='Installation directory.' ) install_parser.set_defaults(cmd='install-langkit-support') args = args_parser.parse_args() argv = ['-E', '--build-dir={}'.format(args.build_dir), '--verbosity={}'.format(args.verbosity)] if args.enable_static: argv.append('--enable-static') if not args.enable_shared: argv.append('--disable-shared') argv.append(args.cmd) if args.cmd == 'install-langkit-support': argv.append(getattr(args, 'install-dir')) m.run(argv)
def __init__(self): self.dirs = Directories( # It is assumed that manage.py is at the root of the language # definition source directory. lang_source_dir=path.dirname( path.abspath(inspect.getfile(self.__class__)))) Diagnostics.set_lang_source_dir(self.dirs.lang_source_dir()) ######################## # Main argument parser # ######################## self.args_parser = args_parser = argparse.ArgumentParser( description='General manager to handle actions relative to' ' building/testing libadalang') self.subparsers = subparsers = args_parser.add_subparsers() args_parser.add_argument( '--build-dir', default='build', help=('Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.')) args_parser.add_argument( '--enable-static', action='store_true', help='Enable the generation of static libraries (default:' ' disabled)') args_parser.add_argument( '--disable-static', action='store_false', dest='enable_static', help='Disable the generation of static libraries') args_parser.add_argument( '--enable-shared', action='store_true', default=True, help='Enable the generation (and testing) of shared libraries' ' (default: enabled)') args_parser.add_argument( '--disable-shared', action='store_false', dest='enable_shared', help='Disable the generation (and testing) of shared libraries') args_parser.add_argument( '--bindings', '-b', nargs='+', choices=('python', ), default=['python'], help='Bindings to generate (by default: only Python)') args_parser.add_argument('--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level') # Don't enable this by default so that errors will not make automated # tasks hang. args_parser.add_argument( '-g', '--debug', action='store_true', help='In case of internal error or diagnostic error, run a' ' post-mortem PDB session') args_parser.add_argument( '--profile', action='store_true', help='Run cProfile and langkit, and generate a data file ' '"langkit.prof"') args_parser.add_argument( '--parsable-errors', '-P', action='store_true', default=False, help='Generate error messages parsable by tools') def create_parser(fn, needs_context=False): """ Create a subparser from a function. Uses the name and the docstring of the function to document the subparsers. :param (ManageScript, Namespace) -> None fn: The function to use. :param bool needs_context: Whether the executed function needs a CompileCtx created beforehand or not. :rtype: argparse.ArgumentParser """ p = subparsers.add_parser( # Take the name of the function without the do_ prefix fn.__name__.replace('do_', ''), # Take the first paragraph of the function's documentation as # help. help=fn.__doc__.split('\n\n')[0].strip()) def internal(*args, **kwargs): if needs_context: self.set_context(*args, **kwargs) fn(*args, **kwargs) p.set_defaults(func=internal) return p ######## # Help # ######## self.help_parser = create_parser(self.do_help) ############ # Generate # ############ self.generate_parser = generate_parser = create_parser( self.do_generate, True) self.add_generate_args(generate_parser) ######### # Build # ######### self.build_parser = build_parser = create_parser(self.do_build, True) self.add_build_args(build_parser) ######## # Make # ######## self.make_parser = make_parser = create_parser(self.do_make, True) self.add_generate_args(make_parser) self.add_build_args(make_parser) ########### # Install # ########### self.install_parser = install_parser = create_parser( self.do_install, True) install_parser.add_argument('install-dir', help='Installation directory.') ########## # Setenv # ########## self.setenv_parser = create_parser(self.do_setenv, True) self.setenv_parser.add_argument( '--json', '-J', action='store_true', help='Output necessary env keys to json') # The create_context method will create the context and set it here # only right before executing commands so that coverage computation # will apply to create_context. self.context = None
def __init__(self): self.dirs = Directories( # It is assumed that manage.py is at the root of the language # definition source directory, if no source directory is explicitly # passed. lang_source_dir=path.dirname( path.abspath(inspect.getfile(self.__class__)))) ######################## # Main argument parser # ######################## self.args_parser = args_parser = argparse.ArgumentParser( description='General manager to handle actions relative to' ' building/testing your language.') self.subparsers = subparsers = args_parser.add_subparsers() args_parser.add_argument( '--build-dir', default='build', help='Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.') args_parser.add_argument( '--library-types', default=LibraryTypes(relocatable=True), type=LibraryTypes.parse, help='Comma-separated list of library types to build (relocatable,' ' static-pic and static). By default, build only shared' ' libraries.') args_parser.add_argument('--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level') args_parser.add_argument( '--full-error-traces', '-E', action='store_true', default=False, help='Always show full error traces, whatever the verbosity level' ' (default: disabled).') args_parser.add_argument('--trace', '-t', action='append', default=[], help='Activate given debug trace.') args_parser.add_argument( '--no-langkit-support', action='store_true', help='Assuming that Langkit_Support is already built and' ' installed. This is useful to package the generated library' ' only.') args_parser.add_argument( '--no-ada-api', action='store_true', help='Do not generate units to provide an Ada API, and disable the' ' generation of mains.') # Don't enable this by default so that errors will not make automated # tasks hang. args_parser.add_argument( '-g', '--debug', action='store_true', help='In case of internal error or diagnostic error, run a' ' post-mortem PDB session.') args_parser.add_argument( '--profile', action='store_true', help='Run cProfile and langkit, and generate a data file' ' "langkit.prof".') args_parser.add_argument('--diagnostic-style', '-D', type=DiagnosticStyle, default=DiagnosticStyle.default, help='Style for error messages.') args_parser.add_argument( '--plugin-pass', action='append', default=[], help='Fully qualified name to a Langkit plug-in pass constructor.' ' The function must return a Langkit pass, whose type derives' ' from langkit.passes.AbstractPass. It will be ran at the end' ' of the pass preexisting order.') def create_parser(fn, needs_context=False): """ Create a subparser from a function. Uses the name and the docstring of the function to document the subparsers. :param (ManageScript, Namespace) -> None fn: The function to use. :param bool needs_context: Whether the executed function needs a CompileCtx created beforehand or not. :rtype: argparse.ArgumentParser """ p = subparsers.add_parser( # Take the name of the function without the do_ prefix and with # dashes instead of underscores. fn.__name__.replace('do_', '').replace('_', '-'), # Take the first paragraph of the function's documentation as # help. help=fn.__doc__.split('\n\n')[0].strip()) def internal(*args, **kwargs): if needs_context: self.set_context(*args, **kwargs) fn(*args, **kwargs) p.set_defaults(func=internal) return p ######## # Help # ######## self.help_parser = create_parser(self.do_help) ############ # Generate # ############ self.generate_parser = generate_parser = create_parser( self.do_generate, True) self.add_generate_args(generate_parser) ######### # Build # ######### self.build_parser = build_parser = create_parser(self.do_build, True) self.add_build_args(build_parser) ######## # Make # ######## self.make_parser = make_parser = create_parser(self.do_make, True) self.add_generate_args(make_parser) self.add_build_args(make_parser) ########### # Install # ########### self.install_parser = install_parser = create_parser( self.do_install, True) install_parser.add_argument('install-dir', help='Installation directory.') self.add_build_mode_arg(install_parser) install_parser.add_argument( '--force', '-f', action='store_true', help='Force installation, overwrite files.') install_parser.add_argument('--disable-all-mains', action='store_true', help='Do not install main program.') ########## # Setenv # ########## self.setenv_parser = create_parser(self.do_setenv, True) self.add_build_mode_arg(self.setenv_parser) self.setenv_parser.add_argument( '--json', '-J', action='store_true', help='Output necessary env keys to JSON.') ####################### # Create Python wheel # ####################### self.create_wheel_parser = create_parser(self.do_create_wheel, True) Packager.add_platform_options(self.create_wheel_parser) self.create_wheel_parser.add_argument( '--with-python', help='Python intererpter to use in order to build the wheel. If' ' not provided, use the current one.') self.create_wheel_parser.add_argument( '--tag', help="Tag for the wheel (setup.py's --python-tag argument).") self.create_wheel_parser.add_argument( 'wheel-dir', help='Destination directory for the wheel.') self.create_wheel_parser.add_argument( 'build-dir', help='Temporary directory to use in order to build the wheel.') self.create_wheel_parser.add_argument( 'dyn-deps-dir', help='Directory that contains all the dynamic libraries to ship in' ' the wheel (i.e. dependencies).') self.create_wheel_parser.add_argument( 'install-dir', help='Directory in which the library is installed.') ############################################### # Generate, Build and Install Langkit_Support # ############################################### self.generate_lksp_parser = create_parser( self.do_generate_langkit_support) self.build_lksp_parser = create_parser(self.do_build_langkit_support) self.install_lksp_parser = create_parser( self.do_install_langkit_support) self.install_lksp_parser.add_argument('install-dir', help='Installation directory.') self.install_lksp_parser.add_argument( '--force', '-f', action='store_true', help='Force installation, overwrite files.') self.add_build_args(self.build_lksp_parser) self.add_build_args(self.install_lksp_parser) # The create_context method will create the context and set it here # only right before executing commands. self.context = None # This will be set in the run method, when we have parsed arguments # from the command line. self.verbosity = None ":type: Verbosity"
def __init__(self): self.dirs = Directories( # It is assumed that manage.py is at the root of the language # definition source directory. lang_source_dir=path.dirname( path.abspath(inspect.getfile(self.__class__)) ) ) Diagnostics.set_lang_source_dir(self.dirs.lang_source_dir()) ######################## # Main argument parser # ######################## self.args_parser = args_parser = argparse.ArgumentParser( description='General manager to handle actions relative to' ' building/testing libadalang' ) self.subparsers = subparsers = args_parser.add_subparsers() args_parser.add_argument( '--build-dir', default='build', help=( 'Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.' ) ) args_parser.add_argument( '--enable-static', action='store_true', help='Enable the generation of static libraries (default:' ' disabled)' ) args_parser.add_argument( '--disable-static', action='store_false', dest='enable_static', help='Disable the generation of static libraries' ) args_parser.add_argument( '--enable-shared', action='store_true', default=True, help='Enable the generation (and testing) of shared libraries' ' (default: enabled)' ) args_parser.add_argument( '--disable-shared', action='store_false', dest='enable_shared', help='Disable the generation (and testing) of shared libraries' ) args_parser.add_argument( '--bindings', '-b', nargs='+', choices=('python', ), default=['python'], help='Bindings to generate (by default: only Python)' ) args_parser.add_argument( '--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level' ) # Don't enable this by default so that errors will not make automated # tasks hang. args_parser.add_argument( '-g', '--debug', action='store_true', help='In case of internal error or diagnostic error, run a' ' post-mortem PDB session' ) def create_parser(fn, needs_context=False): """ Create a subparser from a function. Uses the name and the docstring of the function to document the subparsers. :param (ManageScript, Namespace) -> None fn: The function to use. :param bool needs_context: Whether the executed function needs a CompileCtx created beforehand or not. :rtype: argparse.ArgumentParser """ p = subparsers.add_parser( # Take the name of the function without the do_ prefix fn.__name__.replace('do_', ''), # Take the first paragraph of the function's documentation as # help. help=fn.__doc__.split('\n\n')[0].strip() ) def internal(*args, **kwargs): if needs_context: self.set_context(*args, **kwargs) fn(*args, **kwargs) p.set_defaults(func=internal) return p ######## # Help # ######## self.help_parser = create_parser(self.do_help) ############ # Generate # ############ self.generate_parser = generate_parser = create_parser( self.do_generate, True ) self.add_generate_args(generate_parser) ######### # Build # ######### self.build_parser = build_parser = create_parser(self.do_build, True) self.add_build_args(build_parser) ######## # Make # ######## self.make_parser = make_parser = create_parser(self.do_make, True) self.add_generate_args(make_parser) self.add_build_args(make_parser) ########### # Install # ########### self.install_parser = install_parser = create_parser(self.do_install, True) install_parser.add_argument( 'install-dir', help='Installation directory.' ) ########## # Setenv # ########## self.setenv_parser = create_parser(self.do_setenv, True) # The create_context method will create the context and set it here # only right before executing commands so that coverage computation # will apply to create_context. self.context = None
def __init__(self, override_lang_source_dir=True): self.dirs = Directories( # It is assumed that manage.py is at the root of the language # definition source directory. lang_source_dir=path.dirname( path.abspath(inspect.getfile(self.__class__)))) if override_lang_source_dir: Diagnostics.set_lang_source_dir(self.dirs.lang_source_dir()) ######################## # Main argument parser # ######################## self.args_parser = args_parser = argparse.ArgumentParser( description='General manager to handle actions relative to' ' building/testing libadalang.') self.subparsers = subparsers = args_parser.add_subparsers() args_parser.add_argument( '--pp', action='store_true', default=False, help='Whether to automatically generate a pretty-printer along' ' with the parser for the grammar.') args_parser.add_argument( '--build-dir', default='build', help='Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.') args_parser.add_argument( '--enable-static', action='store_true', help='Enable the generation of static libraries (default:' ' disabled).') args_parser.add_argument( '--disable-static', action='store_false', dest='enable_static', help='Disable the generation of static libraries.') args_parser.add_argument( '--enable-shared', action='store_true', default=True, help='Enable the generation (and testing) of shared libraries' ' (default: enabled).') args_parser.add_argument( '--disable-shared', action='store_false', dest='enable_shared', help='Disable the generation (and testing) of shared libraries.') args_parser.add_argument('--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level') args_parser.add_argument( '--full-error-traces', '-E', action='store_true', default=False, help='Always show full error traces, whatever the verbosity level' ' (default: disabled).') args_parser.add_argument('--trace', '-t', action='append', default=[], help='Activate given debug trace.') args_parser.add_argument( '--no-langkit-support', action='store_true', help='Assuming that Langkit_Support is already built and' ' installed. This is useful to package the generated library' ' only.') # Don't enable this by default so that errors will not make automated # tasks hang. args_parser.add_argument( '-g', '--debug', action='store_true', help='In case of internal error or diagnostic error, run a' ' post-mortem PDB session.') args_parser.add_argument( '--profile', action='store_true', help='Run cProfile and langkit, and generate a data file' ' "langkit.prof".') args_parser.add_argument('--diagnostic-style', '-D', type=DiagnosticStyle, default=DiagnosticStyle.default, help='Style for error messages.') def create_parser(fn, needs_context=False): """ Create a subparser from a function. Uses the name and the docstring of the function to document the subparsers. :param (ManageScript, Namespace) -> None fn: The function to use. :param bool needs_context: Whether the executed function needs a CompileCtx created beforehand or not. :rtype: argparse.ArgumentParser """ p = subparsers.add_parser( # Take the name of the function without the do_ prefix and with # dashes instead of underscores. fn.__name__.replace('do_', '').replace('_', '-'), # Take the first paragraph of the function's documentation as # help. help=fn.__doc__.split('\n\n')[0].strip()) def internal(*args, **kwargs): if needs_context: self.set_context(*args, **kwargs) fn(*args, **kwargs) p.set_defaults(func=internal) return p ######## # Help # ######## self.help_parser = create_parser(self.do_help) ############ # Generate # ############ self.generate_parser = generate_parser = create_parser( self.do_generate, True) self.add_generate_args(generate_parser) ######### # Build # ######### self.build_parser = build_parser = create_parser(self.do_build, True) self.add_build_args(build_parser) ######## # Make # ######## self.make_parser = make_parser = create_parser(self.do_make, True) self.add_generate_args(make_parser) self.add_build_args(make_parser) ########### # Install # ########### self.install_parser = install_parser = create_parser( self.do_install, True) install_parser.add_argument('install-dir', help='Installation directory.') ########## # Setenv # ########## self.setenv_parser = create_parser(self.do_setenv, True) self.setenv_parser.add_argument( '--json', '-J', action='store_true', help='Output necessary env keys to JSON.') ############################################### # Generate, Build and Install Langkit_Support # ############################################### self.generate_lksp_parser = create_parser( self.do_generate_langkit_support) self.build_lksp_parser = create_parser(self.do_build_langkit_support) self.install_lksp_parser = create_parser( self.do_install_langkit_support) self.install_lksp_parser.add_argument('install-dir', help='Installation directory.') self.add_build_args(self.build_lksp_parser) self.add_build_args(self.install_lksp_parser) # The create_context method will create the context and set it here # only right before executing commands. self.context = None # This will be set in the run method, when we have parsed arguments # from the command line. self.verbosity = None ":type: Verbosity"
def main(): m = ManageScript() def add_build_mode_arg(parser): parser.add_argument( '--build-mode', '-b', choices=list(m.BUILD_MODES), default='dev', help='Selects a preset for build options' ) args_parser = argparse.ArgumentParser( description='Helper to build and install Langkit_Support' ) args_parser.add_argument( '--build-dir', default='build', help='Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.' ) args_parser.add_argument( '--library-types', default=LibraryTypes(relocatable=True), type=LibraryTypes.parse, help='Comma-separated list of library types to build (relocatable,' ' static-pic and static). By default, build only shared' ' libraries.' ) args_parser.add_argument( '--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level' ) subparsers = args_parser.add_subparsers() # Generate generate_parser = subparsers.add_parser( 'generate', help='Generate build tree and project file for Langkit_Support.' ) generate_parser.set_defaults(cmd='generate-langkit-support') # Build build_parser = subparsers.add_parser( 'build', help='Build Langkit_Support.' ) build_parser.add_argument( '--jobs', '-j', type=int, default=get_cpu_count(), help='Number of parallel jobs to spawn in parallel ' '(default: your number of cpu)' ) add_build_mode_arg(build_parser) build_parser.add_argument( '--gargs', help='Additional arguments to pass to GPRbuild' ) build_parser.set_defaults(cmd='build-langkit-support') # Install install_parser = subparsers.add_parser( 'install', help='Install Langkit_Support.' ) add_build_mode_arg(install_parser) install_parser.add_argument( 'install-dir', help='Installation directory.' ) install_parser.set_defaults(cmd='install-langkit-support') # Package dependencies pkg_deps_parser = subparsers.add_parser( 'package-deps', help='Bundle all dependencies to complete GNAT Pro' ) pkg_deps_parser.add_argument( 'package-dir', help='Destination directory.' ) Packager.add_prefix_options(pkg_deps_parser) Packager.add_platform_options(pkg_deps_parser) pkg_deps_parser.set_defaults(cmd='package-deps') # Standalone package for dynamic libraries pkg_std_dyn_parser = subparsers.add_parser( 'package-std-dyn', help='Bundle all dependencies to create standalone packages' ) pkg_std_dyn_parser.add_argument( 'package-dir', help='Destination directory.' ) Packager.add_prefix_options(pkg_std_dyn_parser) Packager.add_platform_options(pkg_std_dyn_parser) pkg_std_dyn_parser.set_defaults(cmd='package-std-dyn') args = args_parser.parse_args() argv = ['-E', '--build-dir={}'.format(args.build_dir), '--verbosity={}'.format(args.verbosity), '--library-types={}'.format(args.library_types)] def add_build_mode(): argv.append('--build-mode={}'.format(args.build_mode)) argv.append(args.cmd) if args.cmd == 'build-langkit-support': add_build_mode() if args.gargs: argv.append('--gargs={}'.format(args.gargs)) elif args.cmd == 'install-langkit-support': add_build_mode() argv.append(getattr(args, 'install-dir')) elif args.cmd == 'package-deps': p = Packager.from_args(args) p.package_deps(getattr(args, 'package-dir')) return elif args.cmd == 'package-std-dyn': p = Packager.from_args(args) pkg_dir = getattr(args, 'package-dir') p.package_standalone_dyn(pkg_dir) p.package_langkit_support_dyn(pkg_dir) return m.run(argv)
def add_common_args(subparser: argparse.ArgumentParser) -> None: """ Add command-line arguments common to all subcommands to ``subparser``. """ subparser.add_argument( '--build-dir', default='build', help='Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.') LibraryTypes.add_option(subparser) subparser.add_argument('--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level') subparser.add_argument( '--full-error-traces', '-E', action='store_true', default=False, help='Always show full error traces, whatever the verbosity level' ' (default: disabled).') subparser.add_argument('--trace', '-t', action='append', default=[], help='Activate given debug trace.') subparser.add_argument( '--no-ada-api', action='store_true', help='Do not generate units to provide an Ada API, and disable the' ' generation of mains.') # Don't enable this by default so that errors will not make automated # tasks hang. subparser.add_argument( '-g', '--debug', action='store_true', help='In case of internal error or diagnostic error, run a' ' post-mortem PDB session.') subparser.add_argument( '--profile', action='store_true', help='Run cProfile and langkit, and generate a data file' ' "langkit.prof".') subparser.add_argument('--diagnostic-style', '-D', type=DiagnosticStyle, default=DiagnosticStyle.default, help='Style for error messages.') subparser.add_argument( '--plugin-pass', action='append', default=[], help='Fully qualified name to a Langkit plug-in pass constructor.' ' The function must return a Langkit pass, whose type derives' ' from langkit.passes.AbstractPass. It will be ran at the end' ' of the pass preexisting order.') subparser.add_argument('--pass-on', type=str, action='append', default=[], help='Activate an optional pass by name.') subparser.add_argument('--pass-off', type=str, action='append', default=[], help='Deactivate an optional pass by name.')
def main(): m = ManageScript() args_parser = argparse.ArgumentParser( description='Helper to build and install Langkit_Support' ) args_parser.add_argument( '--build-dir', default='build', help='Directory to use for generated source code and binaries. By' ' default, use "build" in the current directory.' ) args_parser.add_argument( '--library-types', default=LibraryTypes(relocatable=True), type=LibraryTypes.parse, help='Comma-separated list of library types to build (relocatable,' ' static-pic and static). By default, build only shared' ' libraries.' ) args_parser.add_argument( '--verbosity', '-v', nargs='?', type=Verbosity, choices=Verbosity.choices(), default=Verbosity('info'), const=Verbosity('debug'), help='Verbosity level' ) subparsers = args_parser.add_subparsers() # Generate generate_parser = subparsers.add_parser( 'generate', help='Generate build tree and project file for Langkit_Support.' ) generate_parser.set_defaults(cmd='generate-langkit-support') # Build build_parser = subparsers.add_parser( 'build', help='Build Langkit_Support.' ) build_parser.add_argument( '--jobs', '-j', type=int, default=get_cpu_count(), help='Number of parallel jobs to spawn in parallel ' '(default: your number of cpu)' ) build_parser.add_argument( '--build-mode', '-b', choices=list(m.BUILD_MODES), default='dev', help='Selects a preset for build options' ) build_parser.add_argument( '--gargs', help='Additional arguments to pass to GPRbuild' ) build_parser.set_defaults(cmd='build-langkit-support') # Install install_parser = subparsers.add_parser( 'install', help='Install Langkit_Support.' ) install_parser.add_argument( 'install-dir', help='Installation directory.' ) install_parser.set_defaults(cmd='install-langkit-support') args = args_parser.parse_args() argv = ['-E', '--build-dir={}'.format(args.build_dir), '--verbosity={}'.format(args.verbosity), '--library-types={}'.format(args.library_types)] argv.append(args.cmd) if args.cmd == 'build-langkit-support': argv.append('--build-mode={}'.format(args.build_mode)) if args.gargs: argv.append('--gargs={}'.format(args.gargs)) if args.cmd == 'install-langkit-support': argv.append(getattr(args, 'install-dir')) m.run(argv)