Skip to content

Commit a92d0df

Browse files
committed
Move region adding to mbedToolchain
1 parent c9add5c commit a92d0df

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

tools/build_api.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -284,25 +284,6 @@ def get_mbed_official_release(version):
284284

285285
return mbed_official_release
286286

287-
def add_regions_to_toolchain(toolchain):
288-
"""Add regions to the build profile, if there are any.
289-
290-
Positional Arguments:
291-
toolchain - the toolchain to add the region defines to
292-
"""
293-
regions = list(toolchain.config.regions)
294-
for region in regions:
295-
for define in [(region.name.upper() + "_ADDR", region.start),
296-
(region.name.upper() + "_SIZE", region.size)]:
297-
toolchain.cc.append("-D%s=0x%x" % define)
298-
toolchain.cppc.append("-D%s=0x%x" % define)
299-
if region.active:
300-
toolchain.ld.append(toolchain.make_ld_define(*define))
301-
print("Using regions in this build:")
302-
for region in regions:
303-
print(" Region %s size 0x%x, offset 0x%x"
304-
% (region.name, region.size, region.start))
305-
306287

307288
def prepare_toolchain(src_paths, build_dir, target, toolchain_name,
308289
macros=None, clean=False, jobs=1,
@@ -430,9 +411,6 @@ def scan_resources(src_paths, toolchain, dependencies_paths=None,
430411
# Set the toolchain's configuration data
431412
toolchain.set_config_data(toolchain.config.get_config_data())
432413

433-
if toolchain.config.has_regions:
434-
add_regions_to_toolchain(toolchain)
435-
436414
if (hasattr(toolchain.target, "release_versions") and
437415
"5" not in toolchain.target.release_versions and
438416
"rtos" in toolchain.config.lib_config_data):

tools/toolchains/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,9 +1231,31 @@ def mem_stats(self, map):
12311231

12321232
return None
12331233

1234+
def add_regions(self):
1235+
"""Add regions to the build profile, if there are any.
1236+
"""
1237+
print("Using regions in this build:")
1238+
for region in self.config.regions:
1239+
for define in [(region.name.upper() + "_ADDR", region.start),
1240+
(region.name.upper() + "_SIZE", region.size)]:
1241+
define_string = "-D%s=0x%x" % define
1242+
self.cc.append(define_string)
1243+
self.cppc.append(define_string)
1244+
self.flags["common"].append(define_string)
1245+
if region.active:
1246+
for define in [("MBED_APP_START", region.start),
1247+
("MBED_APP_SIZE", region.size)]:
1248+
define_string = self.make_ld_define(*define)
1249+
self.ld.append(define_string)
1250+
self.flags["ld"].append(define_string)
1251+
print(" Region %s size 0x%x, offset 0x%x"
1252+
% (region.name, region.size, region.start))
1253+
12341254
# Set the configuration data
12351255
def set_config_data(self, config_data):
12361256
self.config_data = config_data
1257+
if self.config.has_regions:
1258+
self.add_regions()
12371259

12381260
# Creates the configuration header if needed:
12391261
# - if there is no configuration data, "mbed_config.h" is not create (or deleted if it exists).

0 commit comments

Comments
 (0)