Skip to content

Commit 3922146

Browse files
authored
Merge pull request #279 from ARMmbed/tools-unification
Unification of tools.
2 parents 3429d4e + 4559dba commit 3922146

35 files changed

+1248
-195
lines changed

tools/build.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
if options.usb_host:
193193
libraries.append("usb_host")
194194
if options.dsp:
195-
libraries.extend(["cmsis_dsp", "dsp"])
195+
libraries.extend(["dsp"])
196196
if options.fat:
197197
libraries.extend(["fat"])
198198
if options.ublox:
@@ -233,7 +233,8 @@
233233
tt_id = "%s::%s" % (toolchain, target)
234234
try:
235235
mcu = TARGET_MAP[target]
236-
lib_build_res = build_library(options.source_dir, options.build_dir, mcu, toolchain,
236+
if options.source_dir:
237+
lib_build_res = build_library(options.source_dir, options.build_dir, mcu, toolchain,
237238
options=options.options,
238239
extra_verbose=options.extra_verbose_notify,
239240
verbose=options.verbose,
@@ -242,6 +243,16 @@
242243
clean=options.clean,
243244
archive=(not options.no_archive),
244245
macros=options.macros)
246+
else:
247+
lib_build_res = build_mbed_libs(mcu, toolchain,
248+
options=options.options,
249+
extra_verbose=options.extra_verbose_notify,
250+
verbose=options.verbose,
251+
silent=options.silent,
252+
jobs=options.jobs,
253+
clean=options.clean,
254+
macros=options.macros)
255+
245256
for lib_id in libraries:
246257
build_lib(lib_id, mcu, toolchain,
247258
options=options.options,

tools/build_api.py

Lines changed: 134 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -390,33 +390,145 @@ def build_library(src_paths, build_path, target, toolchain_name,
390390
# Let Exception propagate
391391
raise e
392392

393-
def build_lib(lib_id, target, toolchain, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None, extra_verbose=False):
394-
""" Wrapper for build_library function.
393+
######################
394+
### Legacy methods ###
395+
######################
396+
397+
def build_lib(lib_id, target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None, extra_verbose=False):
398+
""" Legacy method for building mbed libraries
395399
Function builds library in proper directory using all dependencies and macros defined by user.
396400
"""
397401
lib = Library(lib_id)
398-
if lib.is_supported(target, toolchain):
399-
# We need to combine macros from parameter list with macros from library definition
400-
MACROS = lib.macros if lib.macros else []
401-
if macros:
402-
MACROS.extend(macros)
403-
404-
return build_library(lib.source_dir, lib.build_dir, target, toolchain, lib.dependencies, options,
405-
verbose=verbose,
406-
silent=silent,
407-
clean=clean,
408-
macros=MACROS,
409-
notify=notify,
410-
inc_dirs=lib.inc_dirs,
411-
inc_dirs_ext=lib.inc_dirs_ext,
412-
jobs=jobs,
413-
report=report,
414-
properties=properties,
415-
extra_verbose=extra_verbose)
416-
else:
402+
if not lib.is_supported(target, toolchain_name):
417403
print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id, target.name, toolchain)
418404
return False
405+
406+
# We need to combine macros from parameter list with macros from library definition
407+
MACROS = lib.macros if lib.macros else []
408+
if macros:
409+
macros.extend(MACROS)
410+
else:
411+
macros = MACROS
412+
413+
src_paths = lib.source_dir
414+
build_path = lib.build_dir
415+
dependencies_paths = lib.dependencies
416+
inc_dirs = lib.inc_dirs
417+
inc_dirs_ext = lib.inc_dirs_ext
418+
419+
""" src_path: the path of the source directory
420+
build_path: the path of the build directory
421+
target: ['LPC1768', 'LPC11U24', 'LPC2368']
422+
toolchain: ['ARM', 'uARM', 'GCC_ARM', 'GCC_CR']
423+
library_paths: List of paths to additional libraries
424+
clean: Rebuild everything if True
425+
notify: Notify function for logs
426+
verbose: Write the actual tools command lines if True
427+
inc_dirs: additional include directories which should be included in build
428+
inc_dirs_ext: additional include directories which should be copied to library directory
429+
"""
430+
if type(src_paths) != ListType:
431+
src_paths = [src_paths]
432+
433+
# The first path will give the name to the library
434+
name = basename(src_paths[0])
435+
436+
if report != None:
437+
start = time()
438+
id_name = name.upper()
439+
description = name
440+
vendor_label = target.extra_labels[0]
441+
cur_result = None
442+
prep_report(report, target.name, toolchain_name, id_name)
443+
cur_result = create_result(target.name, toolchain_name, id_name, description)
444+
445+
if properties != None:
446+
prep_properties(properties, target.name, toolchain_name, vendor_label)
447+
448+
for src_path in src_paths:
449+
if not exists(src_path):
450+
error_msg = "The library source folder does not exist: %s", src_path
451+
452+
if report != None:
453+
cur_result["output"] = error_msg
454+
cur_result["result"] = "FAIL"
455+
add_result_to_report(report, cur_result)
456+
457+
raise Exception(error_msg)
458+
459+
try:
460+
# Toolchain instance
461+
toolchain = TOOLCHAIN_CLASSES[toolchain_name](target, options, macros=macros, notify=notify, silent=silent, extra_verbose=extra_verbose)
462+
toolchain.VERBOSE = verbose
463+
toolchain.jobs = jobs
464+
toolchain.build_all = clean
419465

466+
toolchain.info("Building library %s (%s, %s)" % (name.upper(), target.name, toolchain_name))
467+
468+
# Scan Resources
469+
resources = []
470+
for src_path in src_paths:
471+
resources.append(toolchain.scan_resources(src_path))
472+
473+
# Add extra include directories / files which are required by library
474+
# This files usually are not in the same directory as source files so
475+
# previous scan will not include them
476+
if inc_dirs_ext is not None:
477+
for inc_ext in inc_dirs_ext:
478+
resources.append(toolchain.scan_resources(inc_ext))
479+
480+
# Dependencies Include Paths
481+
dependencies_include_dir = []
482+
if dependencies_paths is not None:
483+
for path in dependencies_paths:
484+
lib_resources = toolchain.scan_resources(path)
485+
dependencies_include_dir.extend(lib_resources.inc_dirs)
486+
487+
if inc_dirs:
488+
dependencies_include_dir.extend(inc_dirs)
489+
490+
# Create the desired build directory structure
491+
bin_path = join(build_path, toolchain.obj_path)
492+
mkdir(bin_path)
493+
tmp_path = join(build_path, '.temp', toolchain.obj_path)
494+
mkdir(tmp_path)
495+
496+
# Copy Headers
497+
for resource in resources:
498+
toolchain.copy_files(resource.headers, build_path, rel_path=resource.base_path)
499+
dependencies_include_dir.extend(toolchain.scan_resources(build_path).inc_dirs)
500+
501+
# Compile Sources
502+
objects = []
503+
for resource in resources:
504+
objects.extend(toolchain.compile_sources(resource, tmp_path, dependencies_include_dir))
505+
506+
needed_update = toolchain.build_library(objects, bin_path, name)
507+
508+
if report != None and needed_update:
509+
end = time()
510+
cur_result["elapsed_time"] = end - start
511+
cur_result["output"] = toolchain.get_output()
512+
cur_result["result"] = "OK"
513+
514+
add_result_to_report(report, cur_result)
515+
516+
except Exception, e:
517+
if report != None:
518+
end = time()
519+
cur_result["result"] = "FAIL"
520+
cur_result["elapsed_time"] = end - start
521+
522+
toolchain_output = toolchain.get_output()
523+
if toolchain_output:
524+
cur_result["output"] += toolchain_output
525+
526+
cur_result["output"] += str(e)
527+
528+
add_result_to_report(report, cur_result)
529+
530+
# Let Exception propagate
531+
raise e
420532

421533
# We do have unique legacy conventions about how we build and package the mbed library
422534
def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=False, macros=None, notify=None, jobs=1, silent=False, report=None, properties=None, extra_verbose=False):
@@ -539,6 +651,7 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
539651
# Let Exception propagate
540652
raise e
541653

654+
542655
def get_unique_supported_toolchains():
543656
""" Get list of all unique toolchains supported by targets """
544657
unique_supported_toolchains = []

tools/build_release.py

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
from tools.build_api import build_mbed_libs
2929
from tools.build_api import write_build_report
30-
from tools.targets import TARGET_MAP
30+
from tools.targets import TARGET_MAP, TARGET_NAMES
3131
from tools.test_exporters import ReportExporter, ResultExporterType
3232
from tools.test_api import SingleTestRunner
3333
from tools.test_api import singletest_in_cli_mode
@@ -59,6 +59,7 @@
5959

6060
('KL05Z', ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
6161
('KL25Z', ('ARM', 'GCC_ARM', 'IAR')),
62+
('KL27Z', ('ARM', 'GCC_ARM', 'IAR')),
6263
('KL43Z', ('ARM', 'GCC_ARM')),
6364
('KL46Z', ('ARM', 'GCC_ARM', 'IAR')),
6465
('K64F', ('ARM', 'GCC_ARM', 'IAR')),
@@ -96,6 +97,7 @@
9697
('DISCO_L476VG', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
9798
('NUCLEO_L476RG', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
9899
('NUCLEO_F746ZG', ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
100+
('NUCLEO_L031K6', ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
99101
('NUCLEO_L073RZ', ('ARM', 'uARM', 'GCC_ARM', 'IAR')),
100102

101103
('MOTE_L152RC', ('ARM', 'uARM', 'IAR', 'GCC_ARM')),
@@ -112,7 +114,7 @@
112114
('RBLAB_BLENANO', ('ARM', 'GCC_ARM')),
113115
('WALLBOT_BLE', ('ARM', 'GCC_ARM')),
114116
('DELTA_DFCM_NNN40', ('ARM', 'GCC_ARM')),
115-
('NRF51_MICROBIT', ('ARM',)),
117+
('NRF51_MICROBIT', ('ARM','GCC_ARM')),
116118
('NRF51_MICROBIT_B', ('ARM',)),
117119
('TY51822R3', ('ARM', 'GCC_ARM')),
118120

@@ -124,15 +126,16 @@
124126
('ARM_MPS2_M3' , ('ARM',)),
125127
('ARM_MPS2_M4' , ('ARM',)),
126128
('ARM_MPS2_M7' , ('ARM',)),
127-
('ARM_MPS2_BEID' , ('ARM',)),
129+
('ARM_IOTSS_BEID' , ('ARM',)),
128130

129-
('RZ_A1H' , ('ARM', 'GCC_ARM', 'IAR')),
131+
('RZ_A1H' , ('ARM', 'GCC_ARM')),
130132

131133
('EFM32ZG_STK3200', ('GCC_ARM', 'uARM')),
132134
('EFM32HG_STK3400', ('GCC_ARM', 'uARM')),
133135
('EFM32LG_STK3600', ('ARM', 'GCC_ARM', 'uARM')),
134136
('EFM32GG_STK3700', ('ARM', 'GCC_ARM', 'uARM')),
135137
('EFM32WG_STK3800', ('ARM', 'GCC_ARM', 'uARM')),
138+
('EFM32PG_STK3401', ('ARM', 'GCC_ARM', 'uARM')),
136139

137140
('MAXWSNENV', ('ARM', 'GCC_ARM', 'IAR')),
138141
('MAX32600MBED', ('ARM', 'GCC_ARM', 'IAR')),
@@ -206,19 +209,25 @@
206209
"targets": {}
207210
}
208211

212+
if options.toolchains:
213+
print "Only building using the following toolchains: %s" % (options.toolchains)
214+
209215
for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD:
210216
toolchains = None
211217
if platforms is not None and not target_name in platforms:
212218
print("Excluding %s from release" % target_name)
213219
continue
220+
221+
if target_name not in TARGET_NAMES:
222+
print "Target '%s' is not a valid target. Excluding from release"
223+
continue
214224

215225
if options.official_only:
216226
toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),)
217227
else:
218228
toolchains = toolchain_list
219229

220230
if options.toolchains:
221-
print "Only building using the following toolchains: %s" % (options.toolchains)
222231
toolchainSet = set(toolchains)
223232
toolchains = toolchainSet.intersection(set((options.toolchains).split(',')))
224233

@@ -230,24 +239,28 @@
230239

231240
test_spec["targets"][target_name] = toolchains
232241

233-
single_test = SingleTestRunner(_muts=mut,
234-
_opts_report_build_file_name=options.report_build_file_name,
235-
_test_spec=test_spec,
236-
_opts_test_by_names=",".join(test_names),
237-
_opts_verbose=options.verbose,
238-
_opts_only_build_tests=True,
239-
_opts_suppress_summary=True,
240-
_opts_jobs=options.jobs,
241-
_opts_include_non_automated=True,
242-
_opts_build_report=build_report,
243-
_opts_build_properties=build_properties)
244-
# Runs test suite in CLI mode
245-
test_summary, shuffle_seed, test_summary_ext, test_suite_properties_ext, new_build_report, new_build_properties = single_test.execute()
242+
single_test = SingleTestRunner(_muts=mut,
243+
_opts_report_build_file_name=options.report_build_file_name,
244+
_test_spec=test_spec,
245+
_opts_test_by_names=",".join(test_names),
246+
_opts_verbose=options.verbose,
247+
_opts_only_build_tests=True,
248+
_opts_suppress_summary=True,
249+
_opts_jobs=options.jobs,
250+
_opts_include_non_automated=True,
251+
_opts_build_report=build_report,
252+
_opts_build_properties=build_properties)
253+
# Runs test suite in CLI mode
254+
test_summary, shuffle_seed, test_summary_ext, test_suite_properties_ext, new_build_report, new_build_properties = single_test.execute()
246255
else:
247256
for target_name, toolchain_list in OFFICIAL_MBED_LIBRARY_BUILD:
248257
if platforms is not None and not target_name in platforms:
249258
print("Excluding %s from release" % target_name)
250259
continue
260+
261+
if target_name not in TARGET_NAMES:
262+
print "Target '%s' is not a valid target. Excluding from release"
263+
continue
251264

252265
if options.official_only:
253266
toolchains = (getattr(TARGET_MAP[target_name], 'default_toolchain', 'ARM'),)

tools/build_travis.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
{ "target": "NUCLEO_F410RB", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
5454
{ "target": "NUCLEO_F411RE", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
5555
{ "target": "NUCLEO_L476RG", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
56+
{ "target": "NUCLEO_L031K6", "toolchains": "GCC_ARM", "libs": ["dsp"] },
5657
{ "target": "NUCLEO_L073RZ", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
5758
{ "target": "NUCLEO_F446RE", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
5859

@@ -82,6 +83,7 @@
8283

8384
{ "target": "KL05Z", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
8485
{ "target": "KL25Z", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] },
86+
{ "target": "KL27Z", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] },
8587
{ "target": "KL43Z", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] },
8688
{ "target": "KL46Z", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] },
8789
{ "target": "K20D50M", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
@@ -90,17 +92,17 @@
9092
{ "target": "LPC4088", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb", "fat"] },
9193
{ "target": "ARCH_PRO", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
9294
{ "target": "LPC1549", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
93-
{ "target": "NRF51822", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
95+
{ "target": "NRF51822", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
9496
{ "target": "DELTA_DFCM_NNN40", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
95-
{ "target": "NRF51_DK", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
96-
{ "target": "NRF51_MICROBIT", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
97+
{ "target": "NRF51_DK", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
98+
{ "target": "NRF51_MICROBIT", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "fat"] },
9799

98100
{ "target": "EFM32ZG_STK3200", "toolchains": "GCC_ARM", "libs": ["dsp"] },
99-
{ "target": "EFM32HG_STK3400", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] },
100-
{ "target": "EFM32LG_STK3600", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] },
101-
{ "target": "EFM32GG_STK3700", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] },
102-
{ "target": "EFM32WG_STK3800", "toolchains": "GCC_ARM", "libs": ["dsp", "usb"] },
103-
{ "target": "EFM32PG_STK3401", "toolchains": "GCC_ARM", "libs": ["dsp"] },
101+
{ "target": "EFM32HG_STK3400", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb"] },
102+
{ "target": "EFM32LG_STK3600", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb"] },
103+
{ "target": "EFM32GG_STK3700", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb"] },
104+
{ "target": "EFM32WG_STK3800", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos", "usb"] },
105+
{ "target": "EFM32PG_STK3401", "toolchains": "GCC_ARM", "libs": ["dsp", "rtos"] },
104106

105107
{ "target": "MAXWSNENV", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },
106108
{ "target": "MAX32600MBED", "toolchains": "GCC_ARM", "libs": ["dsp", "fat"] },

tools/export/.hgignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
syntax: regexp
2+
\.hgignore$
3+
\.git$
4+
\.svn$
5+
\.orig$
6+
\.msub$
7+
\.meta$
8+
\.ctags
9+
\.uvproj$
10+
\.uvopt$
11+
\.project$
12+
\.cproject$
13+
\.launch$
14+
\.project$
15+
\.cproject$
16+
\.launch$
17+
Makefile$
18+
\.ewp$
19+
\.eww$
20+
\.htm$
21+
Debug$
22+
.settings$

0 commit comments

Comments
 (0)