mirror of https://github.com/ARMmbed/mbed-os.git
Find extra targets in all source folders
parent
58c52fa2e7
commit
2c4475cacc
|
@ -32,6 +32,7 @@ from tools.toolchains import mbedToolchain
|
||||||
from tools.targets import TARGET_NAMES, TARGET_MAP
|
from tools.targets import TARGET_NAMES, TARGET_MAP
|
||||||
from tools.options import get_default_options_parser
|
from tools.options import get_default_options_parser
|
||||||
from tools.options import extract_profile
|
from tools.options import extract_profile
|
||||||
|
from tools.options import extract_mcus
|
||||||
from tools.build_api import build_library, build_mbed_libs, build_lib
|
from tools.build_api import build_library, build_mbed_libs, build_lib
|
||||||
from tools.build_api import mcu_toolchain_matrix
|
from tools.build_api import mcu_toolchain_matrix
|
||||||
from tools.build_api import print_build_results
|
from tools.build_api import print_build_results
|
||||||
|
@ -134,7 +135,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
# Get target list
|
# Get target list
|
||||||
targets = options.mcu if options.mcu else TARGET_NAMES
|
targets = extract_mcus(parser, options) if options.mcu else TARGET_NAMES
|
||||||
|
|
||||||
# Get toolchains list
|
# Get toolchains list
|
||||||
toolchains = options.tool if options.tool else TOOLCHAINS
|
toolchains = options.tool if options.tool else TOOLCHAINS
|
||||||
|
|
|
@ -26,6 +26,7 @@ sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
from tools.utils import args_error
|
from tools.utils import args_error
|
||||||
from tools.options import get_default_options_parser
|
from tools.options import get_default_options_parser
|
||||||
|
from tools.options import extract_mcus
|
||||||
from tools.build_api import get_config
|
from tools.build_api import get_config
|
||||||
from config import Config
|
from config import Config
|
||||||
from utils import argparse_filestring_type
|
from utils import argparse_filestring_type
|
||||||
|
@ -49,7 +50,7 @@ if __name__ == '__main__':
|
||||||
# Target
|
# Target
|
||||||
if options.mcu is None :
|
if options.mcu is None :
|
||||||
args_error(parser, "argument -m/--mcu is required")
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
target = options.mcu[0]
|
target = extract_mcus(parser, options)[0]
|
||||||
|
|
||||||
# Toolchain
|
# Toolchain
|
||||||
if options.tool is None:
|
if options.tool is None:
|
||||||
|
|
|
@ -42,6 +42,7 @@ from tools.tests import test_known, test_name_known
|
||||||
from tools.targets import TARGET_MAP
|
from tools.targets import TARGET_MAP
|
||||||
from tools.options import get_default_options_parser
|
from tools.options import get_default_options_parser
|
||||||
from tools.options import extract_profile
|
from tools.options import extract_profile
|
||||||
|
from tools.options import extract_mcus
|
||||||
from tools.build_api import build_project
|
from tools.build_api import build_project
|
||||||
from tools.build_api import mcu_toolchain_matrix
|
from tools.build_api import mcu_toolchain_matrix
|
||||||
from tools.build_api import mcu_toolchain_list
|
from tools.build_api import mcu_toolchain_list
|
||||||
|
@ -200,7 +201,7 @@ if __name__ == '__main__':
|
||||||
# Target
|
# Target
|
||||||
if options.mcu is None :
|
if options.mcu is None :
|
||||||
args_error(parser, "argument -m/--mcu is required")
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
mcu = options.mcu[0]
|
mcu = extract_mcus(parser, options)[0]
|
||||||
|
|
||||||
# Toolchain
|
# Toolchain
|
||||||
if options.tool is None:
|
if options.tool is None:
|
||||||
|
|
|
@ -17,9 +17,9 @@ limitations under the License.
|
||||||
from json import load
|
from json import load
|
||||||
from os.path import join, dirname
|
from os.path import join, dirname
|
||||||
from os import listdir
|
from os import listdir
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser, ArgumentTypeError
|
||||||
from tools.toolchains import TOOLCHAINS
|
from tools.toolchains import TOOLCHAINS
|
||||||
from tools.targets import TARGET_NAMES
|
from tools.targets import TARGET_NAMES, Target, update_target_data
|
||||||
from tools.utils import argparse_force_uppercase_type, \
|
from tools.utils import argparse_force_uppercase_type, \
|
||||||
argparse_lowercase_hyphen_type, argparse_many, \
|
argparse_lowercase_hyphen_type, argparse_many, \
|
||||||
argparse_filestring_type, args_error, argparse_profile_filestring_type,\
|
argparse_filestring_type, args_error, argparse_profile_filestring_type,\
|
||||||
|
@ -47,10 +47,7 @@ def get_default_options_parser(add_clean=True, add_options=True,
|
||||||
parser.add_argument("-m", "--mcu",
|
parser.add_argument("-m", "--mcu",
|
||||||
help=("build for the given MCU (%s)" %
|
help=("build for the given MCU (%s)" %
|
||||||
', '.join(targetnames)),
|
', '.join(targetnames)),
|
||||||
metavar="MCU",
|
metavar="MCU")
|
||||||
type=argparse_many(
|
|
||||||
argparse_force_uppercase_type(
|
|
||||||
targetnames, "MCU")))
|
|
||||||
|
|
||||||
parser.add_argument("-t", "--tool",
|
parser.add_argument("-t", "--tool",
|
||||||
help=("build using the given TOOLCHAIN (%s)" %
|
help=("build using the given TOOLCHAIN (%s)" %
|
||||||
|
@ -130,3 +127,19 @@ def mcu_is_enabled(parser, mcu):
|
||||||
"See https://developer.mbed.org/platforms/Renesas-GR-PEACH/#important-notice "
|
"See https://developer.mbed.org/platforms/Renesas-GR-PEACH/#important-notice "
|
||||||
"for more information") % (mcu, mcu))
|
"for more information") % (mcu, mcu))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def extract_mcus(parser, options):
|
||||||
|
try:
|
||||||
|
extra_targets = [join(src, "custom_targets.json") for src in options.source_dir]
|
||||||
|
for filename in extra_targets:
|
||||||
|
Target.add_extra_targets(filename)
|
||||||
|
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)))
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ from tools.utils import argparse_filestring_type, argparse_profile_filestring_ty
|
||||||
from tools.utils import argparse_force_lowercase_type
|
from tools.utils import argparse_force_lowercase_type
|
||||||
from tools.utils import argparse_force_uppercase_type
|
from tools.utils import argparse_force_uppercase_type
|
||||||
from tools.utils import print_large_string
|
from tools.utils import print_large_string
|
||||||
from tools.options import extract_profile, list_profiles
|
from tools.options import extract_profile, list_profiles, extract_mcus
|
||||||
|
|
||||||
def setup_project(ide, target, program=None, source_dir=None, build=None, export_path=None):
|
def setup_project(ide, target, program=None, source_dir=None, build=None, export_path=None):
|
||||||
"""Generate a name, if not provided, and find dependencies
|
"""Generate a name, if not provided, and find dependencies
|
||||||
|
@ -247,7 +247,8 @@ def main():
|
||||||
profile = extract_profile(parser, options, toolchain_name, fallback="debug")
|
profile = extract_profile(parser, options, toolchain_name, fallback="debug")
|
||||||
if options.clean:
|
if options.clean:
|
||||||
rmtree(BUILD_DIR)
|
rmtree(BUILD_DIR)
|
||||||
export(options.mcu, options.ide, build=options.build,
|
mcu = extract_mcus(parser, options)[0]
|
||||||
|
export(mcu, options.ide, build=options.build,
|
||||||
src=options.source_dir, macros=options.macros,
|
src=options.source_dir, macros=options.macros,
|
||||||
project_id=options.program, zip_proj=zip_proj,
|
project_id=options.program, zip_proj=zip_proj,
|
||||||
build_profile=profile, app_config=options.app_config)
|
build_profile=profile, app_config=options.app_config)
|
||||||
|
|
|
@ -148,14 +148,14 @@ class Target(namedtuple("Target", "name json_data resolution_order resolution_or
|
||||||
"""Load the description of JSON target data"""
|
"""Load the description of JSON target data"""
|
||||||
targets = json_file_to_dict(Target.__targets_json_location or
|
targets = json_file_to_dict(Target.__targets_json_location or
|
||||||
Target.__targets_json_location_default)
|
Target.__targets_json_location_default)
|
||||||
|
return targets
|
||||||
|
|
||||||
# If extra_targets.json exists in working directory load it over the top
|
@staticmethod
|
||||||
extra = os.path.join('.', 'extra_targets.json')
|
@cached
|
||||||
|
def add_extra_targets(extra):
|
||||||
if os.path.exists(extra):
|
if os.path.exists(extra):
|
||||||
Target._merge_dict(targets, json_file_to_dict(extra))
|
Target._merge_dict(targets, json_file_to_dict(extra))
|
||||||
|
|
||||||
return targets
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_targets_json_location(location=None):
|
def set_targets_json_location(location=None):
|
||||||
"""Set the location of the targets.json file"""
|
"""Set the location of the targets.json file"""
|
||||||
|
@ -561,6 +561,9 @@ def set_targets_json_location(location=None):
|
||||||
# re-initialization does not create new variables, it keeps the old ones
|
# re-initialization does not create new variables, it keeps the old ones
|
||||||
# instead. This ensures compatibility with code that does
|
# instead. This ensures compatibility with code that does
|
||||||
# "from tools.targets import TARGET_NAMES"
|
# "from tools.targets import TARGET_NAMES"
|
||||||
|
update_target_data()
|
||||||
|
|
||||||
|
def update_target_data():
|
||||||
TARGETS[:] = [Target.get_target(tgt) for tgt, obj
|
TARGETS[:] = [Target.get_target(tgt) for tgt, obj
|
||||||
in Target.get_json_target_data().items()
|
in Target.get_json_target_data().items()
|
||||||
if obj.get("public", True)]
|
if obj.get("public", True)]
|
||||||
|
|
|
@ -28,7 +28,7 @@ sys.path.insert(0, ROOT)
|
||||||
|
|
||||||
from tools.config import ConfigException
|
from tools.config import ConfigException
|
||||||
from tools.test_api import test_path_to_name, find_tests, print_tests, build_tests, test_spec_from_test_builds
|
from tools.test_api import test_path_to_name, find_tests, print_tests, build_tests, test_spec_from_test_builds
|
||||||
from tools.options import get_default_options_parser, extract_profile
|
from tools.options import get_default_options_parser, extract_profile, extract_mcus
|
||||||
from tools.build_api import build_project, build_library
|
from tools.build_api import build_project, build_library
|
||||||
from tools.build_api import print_build_memory_usage
|
from tools.build_api import print_build_memory_usage
|
||||||
from tools.build_api import merge_build_data
|
from tools.build_api import merge_build_data
|
||||||
|
@ -114,7 +114,7 @@ if __name__ == '__main__':
|
||||||
# Target
|
# Target
|
||||||
if options.mcu is None :
|
if options.mcu is None :
|
||||||
args_error(parser, "argument -m/--mcu is required")
|
args_error(parser, "argument -m/--mcu is required")
|
||||||
mcu = options.mcu[0]
|
mcu = extract_mcus(parser, options)[0]
|
||||||
|
|
||||||
# Toolchain
|
# Toolchain
|
||||||
if options.tool is None:
|
if options.tool is None:
|
||||||
|
|
Loading…
Reference in New Issue