def get_default_options_parser(add_clean=True, add_options=True, add_app_config=False): """Create a new options parser with the default compiler options added Keyword arguments: add_clean - add the clean argument? add_options - add the options argument? """ parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = list(TOOLCHAINS) toolchainlist.sort() parser.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(targetnames)), metavar="MCU", type=argparse_many( argparse_force_uppercase_type( targetnames, "MCU"))) parser.add_argument("-t", "--tool", help=("build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist)), metavar="TOOLCHAIN", type=argparse_many( argparse_force_uppercase_type( toolchainlist, "toolchain"))) parser.add_argument("--color", help="print Warnings, and Errors in color", action="store_true", default=False) parser.add_argument("--cflags", default=[], action="append", help="Extra flags to provide to the C compiler") parser.add_argument("--asmflags", default=[], action="append", help="Extra flags to provide to the assembler") parser.add_argument("--ldflags", default=[], action="append", help="Extra flags to provide to the linker") if add_clean: parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the build directory") if add_options: parser.add_argument("--profile", dest="profile", action="append", type=argparse_profile_filestring_type, help="Build profile to use. Can be either path to json" \ "file or one of the default one ({})".format(", ".join(list_profiles())), default=[]) if add_app_config: parser.add_argument("--app-config", default=None, dest="app_config", type=argparse_filestring_type, help="Path of an app configuration file (Default is to look for 'mbed_app.json')") return parser
def main(): """Entry point""" parser = ArgumentParser() parser.add_argument("-c", dest="config", default="examples.json") subparsers = parser.add_subparsers() import_cmd = subparsers.add_parser("import") import_cmd.set_defaults(fn=do_import) version_cmd = subparsers.add_parser("tag") version_cmd.add_argument("tag") version_cmd.set_defaults(fn=do_versionning) compile_cmd = subparsers.add_parser("compile") compile_cmd.set_defaults(fn=do_compile), compile_cmd.add_argument("toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS, type=argparse_force_uppercase_type( SUPPORTED_TOOLCHAINS, "toolchain")), export_cmd = subparsers.add_parser("export") export_cmd.set_defaults(fn=do_export), export_cmd.add_argument("ide", nargs="*", default=SUPPORTED_IDES, type=argparse_force_uppercase_type( SUPPORTED_IDES, "ide")) args = parser.parse_args() config = json.load( open(os.path.join(os.path.dirname(__file__), args.config))) return args.fn(args, config)
def main(): """Entry point""" official_targets = get_mbed_official_release("5") official_target_names = [x[0] for x in official_targets] parser = ArgumentParser() parser.add_argument("-c", dest="config", default="examples.json") parser.add_argument("-e", "--example", help=("filter the examples used in the script"), type=argparse_many(lambda x: x), default=[]) subparsers = parser.add_subparsers() import_cmd = subparsers.add_parser("import") import_cmd.set_defaults(fn=do_import) clone_cmd = subparsers.add_parser("clone") clone_cmd.set_defaults(fn=do_clone) deploy_cmd = subparsers.add_parser("deploy") deploy_cmd.set_defaults(fn=do_deploy) version_cmd = subparsers.add_parser("tag") version_cmd.add_argument("tag") version_cmd.set_defaults(fn=do_versionning) compile_cmd = subparsers.add_parser("compile") compile_cmd.set_defaults(fn=do_compile), compile_cmd.add_argument( "toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS, type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS, "toolchain")), compile_cmd.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(official_target_names)), metavar="MCU", type=argparse_many( argparse_force_uppercase_type( official_target_names, "MCU")), default=official_target_names) export_cmd = subparsers.add_parser("export") export_cmd.set_defaults(fn=do_export), export_cmd.add_argument( "ide", nargs="*", default=SUPPORTED_IDES, type=argparse_force_uppercase_type(SUPPORTED_IDES, "ide")) export_cmd.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(official_target_names)), metavar="MCU", type=argparse_many( argparse_force_uppercase_type( official_target_names, "MCU")), default=official_target_names) args = parser.parse_args() config = json.load(open(os.path.join(os.path.dirname(__file__), args.config))) all_examples = [] for example in config['examples']: all_examples = all_examples + [basename(x['repo']) for x in lib.get_repo_list(example)] examples = [x for x in all_examples if x in args.example] if args.example else all_examples return args.fn(args, config, examples)
def get_default_options_parser(add_clean=True, add_options=True, add_app_config=False): """Create a new options parser with the default compiler options added Keyword arguments: add_clean - add the clean argument? add_options - add the options argument? """ parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = list(TOOLCHAINS) toolchainlist.sort() parser.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(targetnames)), metavar="MCU") parser.add_argument("-t", "--tool", help=("build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist)), metavar="TOOLCHAIN", type=argparse_many( argparse_force_uppercase_type( toolchainlist, "toolchain"))) parser.add_argument("--color", help="print Warnings, and Errors in color", action="store_true", default=False) parser.add_argument("--cflags", type=argparse_deprecate(FLAGS_DEPRECATION_MESSAGE), help="Deprecated. " + FLAGS_DEPRECATION_MESSAGE) parser.add_argument("--asmflags", type=argparse_deprecate(FLAGS_DEPRECATION_MESSAGE), help="Deprecated. " + FLAGS_DEPRECATION_MESSAGE) parser.add_argument("--ldflags", type=argparse_deprecate(FLAGS_DEPRECATION_MESSAGE), help="Deprecated. " + FLAGS_DEPRECATION_MESSAGE) if add_clean: parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the build directory") if add_options: parser.add_argument("--profile", dest="profile", action="append", type=argparse_profile_filestring_type, help="Build profile to use. Can be either path to json" \ "file or one of the default one ({})".format(", ".join(list_profiles())), default=[]) if add_app_config: parser.add_argument("--app-config", default=None, dest="app_config", type=argparse_filestring_type, help="Path of an app configuration file (Default is to look for 'mbed_app.json')") return parser
def main(): """Entry point""" toolchainlist = ["iar", "uvision", "uvision5"] default_tests = [test_name_known("MBED_BLINKY")] targetnames = TARGET_NAMES targetnames.sort() parser = argparse.ArgumentParser( description="Test progen builders. Leave any flag off" " to run with all possible options.") parser.add_argument("-i", dest="ides", default=toolchainlist, type=argparse_many( argparse_force_lowercase_type( toolchainlist, "toolchain")), help="The target IDE: %s" % str(toolchainlist)) parser.add_argument("-p", type=argparse_many(test_name_known), dest="programs", help="The index of the desired test program: [0-%d]" % (len(TESTS) - 1), default=default_tests) parser.add_argument("-n", type=argparse_many(test_name_known), dest="programs", help="The name of the desired test program", default=default_tests) parser.add_argument("-m", "--mcu", metavar="MCU", default='LPC1768', nargs="+", type=argparse_force_uppercase_type(targetnames, "MCU"), help="generate project for the given MCU (%s)" % ', '.join(targetnames)) parser.add_argument("-c", "--clean", dest="clean", action="store_true", help="clean up the exported project files", default=False) options = parser.parse_args() test = ProgenBuildTest(options.ides, options.mcu, options.programs) successes, failures, skips = test.generate_and_build(clean=options.clean) print_results(successes, failures, skips) sys.exit(len(failures))
def main(): """Entry point""" parser = ArgumentParser() subparsers = parser.add_subparsers() import_cmd = subparsers.add_parser("import") import_cmd.set_defaults(fn=do_import) compile_cmd = subparsers.add_parser("compile") compile_cmd.set_defaults(fn=do_compile) compile_cmd.add_argument( "toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS, type=argparse_force_uppercase_type(SUPPORTED_TOOLCHAINS, "toolchain")) args = parser.parse_args() return args.fn(args)
def extract_mcus(parser, options): try: if options.source_dir: for source_dir in options.source_dir: Target.add_extra_targets(source_dir) update_target_data() except KeyError: pass targetnames = TARGET_NAMES targetnames.sort() try: return argparse_many(argparse_force_uppercase_type(targetnames, "MCU"))(options.mcu) except ArgumentTypeError as exc: args_error(parser, "argument -m/--mcu: {}".format(str(exc)))
def main(): """Entry point""" # Parse Options parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = EXPORTERS.keys() toolchainlist.sort() parser.add_argument("-m", "--mcu", metavar="MCU", default='LPC1768', type=argparse_force_uppercase_type(targetnames, "MCU"), help="generate project for the given MCU ({})".format( ', '.join(targetnames))) parser.add_argument("-i", dest="ide", default='uvision', type=argparse_force_lowercase_type( toolchainlist, "toolchain"), help="The target IDE: %s" % str(toolchainlist)) parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the export directory") group = parser.add_mutually_exclusive_group(required=False) group.add_argument("-p", type=test_known, dest="program", help="The index of the desired test program: [0-%s]" % (len(TESTS) - 1)) group.add_argument("-n", type=test_name_known, dest="program", help="The name of the desired test program") parser.add_argument( "-b", dest="build", default=False, action="store_true", help="use the mbed library build, instead of the sources") group.add_argument("-L", "--list-tests", action="store_true", dest="list_tests", default=False, help="list available programs in order and exit") group.add_argument("-S", "--list-matrix", action="store_true", dest="supported_ides", default=False, help="displays supported matrix of MCUs and IDEs") parser.add_argument("-E", action="store_true", dest="supported_ides_html", default=False, help="writes tools/export/README.md") parser.add_argument("--source", action="append", type=argparse_filestring_type, dest="source_dir", default=[], help="The source (input) directory") parser.add_argument("-D", action="append", dest="macros", help="Add a macro definition") parser.add_argument("-o", type=argparse_many(str), dest="opts", default=["debug-info"], help="Toolchain options") options = parser.parse_args() # Print available tests in order and exit if options.list_tests is True: print '\n'.join([str(test) for test in sorted(TEST_MAP.values())]) sys.exit() # Only prints matrix of supported IDEs if options.supported_ides: print mcu_ide_matrix() exit(0) # Only prints matrix of supported IDEs if options.supported_ides_html: html = mcu_ide_matrix(verbose_html=True) try: with open("./export/README.md", "w") as readme: readme.write("Exporter IDE/Platform Support\n") readme.write("-----------------------------------\n") readme.write("\n") readme.write(html) except IOError as exc: print "I/O error({0}): {1}".format(exc.errno, exc.strerror) except: print "Unexpected error:", sys.exc_info()[0] raise exit(0) # Clean Export Directory if options.clean: if exists(EXPORT_DIR): rmtree(EXPORT_DIR) for mcu in options.mcu: zip_proj = not bool(options.source_dir) # Target if not options.mcu: args_error(parser, "argument -m/--mcu is required") # Toolchain if not options.ide: args_error(parser, "argument -i is required") if (options.program is None) and (not options.source_dir): args_error(parser, "one of -p, -n, or --source is required") # Export to selected toolchain """modified by lex 20161103, add ", export_path=EXPORT_UVISION_DIR" to move uvision project file into IoT-OS/projects""" export(options.mcu, options.ide, build=options.build, src=options.source_dir, macros=options.macros, project_id=options.program, clean=options.clean, zip_proj=zip_proj, options=options.opts, export_path=EXPORT_UVISION_DIR)
def main(): """Entry point""" # Parse Options parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = EXPORTERS.keys() toolchainlist.sort() parser.add_argument("-m", "--mcu", metavar="MCU", default='LPC1768', type=argparse_force_uppercase_type(targetnames, "MCU"), help="generate project for the given MCU ({})".format( ', '.join(targetnames))) parser.add_argument("-i", dest="ide", default='uvision', type=argparse_force_lowercase_type( toolchainlist, "toolchain"), help="The target IDE: %s"% str(toolchainlist)) parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the export directory") group = parser.add_mutually_exclusive_group(required=False) group.add_argument( "-p", type=test_known, dest="program", help="The index of the desired test program: [0-%s]"% (len(TESTS)-1)) group.add_argument("-n", type=test_name_known, dest="program", help="The name of the desired test program") parser.add_argument("-b", dest="build", default=False, action="store_true", help="use the mbed library build, instead of the sources") group.add_argument("-L", "--list-tests", action="store_true", dest="list_tests", default=False, help="list available programs in order and exit") group.add_argument("-S", "--list-matrix", action="store_true", dest="supported_ides", default=False, help="displays supported matrix of MCUs and IDEs") parser.add_argument("-E", action="store_true", dest="supported_ides_html", default=False, help="writes tools/export/README.md") parser.add_argument("--source", action="append", type=argparse_filestring_type, dest="source_dir", default=[], help="The source (input) directory") parser.add_argument("-D", action="append", dest="macros", help="Add a macro definition") parser.add_argument("--profile", type=argparse_filestring_type, default=[], help="Toolchain profile") parser.add_argument("--update-packs", dest="update_packs", action="store_true", default=False) options = parser.parse_args() # Print available tests in order and exit if options.list_tests is True: print '\n'.join([str(test) for test in sorted(TEST_MAP.values())]) sys.exit() # Only prints matrix of supported IDEs if options.supported_ides: print_large_string(mcu_ide_matrix()) exit(0) # Only prints matrix of supported IDEs if options.supported_ides_html: html = mcu_ide_matrix(verbose_html=True) try: with open("./export/README.md", "w") as readme: readme.write("Exporter IDE/Platform Support\n") readme.write("-----------------------------------\n") readme.write("\n") readme.write(html) except IOError as exc: print "I/O error({0}): {1}".format(exc.errno, exc.strerror) except: print "Unexpected error:", sys.exc_info()[0] raise exit(0) if options.update_packs: from tools.arm_pack_manager import Cache cache = Cache(True, True) cache.cache_descriptors() # Clean Export Directory if options.clean: if exists(EXPORT_DIR): rmtree(EXPORT_DIR) for mcu in options.mcu: zip_proj = not bool(options.source_dir) # Target if not options.mcu: args_error(parser, "argument -m/--mcu is required") # Toolchain if not options.ide: args_error(parser, "argument -i is required") if (options.program is None) and (not options.source_dir): args_error(parser, "one of -p, -n, or --source is required") # Export to selected toolchain exporter, toolchain_name = get_exporter_toolchain(options.ide) if options.mcu not in exporter.TARGETS: args_error(parser, "%s not supported by %s"%(options.mcu,options.ide)) profile = extract_profile(parser, options, toolchain_name) export(options.mcu, options.ide, build=options.build, src=options.source_dir, macros=options.macros, project_id=options.program, clean=options.clean, zip_proj=zip_proj, build_profile=profile)
def get_default_options_parser(add_clean=True, add_options=True, add_app_config=False): """Create a new options parser with the default compiler options added Keyword arguments: add_clean - add the clean argument? add_options - add the options argument? """ parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = list(TOOLCHAINS) toolchainlist.sort() parser.add_argument( "-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(targetnames)), metavar="MCU", type=argparse_many(argparse_force_uppercase_type(targetnames, "MCU"))) parser.add_argument("-t", "--tool", help=("build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist)), metavar="TOOLCHAIN", type=argparse_many( argparse_force_uppercase_type( toolchainlist, "toolchain"))) parser.add_argument("--color", help="print Warnings, and Errors in color", action="store_true", default=False) parser.add_argument("--cflags", default=[], action="append", help="Extra flags to provide to the C compiler") parser.add_argument("--asmflags", default=[], action="append", help="Extra flags to provide to the assembler") parser.add_argument("--ldflags", default=[], action="append", help="Extra flags to provide to the linker") if add_clean: parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the build directory") if add_options: parser.add_argument( "-o", "--options", action="append", help=('Add a build argument ("save-asm": save the ' 'asm generated by the compiler, "debug-info":' ' generate debugging information, "analyze": ' 'run Goanna static code analyzer")'), type=argparse_lowercase_hyphen_type( ['save-asm', 'debug-info', 'analyze', 'small-lib', 'std-lib'], "build option")) if add_app_config: parser.add_argument( "--app-config", default=None, dest="app_config", type=argparse_filestring_type, help= "Path of an app configuration file (Default is to look for 'mbed_app.json')" ) return parser
def main(): """Entry point""" # Parse Options parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = EXPORTERS.keys() toolchainlist.sort() parser.add_argument("-m", "--mcu", metavar="MCU", type=argparse_force_uppercase_type(targetnames, "MCU"), help="generate project for the given MCU ({})".format( ', '.join(targetnames))) parser.add_argument("-i", dest="ide", type=argparse_force_lowercase_type( toolchainlist, "toolchain"), help="The target IDE: %s" % str(toolchainlist)) parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the export directory") group = parser.add_mutually_exclusive_group(required=False) group.add_argument("-p", type=test_known, dest="program", help="The index of the desired test program: [0-%s]" % (len(TESTS) - 1)) group.add_argument("-n", type=test_name_known, dest="program", help="The name of the desired test program") parser.add_argument( "-b", dest="build", default=False, action="store_true", help="use the mbed library build, instead of the sources") group.add_argument("-L", "--list-tests", action="store_true", dest="list_tests", default=False, help="list available programs in order and exit") group.add_argument("-S", "--list-matrix", dest="supported_ides", default=False, const="matrix", choices=["matrix", "ides"], nargs="?", help="displays supported matrix of MCUs and IDEs") parser.add_argument("-E", action="store_true", dest="supported_ides_html", default=False, help="writes tools/export/README.md") parser.add_argument("--source", action="append", type=argparse_filestring_type, dest="source_dir", default=[], help="The source (input) directory") parser.add_argument("-D", action="append", dest="macros", help="Add a macro definition") parser.add_argument("--profile", dest="profile", action="append", type=argparse_profile_filestring_type, help="Build profile to use. Can be either path to json" \ "file or one of the default one ({})".format(", ".join(list_profiles())), default=[]) parser.add_argument("--update-packs", dest="update_packs", action="store_true", default=False) parser.add_argument("--app-config", dest="app_config", default=None) options = parser.parse_args() # Print available tests in order and exit if options.list_tests is True: print '\n'.join([str(test) for test in sorted(TEST_MAP.values())]) sys.exit() # Only prints matrix of supported IDEs if options.supported_ides: if options.supported_ides == "matrix": print_large_string(mcu_ide_matrix()) elif options.supported_ides == "ides": print mcu_ide_list() exit(0) # Only prints matrix of supported IDEs if options.supported_ides_html: html = mcu_ide_matrix(verbose_html=True) try: with open("./export/README.md", "w") as readme: readme.write("Exporter IDE/Platform Support\n") readme.write("-----------------------------------\n") readme.write("\n") readme.write(html) except IOError as exc: print "I/O error({0}): {1}".format(exc.errno, exc.strerror) except: print "Unexpected error:", sys.exc_info()[0] raise exit(0) if options.update_packs: from tools.arm_pack_manager import Cache cache = Cache(True, True) cache.cache_descriptors() # Target if not options.mcu: args_error(parser, "argument -m/--mcu is required") # Toolchain if not options.ide: args_error(parser, "argument -i is required") # Clean Export Directory if options.clean: if exists(EXPORT_DIR): rmtree(EXPORT_DIR) for mcu in options.mcu: zip_proj = not bool(options.source_dir) if (options.program is None) and (not options.source_dir): args_error(parser, "one of -p, -n, or --source is required") # Export to selected toolchain exporter, toolchain_name = get_exporter_toolchain(options.ide) if options.mcu not in exporter.TARGETS: args_error(parser, "%s not supported by %s" % (options.mcu, options.ide)) profile = extract_profile(parser, options, toolchain_name, fallback="debug") if options.clean: rmtree(BUILD_DIR) mcu = extract_mcus(parser, options)[0] export(mcu, options.ide, build=options.build, src=options.source_dir, macros=options.macros, project_id=options.program, zip_proj=zip_proj, build_profile=profile, app_config=options.app_config)
def get_default_options_parser(add_clean=True, add_options=True): """Create a new options parser with the default compiler options added Keyword arguments: add_clean - add the clean argument? add_options - add the options argument? """ parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = list(TOOLCHAINS) toolchainlist.sort() parser.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(targetnames)), metavar="MCU", type=argparse_many( argparse_force_uppercase_type( targetnames, "MCU"))) parser.add_argument("-t", "--tool", help=("build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist)), metavar="TOOLCHAIN", type=argparse_many( argparse_force_uppercase_type( toolchainlist, "toolchain"))) parser.add_argument("--color", help="print Warnings, and Errors in color", action="store_true", default=False) parser.add_argument("--cflags", default=[], action="append", help="Extra flags to provide to the C compiler") parser.add_argument("--asmflags", default=[], action="append", help="Extra flags to provide to the assembler") parser.add_argument("--ldflags", default=[], action="append", help="Extra flags to provide to the linker") if add_clean: parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the build directory") if add_options: parser.add_argument("-o", "--options", action="append", help=('Add a build argument ("save-asm": save the ' 'asm generated by the compiler, "debug-info":' ' generate debugging information, "analyze": ' 'run Goanna static code analyzer")'), type=argparse_lowercase_hyphen_type(['save-asm', 'debug-info', 'analyze', 'small-lib', 'std-lib'], "build option")) return parser
def parse_args(): """Parse the arguments passed to the script.""" official_targets = get_mbed_official_release("5") official_target_names = [x[0] for x in official_targets] parser = ArgumentParser() parser.add_argument("-c", dest="config", default="examples.json") parser.add_argument("-e", "--example", help=("filter the examples used in the script"), type=argparse_many(lambda x: x), default=[]) subparsers = parser.add_subparsers() import_cmd = subparsers.add_parser( "import", help="import of examples in config file") import_cmd.set_defaults(fn=do_import) clone_cmd = subparsers.add_parser("clone", help="clone examples in config file") clone_cmd.set_defaults(fn=do_clone) list_cmd = subparsers.add_parser( "list", help="list examples in config file in a table") list_cmd.set_defaults(fn=do_list) symlink_cmd = subparsers.add_parser( "symlink", help="create symbolic link to given mbed-os PATH") symlink_cmd.add_argument("PATH", help=" path of mbed-os to be symlinked") symlink_cmd.set_defaults(fn=do_symlink) deploy_cmd = subparsers.add_parser( "deploy", help="mbed deploy for examples in config file") deploy_cmd.set_defaults(fn=do_deploy) version_cmd = subparsers.add_parser("update", help="update mbed-os to sepcific tags") version_cmd.add_argument("TAG", help=" tag of mbed-os") version_cmd.set_defaults(fn=do_update) compile_cmd = subparsers.add_parser("compile", help="compile of examples") compile_cmd.set_defaults(fn=do_compile), compile_cmd.add_argument("toolchains", nargs="*", default=SUPPORTED_TOOLCHAINS, type=argparse_force_uppercase_type( SUPPORTED_TOOLCHAINS, "toolchain")), compile_cmd.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(official_target_names)), metavar="MCU", type=argparse_many( argparse_force_uppercase_type( official_target_names, "MCU")), default=official_target_names) compile_cmd.add_argument("--profiles", nargs='+', metavar="profile", help="build profile(s)") compile_cmd.add_argument( "-j", "--jobs", dest='jobs', metavar="NUMBER", type=int, default=0, help= "Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)" ) compile_cmd.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Verbose diagnostic output") export_cmd = subparsers.add_parser("export", help="export of examples") export_cmd.set_defaults(fn=do_export) export_cmd.add_argument("ide", nargs="*", default=SUPPORTED_IDES, type=argparse_force_uppercase_type( SUPPORTED_IDES, "ide")) export_cmd.add_argument("-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(official_target_names)), metavar="MCU", type=argparse_many( argparse_force_uppercase_type( official_target_names, "MCU")), default=official_target_names) return parser.parse_args()
def get_default_options_parser(add_clean=True, add_options=True, add_app_config=False): """Create a new options parser with the default compiler options added Keyword arguments: add_clean - add the clean argument? add_options - add the options argument? """ parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = list(TOOLCHAINS) toolchainlist.sort() parser.add_argument( "-m", "--mcu", help=("build for the given MCU (%s)" % ', '.join(targetnames)), metavar="MCU", type=argparse_many(argparse_force_uppercase_type(targetnames, "MCU"))) parser.add_argument("-t", "--tool", help=("build using the given TOOLCHAIN (%s)" % ', '.join(toolchainlist)), metavar="TOOLCHAIN", type=argparse_many( argparse_force_uppercase_type( toolchainlist, "toolchain"))) parser.add_argument("--color", help="print Warnings, and Errors in color", action="store_true", default=False) parser.add_argument("--cflags", default=[], action="append", help="Extra flags to provide to the C compiler") parser.add_argument("--asmflags", default=[], action="append", help="Extra flags to provide to the assembler") parser.add_argument("--ldflags", default=[], action="append", help="Extra flags to provide to the linker") if add_clean: parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the build directory") if add_options: parser.add_argument("--profile", dest="profile", action="append", type=argparse_filestring_type, default=[]) if add_app_config: parser.add_argument( "--app-config", default=None, dest="app_config", type=argparse_filestring_type, help= "Path of an app configuration file (Default is to look for 'mbed_app.json')" ) return parser