Merge pull request #9401 from loverdeg-ep/custom-targets-option

tools: adds and implements a --custom-targets command line switch
pull/9421/head
Martin Kojtal 2019-01-21 13:17:01 +01:00 committed by GitHub
commit 091fe2bed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -68,6 +68,7 @@ class MbedExtendedArgs(MainArgumentParser):
parser.add_argument('-m', '--mcu') parser.add_argument('-m', '--mcu')
parser.add_argument('-t', '--toolchain') parser.add_argument('-t', '--toolchain')
parser.add_argument('--source', nargs='+', dest='source_dir') parser.add_argument('--source', nargs='+', dest='source_dir')
parser.add_argument('--custom-targets', dest='custom_targets_directory')
parser.add_argument('--build') parser.add_argument('--build')
exclusions.append('payload') exclusions.append('payload')
super(MbedExtendedArgs, self)._addCreateArgs(parser, exclusions) super(MbedExtendedArgs, self)._addCreateArgs(parser, exclusions)

View File

@ -52,6 +52,13 @@ def get_default_options_parser(add_clean=True, add_options=True,
', '.join(targetnames)), ', '.join(targetnames)),
metavar="MCU") metavar="MCU")
parser.add_argument("--custom-targets",
help="Specify directory containing custom_targets.json",
type=argparse_filestring_type,
dest="custom_targets_directory",
action="append",
default=None)
parser.add_argument("-t", "--tool", parser.add_argument("-t", "--tool",
help=("build using the given TOOLCHAIN (%s)" % help=("build using the given TOOLCHAIN (%s)" %
', '.join(toolchainlist)), ', '.join(toolchainlist)),
@ -123,7 +130,11 @@ def extract_profile(parser, options, toolchain, fallback="develop"):
def extract_mcus(parser, options): def extract_mcus(parser, options):
try: try:
if options.source_dir: if options.custom_targets_directory:
for custom_targets_directory in options.custom_targets_directory:
Target.add_extra_targets(custom_targets_directory)
update_target_data()
elif options.source_dir:
for source_dir in options.source_dir: for source_dir in options.source_dir:
Target.add_extra_targets(source_dir) Target.add_extra_targets(source_dir)
update_target_data() update_target_data()
@ -135,4 +146,3 @@ def extract_mcus(parser, options):
return argparse_many(argparse_force_uppercase_type(targetnames, "MCU"))(options.mcu) return argparse_many(argparse_force_uppercase_type(targetnames, "MCU"))(options.mcu)
except ArgumentTypeError as exc: except ArgumentTypeError as exc:
args_error(parser, "argument -m/--mcu: {}".format(str(exc))) args_error(parser, "argument -m/--mcu: {}".format(str(exc)))

View File

@ -270,6 +270,15 @@ def get_args(argv):
help="The source (input) directory" help="The source (input) directory"
) )
parser.add_argument(
"--custom-targets",
action="append",
type=argparse_filestring_type,
dest="custom_targets_directory",
default=[],
help="Specify directory containing custom_targets.json"
)
parser.add_argument( parser.add_argument(
"-D", "-D",
action="append", action="append",