Skip to content

Commit 2886f0b

Browse files
Merge pull request #4387 from theotherjimmy/override-target-attrs
Allow target attribute overrides in app config and pick toolchain with default_toolchain
2 parents fa82a78 + 9277c6e commit 2886f0b

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

tools/build_api.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
331331
extra_verbose - even more output!
332332
config - a Config object to use instead of creating one
333333
app_config - location of a chosen mbed_app.json file
334-
build_profile - a dict of flags that will be passed to the compiler
334+
build_profile - a list of mergeable build profiles
335335
"""
336336

337337
# We need to remove all paths which are repeated to avoid
@@ -345,12 +345,17 @@ def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
345345
cur_tc = TOOLCHAIN_CLASSES[toolchain_name]
346346
except KeyError:
347347
raise KeyError("Toolchain %s not supported" % toolchain_name)
348+
349+
profile = {'c': [], 'cxx': [], 'common': [], 'asm': [], 'ld': []}
350+
for contents in build_profile or []:
351+
for key in profile:
352+
profile[key].extend(contents[toolchain_name][key])
353+
348354
if config.has_regions:
349-
add_regions_to_profile(build_profile, config, cur_tc)
355+
add_regions_to_profile(profile, config, cur_tc)
350356

351-
# Toolchain instance
352357
toolchain = cur_tc(target, notify, macros, silent, build_dir=build_dir,
353-
extra_verbose=extra_verbose, build_profile=build_profile)
358+
extra_verbose=extra_verbose, build_profile=profile)
354359

355360
toolchain.config = config
356361
toolchain.jobs = jobs

tools/config/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
644644
label)
645645
elif name in self.__unused_overrides:
646646
pass
647+
elif (name.startswith("target.") and
648+
unit_kind is "application"):
649+
_, attribute = name.split(".")
650+
setattr(self.target, attribute, val)
647651
else:
648652
self.config_errors.append(
649653
ConfigException(

tools/options.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,25 @@ def extract_profile(parser, options, toolchain, fallback="develop"):
108108
options - The parsed command line arguments
109109
toolchain - the toolchain that the profile should be extracted for
110110
"""
111-
profile = {'c': [], 'cxx': [], 'ld': [], 'common': [], 'asm': []}
111+
profiles = []
112112
filenames = options.profile or [join(dirname(__file__), "profiles",
113113
fallback + ".json")]
114114
for filename in filenames:
115115
contents = load(open(filename))
116-
try:
117-
for key in profile.iterkeys():
118-
profile[key] += contents[toolchain][key]
119-
except KeyError:
116+
if toolchain not in contents:
120117
args_error(parser, ("argument --profile: toolchain {} is not"
121118
" supported by profile {}").format(toolchain,
122119
filename))
123-
return profile
120+
profiles.append(contents)
121+
122+
return profiles
123+
124+
def mcu_is_enabled(parser, mcu):
125+
if "Cortex-A" in TARGET_MAP[mcu].core:
126+
args_error(
127+
parser,
128+
("%s Will be supported in mbed OS 5.6. "
129+
"To use the %s, please checkout the mbed OS 5.4 release branch. "
130+
"See https://developer.mbed.org/platforms/Renesas-GR-PEACH/#important-notice "
131+
"for more information") % (mcu, mcu))
132+
return True

0 commit comments

Comments
 (0)