Skip to content

Commit dafcf7f

Browse files
committed
Add support for legacy build conventions
Improve exporter test Build the hal implementation and common sources separately to have proper temporary relative paths
1 parent 27808da commit dafcf7f

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

workspace_tools/build_api.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,20 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False):
136136

137137
# mbed
138138
toolchain.info("\n>>> BUILD LIBRARY %s (%s, %s)" % ('MBED', target.name, toolchain_name))
139-
HAL_SRC = join(MBED_TARGETS_PATH, "hal")
140-
hal_implementation = toolchain.scan_resources(HAL_SRC)
141-
142-
mbed_resources = toolchain.scan_resources(MBED_COMMON)
143-
mbed_resources.add(hal_implementation)
144139

145-
# Headers
140+
# Common Headers
146141
toolchain.copy_files(toolchain.scan_resources(MBED_API).headers, MBED_LIBRARIES)
147142
toolchain.copy_files(toolchain.scan_resources(MBED_HAL).headers, MBED_LIBRARIES)
143+
144+
# Target specific sources
145+
HAL_SRC = join(MBED_TARGETS_PATH, "hal")
146+
hal_implementation = toolchain.scan_resources(HAL_SRC)
148147
toolchain.copy_files(hal_implementation.headers, BUILD_TARGET)
148+
objects = toolchain.compile_sources(hal_implementation, TMP_PATH, [MBED_LIBRARIES, BUILD_TARGET])
149149

150-
objects = toolchain.compile_sources(mbed_resources, TMP_PATH, [MBED_LIBRARIES, BUILD_TARGET])
150+
# Common Sources
151+
mbed_resources = toolchain.scan_resources(MBED_COMMON)
152+
objects += toolchain.compile_sources(mbed_resources, TMP_PATH, [MBED_LIBRARIES, BUILD_TARGET])
151153

152154
# Keep the stdio retargeting as a standalone object to be sure the
153155
# C standard library symbols get overridden

workspace_tools/export_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@
99

1010
from shutil import copytree
1111

12+
EXPORT_DIR = join(BUILD_DIR, "export_test")
13+
USER_WORKSPACE = join(EXPORT_DIR, "user_workspace")
1214

13-
USR_PRJ_NAME = "export_test"
14-
USER_PRJ = join(BUILD_DIR, USR_PRJ_NAME)
15+
USR_PRJ_NAME = "usr_prj"
16+
USER_PRJ = join(USER_WORKSPACE, USR_PRJ_NAME)
1517
USER_LIB = join(USER_PRJ, "lib")
1618
USER_SRC = join(USER_PRJ, "src")
17-
TEMP = join(USER_PRJ, ".temp")
19+
20+
TEMP = join(USER_WORKSPACE, ".temp")
21+
1822

1923
def setup_test_user_prj():
2024
if exists(USER_PRJ):
@@ -50,7 +54,7 @@ def test_export(toolchain, target, expected_error=None):
5054
zip_path, report = export(USER_PRJ, USR_PRJ_NAME, toolchain, target, base_dir, temp_dir, False, fake_build_url_resolver)
5155

5256
if report['success']:
53-
export_name = join(TEMP, "export_%s_%s.zip" % (toolchain, target))
57+
export_name = join(EXPORT_DIR, "export_%s_%s.zip" % (toolchain, target))
5458
cmd(["mv", zip_path, export_name])
5559
print "[OK]"
5660
else:
@@ -66,9 +70,6 @@ def test_export(toolchain, target, expected_error=None):
6670

6771

6872
if __name__ == '__main__':
69-
# import logging as log
70-
# log.getLogger().setLevel(log.DEBUG)
71-
7273
setup_test_user_prj()
7374

7475
for toolchain, target in [

workspace_tools/toolchains/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,20 @@ def __str__(self):
101101
return '\n'.join(s)
102102

103103

104+
# Support legacy build conventions: the original mbed build system did not have
105+
# standard labels for the "TARGET_" and "TOOLCHAIN_" specific directories, but
106+
# had the knowledge of a list of these directories to be ignored.
107+
LEGACY_IGNORE_DIRS = set([
108+
'LPC11U24', 'LPC1768', 'LPC2368', 'LPC4088', 'LPC812', 'KL25Z',
109+
'ARM', 'GCC_ARM', 'GCC_CR', 'GCC_CS', 'IAR', 'uARM'
110+
])
111+
LEGACY_TOOLCHAIN_NAMES = {
112+
'ARM_STD':'ARM', 'ARM_MICRO': 'uARM',
113+
'GCC_ARM': 'GCC_ARM', 'GCC_CR': 'GCC_CR', 'GCC_CS': 'GCC_CS',
114+
'IAR': 'IAR',
115+
}
116+
117+
104118
class mbedToolchain:
105119
VERBOSE = True
106120

@@ -113,6 +127,9 @@ class mbedToolchain:
113127

114128
def __init__(self, target, options=None, notify=None):
115129
self.target = target
130+
self.name = self.__class__.__name__
131+
132+
self.legacy_ignore_dirs = LEGACY_IGNORE_DIRS - set([target.name, LEGACY_TOOLCHAIN_NAMES[self.name]])
116133

117134
if notify is not None:
118135
self.notify = notify
@@ -127,7 +144,6 @@ def __init__(self, target, options=None, notify=None):
127144
if self.options:
128145
self.info("Build Options: %s" % (', '.join(self.options)))
129146

130-
self.name = self.__class__.__name__
131147
self.obj_path = join(target.name, self.name)
132148

133149
self.symbols = None
@@ -195,7 +211,7 @@ def scan_resources(self, path):
195211
for root, dirs, files in walk(path):
196212
# Remove ignored directories
197213
for d in copy(dirs):
198-
if ((d.startswith('.') or d in set(['CVS'])) or
214+
if ((d.startswith('.') or d in self.legacy_ignore_dirs) or
199215
(d.startswith('TARGET_') and d[7:] not in labels['TARGET']) or
200216
(d.startswith('TOOLCHAIN_') and d[10:] not in labels['TOOLCHAIN'])):
201217
dirs.remove(d)

0 commit comments

Comments
 (0)