mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #1975 from theotherjimmy/export-mbed-conf
[Exporters] Update exporters to include and use mbed_conf.h (Was #1964)pull/2037/head
commit
af71d87adc
|
|
@ -33,6 +33,8 @@ class AtmelStudio(Exporter):
|
||||||
|
|
||||||
DOT_IN_RELATIVE_PATH = True
|
DOT_IN_RELATIVE_PATH = True
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
|
|
||||||
source_files = []
|
source_files = []
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ class CodeRed(Exporter):
|
||||||
NAME = 'CodeRed'
|
NAME = 'CodeRed'
|
||||||
TOOLCHAIN = 'GCC_CR'
|
TOOLCHAIN = 'GCC_CR'
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
TARGETS = [
|
TARGETS = [
|
||||||
'LPC1768',
|
'LPC1768',
|
||||||
'LPC4088',
|
'LPC4088',
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,8 @@ class IntermediateFile(Exporter):
|
||||||
# we support all GCC targets (is handled on IDE side)
|
# we support all GCC targets (is handled on IDE side)
|
||||||
TARGETS = gccTargets
|
TARGETS = gccTargets
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
FILE_TYPES = {
|
FILE_TYPES = {
|
||||||
'headers': 'h',
|
'headers': 'h',
|
||||||
'c_sources': 'c',
|
'c_sources': 'c',
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class Exporter(object):
|
||||||
self.extra_symbols = extra_symbols
|
self.extra_symbols = extra_symbols
|
||||||
self.config_macros = []
|
self.config_macros = []
|
||||||
self.sources_relative = sources_relative
|
self.sources_relative = sources_relative
|
||||||
|
self.config_header = None
|
||||||
|
|
||||||
def get_toolchain(self):
|
def get_toolchain(self):
|
||||||
return self.TOOLCHAIN
|
return self.TOOLCHAIN
|
||||||
|
|
@ -48,6 +49,9 @@ class Exporter(object):
|
||||||
def progen_flags(self):
|
def progen_flags(self):
|
||||||
if not hasattr(self, "_progen_flag_cache") :
|
if not hasattr(self, "_progen_flag_cache") :
|
||||||
self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()])
|
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
|
return self._progen_flag_cache
|
||||||
|
|
||||||
def __scan_and_copy(self, src_path, trg_path):
|
def __scan_and_copy(self, src_path, trg_path):
|
||||||
|
|
@ -167,9 +171,15 @@ class Exporter(object):
|
||||||
# Loads the resources into the config system which might expand/modify resources based on config data
|
# Loads the resources into the config system which might expand/modify resources based on config data
|
||||||
self.resources = config.load_resources(resources)
|
self.resources = config.load_resources(resources)
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(self, "MBED_CONFIG_HEADER_SUPPORTED") and self.MBED_CONFIG_HEADER_SUPPORTED :
|
||||||
|
# Add the configuration file to the target directory
|
||||||
|
self.config_header = self.toolchain.MBED_CONFIG_FILE_NAME
|
||||||
|
config.get_config_data_header(join(trg_path, self.config_header))
|
||||||
|
self.config_macros = []
|
||||||
|
else :
|
||||||
# And add the configuration macros to the toolchain
|
# And add the configuration macros to the toolchain
|
||||||
self.config_macros = config.get_config_data_macros()
|
self.config_macros = config.get_config_data_macros()
|
||||||
|
|
||||||
# Check the existence of a binary build of the mbed library for the desired target
|
# Check the existence of a binary build of the mbed library for the desired target
|
||||||
# This prevents exporting the mbed libraries from source
|
# This prevents exporting the mbed libraries from source
|
||||||
# if not self.toolchain.mbed_libs:
|
# if not self.toolchain.mbed_libs:
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,8 @@ class GccArm(Exporter):
|
||||||
|
|
||||||
DOT_IN_RELATIVE_PATH = True
|
DOT_IN_RELATIVE_PATH = True
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
# "make" wants Unix paths
|
# "make" wants Unix paths
|
||||||
self.resources.win_to_unix()
|
self.resources.win_to_unix()
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ class IAREmbeddedWorkbench(Exporter):
|
||||||
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
||||||
PROGEN_ACTIVE = True
|
PROGEN_ACTIVE = True
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
# backward compatibility with our scripts
|
# backward compatibility with our scripts
|
||||||
TARGETS = []
|
TARGETS = []
|
||||||
for target in TARGET_NAMES:
|
for target in TARGET_NAMES:
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,8 @@ class SimplicityV3(Exporter):
|
||||||
|
|
||||||
DOT_IN_RELATIVE_PATH = False
|
DOT_IN_RELATIVE_PATH = False
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
orderedPaths = Folder("Root")
|
orderedPaths = Folder("Root")
|
||||||
|
|
||||||
def check_and_add_path(self, path):
|
def check_and_add_path(self, path):
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ class Uvision4(Exporter):
|
||||||
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
||||||
PROGEN_ACTIVE = True
|
PROGEN_ACTIVE = True
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
# backward compatibility with our scripts
|
# backward compatibility with our scripts
|
||||||
TARGETS = []
|
TARGETS = []
|
||||||
for target in TARGET_NAMES:
|
for target in TARGET_NAMES:
|
||||||
|
|
@ -69,16 +71,16 @@ class Uvision4(Exporter):
|
||||||
# get flags from toolchain and apply
|
# get flags from toolchain and apply
|
||||||
project_data['tool_specific']['uvision']['misc'] = {}
|
project_data['tool_specific']['uvision']['misc'] = {}
|
||||||
# asm flags only, common are not valid within uvision project, they are armcc specific
|
# asm flags only, common are not valid within uvision project, they are armcc specific
|
||||||
project_data['tool_specific']['uvision']['misc']['asm_flags'] = list(set(self.toolchain.flags['asm']))
|
project_data['tool_specific']['uvision']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
|
||||||
# cxx flags included, as uvision have them all in one tab
|
# cxx flags included, as uvision have them all in one tab
|
||||||
project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(self.toolchain.flags['common'] + self.toolchain.flags['c'] + self.toolchain.flags['cxx']))
|
project_data['tool_specific']['uvision']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
|
||||||
# not compatible with c99 flag set in the template
|
# not compatible with c99 flag set in the template
|
||||||
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
|
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--c99")
|
||||||
# ARM_INC is by default as system inclusion, not required for exported project
|
# ARM_INC is by default as system inclusion, not required for exported project
|
||||||
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
|
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
|
||||||
# cpp is not required as it's implicit for cpp files
|
# cpp is not required as it's implicit for cpp files
|
||||||
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--cpp")
|
project_data['tool_specific']['uvision']['misc']['c_flags'].remove("--cpp")
|
||||||
project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.toolchain.flags['ld']
|
project_data['tool_specific']['uvision']['misc']['ld_flags'] = self.progen_flags['ld_flags']
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
for macro in project_data['common']['macros']:
|
for macro in project_data['common']['macros']:
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ class Uvision5(Exporter):
|
||||||
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
# PROGEN_ACTIVE contains information for exporter scripts that this is using progen
|
||||||
PROGEN_ACTIVE = True
|
PROGEN_ACTIVE = True
|
||||||
|
|
||||||
|
MBED_CONFIG_HEADER_SUPPORTED = True
|
||||||
|
|
||||||
# backward compatibility with our scripts
|
# backward compatibility with our scripts
|
||||||
TARGETS = []
|
TARGETS = []
|
||||||
for target in TARGET_NAMES:
|
for target in TARGET_NAMES:
|
||||||
|
|
@ -69,16 +71,16 @@ class Uvision5(Exporter):
|
||||||
# get flags from toolchain and apply
|
# get flags from toolchain and apply
|
||||||
project_data['tool_specific']['uvision5']['misc'] = {}
|
project_data['tool_specific']['uvision5']['misc'] = {}
|
||||||
# asm flags only, common are not valid within uvision project, they are armcc specific
|
# asm flags only, common are not valid within uvision project, they are armcc specific
|
||||||
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = list(set(self.toolchain.flags['asm']))
|
project_data['tool_specific']['uvision5']['misc']['asm_flags'] = list(set(self.progen_flags['asm_flags']))
|
||||||
# cxx flags included, as uvision have them all in one tab
|
# cxx flags included, as uvision have them all in one tab
|
||||||
project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(self.toolchain.flags['common'] + self.toolchain.flags['c'] + self.toolchain.flags['cxx']))
|
project_data['tool_specific']['uvision5']['misc']['c_flags'] = list(set(self.progen_flags['common_flags'] + self.progen_flags['c_flags'] + self.progen_flags['cxx_flags']))
|
||||||
# ARM_INC is by default as system inclusion, not required for exported project
|
# ARM_INC is by default as system inclusion, not required for exported project
|
||||||
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
|
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("-I \""+ARM_INC+"\"")
|
||||||
# not compatible with c99 flag set in the template
|
# not compatible with c99 flag set in the template
|
||||||
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
|
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--c99")
|
||||||
# cpp is not required as it's implicit for cpp files
|
# cpp is not required as it's implicit for cpp files
|
||||||
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--cpp")
|
project_data['tool_specific']['uvision5']['misc']['c_flags'].remove("--cpp")
|
||||||
project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.toolchain.flags['ld']
|
project_data['tool_specific']['uvision5']['misc']['ld_flags'] = self.progen_flags['ld_flags']
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
for macro in project_data['common']['macros']:
|
for macro in project_data['common']['macros']:
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,8 @@ class mbedToolchain:
|
||||||
GOANNA_FORMAT = "[Goanna] warning [%FILENAME%:%LINENO%] - [%CHECKNAME%(%SEVERITY%)] %MESSAGE%"
|
GOANNA_FORMAT = "[Goanna] warning [%FILENAME%:%LINENO%] - [%CHECKNAME%(%SEVERITY%)] %MESSAGE%"
|
||||||
GOANNA_DIAGNOSTIC_PATTERN = re.compile(r'"\[Goanna\] (?P<severity>warning) \[(?P<file>[^:]+):(?P<line>\d+)\] \- (?P<message>.*)"')
|
GOANNA_DIAGNOSTIC_PATTERN = re.compile(r'"\[Goanna\] (?P<severity>warning) \[(?P<file>[^:]+):(?P<line>\d+)\] \- (?P<message>.*)"')
|
||||||
|
|
||||||
|
MBED_CONFIG_FILE_NAME="mbed_config.h"
|
||||||
|
|
||||||
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
def __init__(self, target, options=None, notify=None, macros=None, silent=False, extra_verbose=False):
|
||||||
self.target = target
|
self.target = target
|
||||||
self.name = self.__class__.__name__
|
self.name = self.__class__.__name__
|
||||||
|
|
@ -908,7 +910,7 @@ class mbedToolchain:
|
||||||
def get_config_header(self):
|
def get_config_header(self):
|
||||||
if self.config_data is None:
|
if self.config_data is None:
|
||||||
return None
|
return None
|
||||||
config_file = join(self.build_dir, "mbed_config.h")
|
config_file = join(self.build_dir, self.MBED_CONFIG_FILE_NAME)
|
||||||
if not exists(config_file):
|
if not exists(config_file):
|
||||||
with open(config_file, "wt") as f:
|
with open(config_file, "wt") as f:
|
||||||
f.write(Config.config_to_header(self.config_data))
|
f.write(Config.config_to_header(self.config_data))
|
||||||
|
|
|
||||||
|
|
@ -114,11 +114,14 @@ class ARM(mbedToolchain):
|
||||||
dep_path = base + '.d'
|
dep_path = base + '.d'
|
||||||
return ["--depend", dep_path]
|
return ["--depend", dep_path]
|
||||||
|
|
||||||
|
def get_config_option(self, config_header) :
|
||||||
|
return ['--preinclude=' + config_header]
|
||||||
|
|
||||||
def get_compile_options(self, defines, includes):
|
def get_compile_options(self, defines, includes):
|
||||||
opts = ['-D%s' % d for d in defines] + ['--via', self.get_inc_file(includes)]
|
opts = ['-D%s' % d for d in defines] + ['--via', self.get_inc_file(includes)]
|
||||||
config_header = self.get_config_header()
|
config_header = self.get_config_header()
|
||||||
if config_header is not None:
|
if config_header is not None:
|
||||||
opts = opts + ['--preinclude', config_header]
|
opts = opts + self.get_config_option(config_header)
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@hook_tool
|
@hook_tool
|
||||||
|
|
|
||||||
|
|
@ -165,11 +165,14 @@ class GCC(mbedToolchain):
|
||||||
dep_path = base + '.d'
|
dep_path = base + '.d'
|
||||||
return ["-MD", "-MF", dep_path]
|
return ["-MD", "-MF", dep_path]
|
||||||
|
|
||||||
|
def get_config_option(self, config_header):
|
||||||
|
return ['-include', config_header]
|
||||||
|
|
||||||
def get_compile_options(self, defines, includes):
|
def get_compile_options(self, defines, includes):
|
||||||
opts = ['-D%s' % d for d in defines] + ['@%s' % self.get_inc_file(includes)]
|
opts = ['-D%s' % d for d in defines] + ['@%s' % self.get_inc_file(includes)]
|
||||||
config_header = self.get_config_header()
|
config_header = self.get_config_header()
|
||||||
if config_header is not None:
|
if config_header is not None:
|
||||||
opts = opts + ['-include', config_header]
|
opts = opts + self.get_config_option(config_header)
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@hook_tool
|
@hook_tool
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,12 @@ class IAR(mbedToolchain):
|
||||||
base, _ = splitext(object)
|
base, _ = splitext(object)
|
||||||
return ["-l", base + '.s.txt']
|
return ["-l", base + '.s.txt']
|
||||||
|
|
||||||
|
def get_config_option(self, config_header):
|
||||||
|
return ['--preinclude=' + config_header]
|
||||||
|
|
||||||
def get_compile_options(self, defines, includes, for_asm=False):
|
def get_compile_options(self, defines, includes, for_asm=False):
|
||||||
opts = ['-D%s' % d for d in defines] + ['-f', self.get_inc_file(includes)]
|
opts = ['-D%s' % d for d in defines] + ['-f', self.get_inc_file(includes)]
|
||||||
|
config_header = self.get_config_header()
|
||||||
if for_asm:
|
if for_asm:
|
||||||
# The assembler doesn't support '--preinclude', so we need to add
|
# The assembler doesn't support '--preinclude', so we need to add
|
||||||
# the macros directly
|
# the macros directly
|
||||||
|
|
@ -135,7 +139,7 @@ class IAR(mbedToolchain):
|
||||||
else:
|
else:
|
||||||
config_header = self.get_config_header()
|
config_header = self.get_config_header()
|
||||||
if config_header is not None:
|
if config_header is not None:
|
||||||
opts = opts + ['--preinclude', config_header]
|
opts = opts + self.get_config_option(config_header)
|
||||||
return opts
|
return opts
|
||||||
|
|
||||||
@hook_tool
|
@hook_tool
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue