Build metadata check added

pull/9888/head
Senthil Ramakrishnan 2019-02-19 22:57:24 -06:00
parent 7490b1c87f
commit 8624fdf0a7
3 changed files with 54 additions and 31 deletions

View File

@ -8250,7 +8250,7 @@
"detect_code": ["1703"],
"macros_add": ["GD32E10X"],
"release_versions": ["5"]
},
},
"TT_M4G9": {
"inherits": ["Target"],
"core": "Cortex-M4",
@ -8280,5 +8280,9 @@
"detect_code": ["8013"],
"release_versions": ["5"],
"bootloader_supported": true
},
"__build_tools_metadata__": {
"version": "1",
"public": false
}
}

View File

@ -122,21 +122,27 @@ def add_result_to_report(report, result):
report[target][toolchain][id_name].append(result_wrap)
def get_toolchain_name(target, toolchain_name):
if toolchain_name == "ARM" or toolchain_name == "ARMC6" :
if("ARM" in target.supported_toolchains or "ARMC6" in target.supported_toolchains):
return "ARMC6"
elif ("ARMC5" in target.supported_toolchains):
if toolchain_name == "ARM":
return "ARM" #note that returning ARM here means, use ARMC5 toolchain
if int(target.build_tools_metadata["version"]) > 0:
if toolchain_name == "ARM" or toolchain_name == "ARMC6" :
if("ARM" in target.supported_toolchains or "ARMC6" in target.supported_toolchains):
return "ARMC6"
elif ("ARMC5" in target.supported_toolchains):
if toolchain_name == "ARM":
return "ARM" #note that returning ARM here means, use ARMC5 toolchain
else:
return "ARMC6" #ARMC6 explicitly specified by user, try ARMC6 anyway although the target doesnt explicitly specify ARMC6, as ARMC6 is our default ARM toolchain
elif toolchain_name == "uARM":
if ("ARMC5" in target.supported_toolchains):
return "uARM" #use ARM_MICRO to use AC5+microlib
else:
return "ARMC6" #ARMC6 explicitly specified by user, try ARMC6 anyway although the target doesnt explicitly specify ARMC6, as ARMC6 is our default ARM toolchain
elif toolchain_name == "uARM":
if ("ARMC5" in target.supported_toolchains):
return "uARM" #use ARM_MICRO to use AC5+microlib
else:
target.default_toolchain = "uARM"
return "ARMC6" #use AC6+microlib
target.default_toolchain = "uARM"
return "ARMC6" #use AC6+microlib
else:
if toolchain_name == "ARM":
if CORE_ARCH[target.core] == 8:
return "ARMC6"
elif getattr(target, "default_toolchain", None) == "uARM":
return "uARM"
return toolchain_name
@ -295,17 +301,23 @@ def get_mbed_official_release(version):
return mbed_official_release
def target_supports_toolchain(target, toolchain_name):
if toolchain_name in target.supported_toolchains:
return True
if int(target.build_tools_metadata["version"]) > 0:
if toolchain_name in target.supported_toolchains:
return True
else:
if(toolchain_name == "ARM"):
#we cant find ARM, see if one ARMC5, ARMC6 or uARM listed
return any(tc in target.supported_toolchains for tc in ("ARMC5","ARMC6","uARM"))
if(toolchain_name == "ARMC6"):
#we did not find ARMC6, but check for ARM is listed
return any(tc in target.supported_toolchains for tc in ("ARM",))
return False
else:
if(toolchain_name == "ARM"):
#we cant find ARM, see if one ARMC5, ARMC6 or uARM listed
return any(tc in target.supported_toolchains for tc in ("ARMC5","ARMC6","uARM"))
if(toolchain_name == "ARMC6"):
#we did not find ARMC6, but check for ARM is listed
return any(tc in target.supported_toolchains for tc in ("ARM",))
return False
ARM_COMPILERS = ("ARM", "ARMC6", "uARM")
if toolchain_name in ARM_COMPILERS:
return any(tc in target.supported_toolchains for tc in ARM_COMPILERS)
else:
return toolchain_name in target.supported_toolchains
def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
macros=None, clean=False, jobs=1,
@ -336,7 +348,7 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
# If the configuration object was not yet created, create it now
config = config or Config(target, src_paths, app_config=app_config)
target = config.target
if not target_supports_toolchain(target, toolchain_name):
raise NotSupportedException(
"Target {} is not supported by toolchain {}".format(
@ -536,13 +548,13 @@ def build_project(src_paths, build_path, target, toolchain_name,
if clean and exists(build_path):
rmtree(build_path)
mkdir(build_path)
toolchain = prepare_toolchain(
src_paths, build_path, target, toolchain_name, macros=macros,
clean=clean, jobs=jobs, notify=notify, config=config,
app_config=app_config, build_profile=build_profile, ignore=ignore)
toolchain.version_check()
# The first path will give the name to the library
name = (name or toolchain.config.name or
basename(normpath(abspath(src_paths[0]))))

View File

@ -103,6 +103,7 @@ def cached(func):
# need to be computed differently than regular attributes
CUMULATIVE_ATTRIBUTES = ['extra_labels', 'macros', 'device_has', 'features', 'components']
default_build_tools_metadata = {u'version':0, u'public':False}
def get_resolution_order(json_data, target_name, order, level=0):
""" Return the order in which target descriptions are searched for
@ -125,6 +126,9 @@ def get_resolution_order(json_data, target_name, order, level=0):
def target(name, json_data):
"""Construct a target object"""
if name.startswith("_"):
raise Exception("Invalid target name '%s' specified, target name should not start with '_'" % name)
try:
resolution_order = get_resolution_order(json_data, name, [])
except KeyError as exc:
@ -132,11 +136,13 @@ def target(name, json_data):
"target {} has an incomplete target definition".format(name)
), exc)
resolution_order_names = [tgt for tgt, _ in resolution_order]
return Target(name=name,
json_data={key: value for key, value in json_data.items()
if key in resolution_order_names},
resolution_order=resolution_order,
resolution_order_names=resolution_order_names)
resolution_order_names=resolution_order_names,
build_tools_metadata=json_data.get("__build_tools_metadata__", default_build_tools_metadata))
def generate_py_target(new_targets, name):
"""Add one or more new target(s) represented as a Python dictionary
@ -151,11 +157,12 @@ def generate_py_target(new_targets, name):
total_data = {}
total_data.update(new_targets)
total_data.update(base_targets)
return target(name, total_data)
class Target(namedtuple("Target", "name json_data resolution_order resolution_order_names")):
class Target(namedtuple("Target", "name json_data resolution_order resolution_order_names build_tools_metadata")):
"""An object to represent a Target (MCU/Board)"""
# Default location of the 'targets.json' file
__targets_json_location_default = os.path.join(
os.path.dirname(os.path.abspath(__file__)), '..', '..', 'targets', 'targets.json')