Skip to content

Commit ff2d8df

Browse files
authored
Merge pull request #2877 from bridadan/build-profiles-release-singletest
Adding build profiles to build_release.py and singletest.py
2 parents 7252dae + 64d09e1 commit ff2d8df

File tree

7 files changed

+61
-37
lines changed

7 files changed

+61
-37
lines changed

tools/build_release.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from tools.build_api import build_mbed_libs
3030
from tools.build_api import write_build_report
3131
from tools.build_api import get_mbed_official_release
32+
from tools.options import extract_profile
3233
from tools.targets import TARGET_MAP, TARGET_NAMES
3334
from tools.test_exporters import ReportExporter, ResultExporterType
3435
from tools.test_api import SingleTestRunner
@@ -48,6 +49,8 @@
4849
default=False, help="Verbose diagnostic output")
4950
parser.add_option("-t", "--toolchains", dest="toolchains", help="Use toolchains names separated by comma")
5051

52+
parser.add_option("--profile", dest="profile", action="append", default=[])
53+
5154
parser.add_option("-p", "--platforms", dest="platforms", default="", help="Build only for the platform namesseparated by comma")
5255

5356
parser.add_option("-L", "--list-config", action="store_true", dest="list_config",
@@ -127,6 +130,8 @@
127130
test_spec["targets"][target_name] = toolchains
128131

129132
single_test = SingleTestRunner(_muts=mut,
133+
_parser=parser,
134+
_opts=options,
130135
_opts_report_build_file_name=options.report_build_file_name,
131136
_test_spec=test_spec,
132137
_opts_test_by_names=",".join(test_names),
@@ -162,8 +167,16 @@
162167
for toolchain in toolchains:
163168
id = "%s::%s" % (target_name, toolchain)
164169

170+
profile = extract_profile(parser, options, toolchain)
171+
165172
try:
166-
built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name], toolchain, verbose=options.verbose, jobs=options.jobs, report=build_report, properties=build_properties)
173+
built_mbed_lib = build_mbed_libs(TARGET_MAP[target_name],
174+
toolchain,
175+
verbose=options.verbose,
176+
jobs=options.jobs,
177+
report=build_report,
178+
properties=build_properties,
179+
build_profile=profile)
167180

168181
except Exception, e:
169182
print str(e)

tools/profiles/debug.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
2323
"ld": []
2424
},
25+
"uARM": {
26+
"common": ["-c", "--gnu", "-Otime", "--split_sections",
27+
"--apcs=interwork", "--brief_diagnostics", "--restrict",
28+
"--multibyte_chars", "-O0", "-D__MICROLIB", "-g"
29+
"--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD"],
30+
"asm": [],
31+
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
32+
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
33+
"ld": ["--library_type=microlib"]
34+
},
2535
"IAR": {
2636
"common": [
2737
"--no_wrap_diagnostics", "non-native end of line sequence", "-e",

tools/profiles/default.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
2323
"ld": []
2424
},
25+
"uARM": {
26+
"common": ["-c", "--gnu", "-Otime", "--split_sections",
27+
"--apcs=interwork", "--brief_diagnostics", "--restrict",
28+
"--multibyte_chars", "-O3", "-D__MICROLIB",
29+
"--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD"],
30+
"asm": [],
31+
"c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
32+
"cxx": ["--cpp", "--no_rtti", "--no_vla"],
33+
"ld": ["--library_type=microlib"]
34+
},
2535
"IAR": {
2636
"common": [
2737
"--no_wrap_diagnostics", "-e",

tools/profiles/save-asm.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@
1212
"c": [],
1313
"cxx": [],
1414
"ld": []
15+
},
16+
"uARM": {
17+
"common": ["--asm", "--interleave"],
18+
"asm": [],
19+
"c": [],
20+
"cxx": [],
21+
"ld": []
1522
}
1623
}

tools/singletest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ def get_version():
225225
_test_loops_list=opts.test_loops_list,
226226
_muts=MUTs,
227227
_clean=opts.clean,
228+
_parser=parser,
229+
_opts=opts,
228230
_opts_db_url=opts.db_url,
229231
_opts_log_file_name=opts.log_file_name,
230232
_opts_report_html_file_name=opts.report_html_file_name,

tools/test_api.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
from tools.build_api import prepare_toolchain
6161
from tools.build_api import scan_resources
6262
from tools.libraries import LIBRARIES, LIBRARY_MAP
63+
from tools.options import extract_profile
6364
from tools.toolchains import TOOLCHAIN_PATHS
6465
from tools.toolchains import TOOLCHAINS
6566
from tools.test_exporters import ReportExporter, ResultExporterType
@@ -170,6 +171,8 @@ def __init__(self,
170171
_test_loops_list=None,
171172
_muts={},
172173
_clean=False,
174+
_parser=None,
175+
_opts=None,
173176
_opts_db_url=None,
174177
_opts_log_file_name=None,
175178
_opts_report_html_file_name=None,
@@ -258,6 +261,8 @@ def __init__(self,
258261
self.opts_consolidate_waterfall_test = _opts_consolidate_waterfall_test
259262
self.opts_extend_test_timeout = _opts_extend_test_timeout
260263
self.opts_clean = _clean
264+
self.opts_parser = _parser
265+
self.opts = _opts
261266
self.opts_auto_detect = _opts_auto_detect
262267
self.opts_include_non_automated = _opts_include_non_automated
263268

@@ -357,6 +362,8 @@ def execute_thread_slice(self, q, target, toolchains, clean, test_ids, build_rep
357362

358363
clean_mbed_libs_options = True if self.opts_goanna_for_mbed_sdk or clean or self.opts_clean else None
359364

365+
profile = extract_profile(self.opts_parser, self.opts, toolchain)
366+
360367

361368
try:
362369
build_mbed_libs_result = build_mbed_libs(T,
@@ -365,7 +372,8 @@ def execute_thread_slice(self, q, target, toolchains, clean, test_ids, build_rep
365372
verbose=self.opts_verbose,
366373
jobs=self.opts_jobs,
367374
report=build_report,
368-
properties=build_properties)
375+
properties=build_properties,
376+
build_profile=profile)
369377

370378
if not build_mbed_libs_result:
371379
print self.logger.log_line(self.logger.LogType.NOTIF, 'Skipped tests for %s target. Toolchain %s is not yet supported for this target'% (T.name, toolchain))
@@ -433,7 +441,8 @@ def execute_thread_slice(self, q, target, toolchains, clean, test_ids, build_rep
433441
clean=clean_mbed_libs_options,
434442
jobs=self.opts_jobs,
435443
report=build_report,
436-
properties=build_properties)
444+
properties=build_properties,
445+
build_profile=profile)
437446

438447
except ToolException:
439448
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building library %s'% (lib_id))
@@ -484,7 +493,8 @@ def execute_thread_slice(self, q, target, toolchains, clean, test_ids, build_rep
484493
report=build_report,
485494
properties=build_properties,
486495
project_id=test_id,
487-
project_description=test.get_description())
496+
project_description=test.get_description(),
497+
build_profile=profile)
488498

489499
except Exception, e:
490500
project_name_str = project_name if project_name is not None else test_id
@@ -1784,6 +1794,10 @@ def get_default_test_options_parser():
17841794
action="store_true",
17851795
help='Test only peripheral declared for MUT and skip common tests')
17861796

1797+
parser.add_argument("--profile", dest="profile", action="append",
1798+
type=argparse_filestring_type,
1799+
default=[])
1800+
17871801
parser.add_argument('-C', '--only-commons',
17881802
dest='test_only_common',
17891803
default=False,

tools/toolchains/arm.py

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -240,37 +240,5 @@ def __init__(self, target, notify=None, macros=None,
240240
ARM.__init__(self, target, notify, macros, silent,
241241
extra_verbose=extra_verbose, build_profile=build_profile)
242242

243-
# Extend flags
244-
self.flags['common'].extend(["-D__MICROLIB"])
245-
self.flags['c'].extend(["--library_type=microlib"])
246-
self.flags['ld'].extend(["--library_type=microlib"])
247-
248243
# Run-time values
249-
self.asm += ["-D__MICROLIB"]
250-
self.cc += ["-D__MICROLIB", "--library_type=microlib"]
251-
self.cppc += ["-D__MICROLIB", "--library_type=microlib"]
252-
self.ld += ["--library_type=microlib"]
253-
254-
# Only allow a single thread
255-
self.cc += ["-DMBED_RTOS_SINGLE_THREAD"]
256-
self.cppc += ["-DMBED_RTOS_SINGLE_THREAD"]
257-
258-
# We had to patch microlib to add C++ support
259-
# In later releases this patch should have entered mainline
260-
if ARM_MICRO.PATCHED_LIBRARY:
261-
# Run-time values
262-
self.flags['ld'].extend(["--noscanlib"])
263-
# Run-time values
264-
self.ld += ["--noscanlib"]
265-
266-
# System Libraries
267-
self.sys_libs.extend([join(TOOLCHAIN_PATHS['ARM'], "lib", "microlib", lib+".l") for lib in ["mc_p", "mf_p", "m_ps"]])
268-
269-
if target.core == "Cortex-M3":
270-
self.sys_libs.extend([join(TOOLCHAIN_PATHS['ARM'], "lib", "cpplib", lib+".l") for lib in ["cpp_ws", "cpprt_w"]])
271-
272-
elif target.core in ["Cortex-M0", "Cortex-M0+"]:
273-
self.sys_libs.extend([join(TOOLCHAIN_PATHS['ARM'], "lib", "cpplib", lib+".l") for lib in ["cpp_ps", "cpprt_p"]])
274-
else:
275-
# Run-time values
276-
self.ld.extend(["--libpath", join(TOOLCHAIN_PATHS['ARM'], "lib")])
244+
self.ld.extend(["--libpath", join(TOOLCHAIN_PATHS['ARM'], "lib")])

0 commit comments

Comments
 (0)