diff --git a/tools/export/exporters.py b/tools/export/exporters.py index 77e114931eb..e030b3ecf5b 100644 --- a/tools/export/exporters.py +++ b/tools/export/exporters.py @@ -35,6 +35,7 @@ def __init__(self, target, inputDir, program_name, build_url_resolver, extra_sym self.jinja_environment = Environment(loader=jinja_loader) self.extra_symbols = extra_symbols self.config_macros = [] + self.config_header = None def get_toolchain(self): return self.TOOLCHAIN @@ -47,6 +48,9 @@ def flags(self): def progen_flags(self): if not hasattr(self, "_progen_flag_cache") : self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()]) + if self.config_header: + self._progen_flag_cache['c_flags'] += self.toolchain.get_config_option(self.config_header) + self._progen_flag_cache['cxx_flags'] += self.toolchain.get_config_option(self.config_header) return self._progen_flag_cache def __scan_and_copy(self, src_path, trg_path): @@ -168,7 +172,10 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False): # And add the configuration macros to the toolchain self.config_macros = config.get_config_data_macros() - + + # Add the configuration file to the target directory + self.config_header = "mbed_conf.h" + cfg.get_config_data_header(join(trg_path, self.config_header)) # Check the existence of a binary build of the mbed library for the desired target # This prevents exporting the mbed libraries from source # if not self.toolchain.mbed_libs: diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index deff6cf9fd3..bc4c5b0459d 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -114,11 +114,14 @@ def get_dep_option(self, object): dep_path = base + '.d' return ["--depend", dep_path] + def get_config_option(self, config_header) : + return ['--preinclude', config_header] + def get_compile_options(self, defines, includes): opts = ['-D%s' % d for d in defines] + ['--via', self.get_inc_file(includes)] config_header = self.get_config_header() if config_header is not None: - opts = opts + ['--preinclude', config_header] + opts = opts + self.get_config_option(config_header) return opts @hook_tool diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index dc10c13d8c8..0c5c68a8a0f 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -165,11 +165,14 @@ def get_dep_option(self, object): dep_path = base + '.d' return ["-MD", "-MF", dep_path] + def get_config_option(self, config_header): + return ['-include', config_header] + def get_compile_options(self, defines, includes): opts = ['-D%s' % d for d in defines] + ['@%s' % self.get_inc_file(includes)] config_header = self.get_config_header() if config_header is not None: - opts = opts + ['-include', config_header] + opts = opts + self.get_config_option(config_header) return opts @hook_tool diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index 7c16328b6a3..2c1b1361b57 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -126,11 +126,14 @@ def cc_extra(self, object): base, _ = splitext(object) return ["-l", base + '.s.txt'] + def get_config_option(self, config_header): + return ['--preinclude', config_header] + def get_compile_options(self, defines, includes): opts = ['-D%s' % d for d in defines] + ['-f', self.get_inc_file(includes)] config_header = self.get_config_header() if config_header is not None: - opts = opts + ['--preinclude', config_header] + opts = opts + self.get_config_option(config_header) return opts @hook_tool