Skip to content

Commit 1a1dafe

Browse files
author
Bogdan Marinescu
committed
Added configuration mechanism
If the build system finds a file named mbed_config.h, it will automatically define a HAVE_MBED_CONFIG_H macro. Various libraries/components can use this mechanism to provide compile-time configuration for user projects.
1 parent bb04bf9 commit 1a1dafe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

workspace_tools/toolchains/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ def __init__(self, target, options=None, notify=None, macros=None):
171171

172172
self.symbols = None
173173
self.labels = None
174+
self.has_config = False
174175

175176
self.build_all = False
176177

@@ -186,6 +187,8 @@ def get_symbols(self):
186187
labels = self.get_labels()
187188
self.symbols = ["TARGET_%s" % t for t in labels['TARGET']]
188189
self.symbols.extend(["TOOLCHAIN_%s" % t for t in labels['TOOLCHAIN']])
190+
if self.has_config:
191+
self.symbols.append('HAVE_MBED_CONFIG_H')
189192

190193
# Cortex CPU symbols
191194
if self.target.core in mbedToolchain.CORTEX_SYMBOLS:
@@ -226,6 +229,7 @@ def need_update(self, target, dependencies):
226229
def scan_resources(self, path):
227230
labels = self.get_labels()
228231
resources = Resources(path)
232+
self.has_config = False
229233

230234
""" os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])
231235
When topdown is True, the caller can modify the dirnames list in-place
@@ -263,6 +267,8 @@ def scan_resources(self, path):
263267
resources.cpp_sources.append(file_path)
264268

265269
elif ext == '.h':
270+
if basename(file_path) == "mbed_config.h":
271+
self.has_config = True
266272
resources.headers.append(file_path)
267273

268274
elif ext == '.o':
@@ -314,7 +320,6 @@ def compile_sources(self, resources, build_path, inc_dirs=None):
314320
inc_paths.extend(inc_dirs)
315321

316322
base_path = resources.base_path
317-
318323
for source in resources.s_sources:
319324
self.compiled += 1
320325
object = self.relative_object_path(build_path, base_path, source)

0 commit comments

Comments
 (0)