17
17
from project_generator .project import Project
18
18
from project_generator .settings import ProjectSettings
19
19
20
+ from tools .config import Config
21
+
20
22
class OldLibrariesException (Exception ): pass
21
23
22
24
class Exporter (object ):
@@ -32,6 +34,7 @@ def __init__(self, target, inputDir, program_name, build_url_resolver, extra_sym
32
34
jinja_loader = FileSystemLoader (os .path .dirname (os .path .abspath (__file__ )))
33
35
self .jinja_environment = Environment (loader = jinja_loader )
34
36
self .extra_symbols = extra_symbols
37
+ self .config_macros = []
35
38
36
39
def get_toolchain (self ):
37
40
return self .TOOLCHAIN
@@ -115,6 +118,8 @@ def __scan_all(self, path):
115
118
def scan_and_copy_resources (self , prj_paths , trg_path , relative = False ):
116
119
# Copy only the file for the required target and toolchain
117
120
lib_builds = []
121
+ # Create the configuration object
122
+ cfg = Config (self .target , prj_paths )
118
123
for src in ['lib' , 'src' ]:
119
124
resources = reduce (add , [self .__scan_and_copy (join (path , src ), trg_path ) for path in prj_paths ])
120
125
lib_builds .extend (resources .lib_builds )
@@ -145,6 +150,10 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
145
150
else :
146
151
# use the prj_dir (source, not destination)
147
152
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 ()
148
157
# Check the existence of a binary build of the mbed library for the desired target
149
158
# This prevents exporting the mbed libraries from source
150
159
# if not self.toolchain.mbed_libs:
@@ -163,7 +172,7 @@ def get_symbols(self, add_extra_symbols=True):
163
172
""" This function returns symbols which must be exported.
164
173
Please add / overwrite symbols in each exporter separately
165
174
"""
166
- symbols = self .toolchain .get_symbols ()
175
+ symbols = self .toolchain .get_symbols () + self . config_macros
167
176
# We have extra symbols from e.g. libraries, we want to have them also added to export
168
177
if add_extra_symbols :
169
178
if self .extra_symbols is not None :
0 commit comments