Skip to content

Commit 44b8b05

Browse files
committed
Merge pull request #246 from ARMmbed/config_in_export
Added support for configuration data in exporters
2 parents a16b40a + efed396 commit 44b8b05

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tools/export/exporters.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from project_generator.project import Project
1818
from project_generator.settings import ProjectSettings
1919

20+
from tools.config import Config
21+
2022
class OldLibrariesException(Exception): pass
2123

2224
class Exporter(object):
@@ -32,6 +34,7 @@ def __init__(self, target, inputDir, program_name, build_url_resolver, extra_sym
3234
jinja_loader = FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
3335
self.jinja_environment = Environment(loader=jinja_loader)
3436
self.extra_symbols = extra_symbols
37+
self.config_macros = []
3538

3639
def get_toolchain(self):
3740
return self.TOOLCHAIN
@@ -115,6 +118,8 @@ def __scan_all(self, path):
115118
def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
116119
# Copy only the file for the required target and toolchain
117120
lib_builds = []
121+
# Create the configuration object
122+
cfg = Config(self.target, prj_paths)
118123
for src in ['lib', 'src']:
119124
resources = reduce(add, [self.__scan_and_copy(join(path, src), trg_path) for path in prj_paths])
120125
lib_builds.extend(resources.lib_builds)
@@ -145,6 +150,10 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
145150
else:
146151
# use the prj_dir (source, not destination)
147152
self.resources = reduce(add, [self.toolchain.scan_resources(path) for path in prj_paths])
153+
# Add all JSON files discovered during scanning to the configuration object
154+
cfg.add_config_files(self.resources.json_files)
155+
# Get data from the configuration system
156+
self.config_macros = cfg.get_config_data_macros()
148157
# Check the existence of a binary build of the mbed library for the desired target
149158
# This prevents exporting the mbed libraries from source
150159
# if not self.toolchain.mbed_libs:
@@ -163,7 +172,7 @@ def get_symbols(self, add_extra_symbols=True):
163172
""" This function returns symbols which must be exported.
164173
Please add / overwrite symbols in each exporter separately
165174
"""
166-
symbols = self.toolchain.get_symbols()
175+
symbols = self.toolchain.get_symbols() + self.config_macros
167176
# We have extra symbols from e.g. libraries, we want to have them also added to export
168177
if add_extra_symbols:
169178
if self.extra_symbols is not None:

0 commit comments

Comments
 (0)