Skip to content

Commit a36c8d1

Browse files
committed
Patches related mbed online build system support:
* added/improved global chroot support * added RESPONSE_FILES flag to support optional response files (on linux the cmd param length is 2 megabytes). Default True * added unified handling for archive and link response file (similar to includes) * added COMPILE_C_AS_CPP flag to support compiling of c files as cpp. Default False * added mbedToolchain.init() for post __init__ hooks * added caching to mbedToolchain.need_update() to reduce IO hits * added support to identify compiler warning/error column (supports ARMCC, GCC and IAR). Errors/warnings now report file@line,col * added global TOOLCHAIN_PATHS which allows overriding/changing of the toolchain paths. Also simplified ARM-related paths * added target.json to mbed library release (by @0xc0170)* migrated compile_worker() to utils.py for lightweight thread initialization * improved run_cmd() performance by removing unnecessary check about the command being executed (should be checked once in the relevant toolchain instead) * removed remnants of Goanna support (should be reimplemented as hooks to compile/link/archive instead) * fixes for Python 2.7 compatibility (by @0xc0170) * fixes for Exporters (by @0xc0170)
1 parent 4e1ac4d commit a36c8d1

18 files changed

+385
-392
lines changed

hal/targets.json

Lines changed: 42 additions & 84 deletions
Large diffs are not rendered by default.

tools/build_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def get_config(src_path, target, toolchain_name):
8888
config = Config(target, src_paths)
8989

9090
# If the 'target' argument is a string, convert it to a target instance
91-
if isinstance(target, str):
91+
if isinstance(target, basestring):
9292
try:
9393
target = TARGET_MAP[target]
9494
except KeyError:
@@ -149,7 +149,7 @@ def build_project(src_path, build_path, target, toolchain_name,
149149
config = config or Config(target, src_paths)
150150

151151
# If the 'target' argument is a string, convert it to a target instance
152-
if isinstance(target, str):
152+
if isinstance(target, basestring):
153153
try:
154154
target = TARGET_MAP[target]
155155
except KeyError:
@@ -287,7 +287,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
287287
config = Config(target, src_paths)
288288

289289
# If the 'target' argument is a string, convert it to a target instance
290-
if isinstance(target, str):
290+
if isinstance(target, basestring):
291291
try:
292292
target = TARGET_MAP[target]
293293
except KeyError:

tools/build_release.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from os.path import join, abspath, dirname, normpath
2121
from optparse import OptionParser
2222
import json
23+
from shutil import copy
2324

2425
# Be sure that the tools directory is in the search path
2526
ROOT = abspath(join(dirname(__file__), ".."))
@@ -31,7 +32,7 @@
3132
from tools.test_exporters import ReportExporter, ResultExporterType
3233
from tools.test_api import SingleTestRunner
3334
from tools.test_api import singletest_in_cli_mode
34-
from tools.paths import TEST_DIR
35+
from tools.paths import TEST_DIR, MBED_LIBRARIES
3536
from tools.tests import TEST_MAP
3637

3738
OFFICIAL_MBED_LIBRARY_BUILD = (
@@ -169,6 +170,9 @@
169170
except Exception, e:
170171
print str(e)
171172

173+
# copy targets.json file as part of the release
174+
copy(join(dirname(abspath(__file__)), '..', 'hal', 'targets.json'), MBED_LIBRARIES)
175+
172176
# Write summary of the builds
173177
if options.report_build_file_name:
174178
file_report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build")

tools/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def __init__(self, target, top_level_dirs = []):
182182
self.lib_config_data = {}
183183
# Make sure that each config is processed only once
184184
self.processed_configs = {}
185-
self.target = target if isinstance(target, str) else target.name
185+
self.target = target if isinstance(target, basestring) else target.name
186186
self.target_labels = Target.get_target(self.target).get_labels()
187187
self.added_features = set()
188188
self.removed_features = set()

tools/export/exporters.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __scan_and_copy(self, src_path, trg_path):
6161

6262
for r_type in ['headers', 's_sources', 'c_sources', 'cpp_sources',
6363
'objects', 'libraries', 'linker_script',
64-
'lib_builds', 'lib_refs', 'repo_files', 'hex_files', 'bin_files']:
64+
'lib_builds', 'lib_refs', 'hex_files', 'bin_files']:
6565
r = getattr(resources, r_type)
6666
if r:
6767
self.toolchain.copy_files(r, trg_path, resources=resources)
@@ -141,16 +141,21 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
141141
# Copy only the file for the required target and toolchain
142142
lib_builds = []
143143
# Create the configuration object
144+
if isinstance(prj_paths, basestring):
145+
prj_paths = [prj_paths]
144146
config = Config(self.target, prj_paths)
145147
for src in ['lib', 'src']:
146-
resources = reduce(add, [self.__scan_and_copy(join(path, src), trg_path) for path in prj_paths])
148+
resources = self.__scan_and_copy(join(prj_paths[0], src), trg_path)
149+
for path in prj_paths[1:]:
150+
resources.add(self.__scan_and_copy(join(path, src), trg_path))
151+
147152
lib_builds.extend(resources.lib_builds)
148153

149154
# The repository files
150-
for repo_dir in resources.repo_dirs:
151-
repo_files = self.__scan_all(repo_dir)
152-
for path in proj_paths :
153-
self.toolchain.copy_files(repo_files, trg_path, rel_path=join(path, src))
155+
#for repo_dir in resources.repo_dirs:
156+
# repo_files = self.__scan_all(repo_dir)
157+
# for path in prj_paths:
158+
# self.toolchain.copy_files(repo_files, trg_path, rel_path=join(path, src))
154159

155160
# The libraries builds
156161
for bld in lib_builds:
@@ -178,19 +183,14 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
178183
# Loads the resources into the config system which might expand/modify resources based on config data
179184
self.resources = config.load_resources(resources)
180185

181-
182186
if hasattr(self, "MBED_CONFIG_HEADER_SUPPORTED") and self.MBED_CONFIG_HEADER_SUPPORTED :
183187
# Add the configuration file to the target directory
184188
self.config_header = self.toolchain.MBED_CONFIG_FILE_NAME
185189
config.get_config_data_header(join(trg_path, self.config_header))
186190
self.config_macros = []
187-
else :
191+
else:
188192
# And add the configuration macros to the toolchain
189193
self.config_macros = config.get_config_data_macros()
190-
# Check the existence of a binary build of the mbed library for the desired target
191-
# This prevents exporting the mbed libraries from source
192-
# if not self.toolchain.mbed_libs:
193-
# raise OldLibrariesException()
194194

195195
def gen_file(self, template_file, data, target_file):
196196
template_path = join(Exporter.TEMPLATE_DIR, template_file)

tools/export/uvision4.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from tools.export.exporters import Exporter
2121
from tools.targets import TARGET_MAP, TARGET_NAMES
22-
from tools.settings import ARM_INC
2322

2423
# If you wish to add a new target, add it to project_generator_definitions, and then
2524
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -79,8 +78,6 @@ def generate(self, progen_build=False):
7978
project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
8079
# not compatible with c99 flag set in the template
8180
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
82-
# ARM_INC is by default as system inclusion, not required for exported project
83-
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
8481
# cpp is not required as it's implicit for cpp files
8582
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--cpp")
8683
# we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
@@ -98,7 +95,7 @@ def generate(self, progen_build=False):
9895
project_data['common']['macros'].pop(i)
9996
i += 1
10097
project_data['common']['macros'].append('__ASSERT_MSG')
101-
project_data['common']['build_dir'] = join(project_data['common']['build_dir'], 'uvision4')
98+
project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision4'
10299
if progen_build:
103100
self.progen_gen_file('uvision', project_data, True)
104101
else:

tools/export/uvision5.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
from tools.export.exporters import Exporter
2121
from tools.targets import TARGET_MAP, TARGET_NAMES
22-
from tools.settings import ARM_INC
2322

2423
# If you wish to add a new target, add it to project_generator_definitions, and then
2524
# define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
@@ -81,8 +80,6 @@ def generate(self, progen_build=False):
8180
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
8281
# cxx flags included, as uvision have them all in one tab
8382
project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
84-
# ARM_INC is by default as system inclusion, not required for exported project
85-
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
8683
# not compatible with c99 flag set in the template
8784
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
8885
# cpp is not required as it's implicit for cpp files
@@ -102,6 +99,7 @@ def generate(self, progen_build=False):
10299
project_data['common']['macros'].pop(i)
103100
i += 1
104101
project_data['common']['macros'].append('__ASSERT_MSG')
102+
project_data['common']['build_dir'] = project_data['common']['build_dir'] + '\\' + 'uvision5'
105103
if progen_build:
106104
self.progen_gen_file('uvision5', project_data, True)
107105
else:

tools/settings.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,6 @@
8080
print "WARNING: MBED_%s set as environment variable but doesn't exist" % _n
8181

8282

83-
##############################################################################
84-
# ARM Compiler Paths
85-
##############################################################################
86-
87-
ARM_BIN = join(ARM_PATH, "bin")
88-
ARM_INC = join(ARM_PATH, "include")
89-
ARM_LIB = join(ARM_PATH, "lib")
90-
ARM_CPPLIB = join(ARM_LIB, "cpplib")
91-
MY_ARM_CLIB = join(ARM_LIB, "lib", "microlib")
92-
93-
9483
##############################################################################
9584
# Test System Settings
9685
##############################################################################

tools/synch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def ignore_path(name, reg_exps):
122122
class MbedRepository:
123123
@staticmethod
124124
def run_and_print(command, cwd):
125-
stdout, _, _ = run_cmd(command, wd=cwd, redirect=True)
125+
stdout, _, _ = run_cmd(command, work_dir=cwd, redirect=True)
126126
print(stdout)
127127

128128
def __init__(self, name, team = None):
@@ -147,7 +147,7 @@ def __init__(self, name, team = None):
147147
def publish(self):
148148
# The maintainer has to evaluate the changes first and explicitly accept them
149149
self.run_and_print(['hg', 'addremove'], cwd=self.path)
150-
stdout, _, _ = run_cmd(['hg', 'status'], wd=self.path)
150+
stdout, _, _ = run_cmd(['hg', 'status'], work_dir=self.path)
151151
if stdout == '':
152152
print "No changes"
153153
return False

tools/targets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"Cortex-M1" : ["M1", "CORTEX_M", "LIKE_CORTEX_M1"],
2323
"Cortex-M3" : ["M3", "CORTEX_M", "LIKE_CORTEX_M3"],
2424
"Cortex-M4" : ["M4", "CORTEX_M", "RTOS_M4_M7", "LIKE_CORTEX_M4"],
25+
"Cortex-M4F" : ["M4", "CORTEX_M", "RTOS_M4_M7", "LIKE_CORTEX_M4"],
2526
"Cortex-M7" : ["M7", "CORTEX_M", "RTOS_M4_M7", "LIKE_CORTEX_M7"],
27+
"Cortex-M7F" : ["M7", "CORTEX_M", "RTOS_M4_M7", "LIKE_CORTEX_M7"],
28+
"Cortex-M7FD" : ["M7", "CORTEX_M", "RTOS_M4_M7", "LIKE_CORTEX_M7"],
2629
"Cortex-A9" : ["A9", "CORTEX_A", "LIKE_CORTEX_A9"]
2730
}
2831

@@ -58,6 +61,9 @@ class Target:
5861
# need to be computed differently than regular attributes
5962
__cumulative_attributes = ['extra_labels', 'macros', 'device_has', 'features']
6063

64+
# List of targets that were added dynamically using "add_py_targets" (see below)
65+
__py_targets = set()
66+
6167
# Location of the 'targets.json' file
6268
__targets_json_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'hal', 'targets.json')
6369

tools/test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from tools.build_api import add_result_to_report
5959
from tools.build_api import scan_for_source_paths
6060
from tools.libraries import LIBRARIES, LIBRARY_MAP
61-
from tools.toolchains import TOOLCHAIN_BIN_PATH
61+
from tools.toolchains import TOOLCHAIN_PATHS
6262
from tools.toolchains import TOOLCHAINS
6363
from tools.test_exporters import ReportExporter, ResultExporterType
6464
from tools.utils import argparse_filestring_type
@@ -1343,8 +1343,8 @@ def print_test_configuration_from_json(json_data, join_delim=", "):
13431343
if conflict:
13441344
cell_val += '*'
13451345
# Check for conflicts: toolchain vs toolchain path
1346-
if toolchain in TOOLCHAIN_BIN_PATH:
1347-
toolchain_path = TOOLCHAIN_BIN_PATH[toolchain]
1346+
if toolchain in TOOLCHAIN_PATHS:
1347+
toolchain_path = TOOLCHAIN_PATHS[toolchain]
13481348
if not os.path.isdir(toolchain_path):
13491349
conflict_path = True
13501350
if toolchain not in toolchain_path_conflicts:
@@ -1368,8 +1368,8 @@ def print_test_configuration_from_json(json_data, join_delim=", "):
13681368

13691369
for toolchain in toolchain_path_conflicts:
13701370
# Let's check toolchain configuration
1371-
if toolchain in TOOLCHAIN_BIN_PATH:
1372-
toolchain_path = TOOLCHAIN_BIN_PATH[toolchain]
1371+
if toolchain in TOOLCHAIN_PATHS:
1372+
toolchain_path = TOOLCHAIN_PATHS[toolchain]
13731373
if not os.path.isdir(toolchain_path):
13741374
result += "\t# Toolchain %s path not found: %s\n"% (toolchain, toolchain_path)
13751375
return result
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" ?>
2+
<testsuites/>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" ?>
2+
<testsuites/>

0 commit comments

Comments
 (0)