mirror of https://github.com/ARMmbed/mbed-os.git
Added toolchain support for configuration in prefix headers
This commit uses the previously introduced feature of generating configuration data as a C header file rather than as command line macro definitions. Each toolchain was modified to use prefix headers if requested, and build_api.py was modified to set up the toolchain's prefix header content using the data generated by the config system. Tested by compiling blinky for GCC and ARMCC. I'm having a few issues with my IAR license currently, but both ARMCC and IAR use the same `--preinclude` option for prefix headers, so this shouldn't be an issue. Note that at the moment all exporters still use the previous configuration data mechanism (individual macro definitions as opposed to a prefix header). Exporters will be updated in one or more PRs that will follow.pull/1957/head
parent
80a70fcb51
commit
85eca37d29
|
@ -232,8 +232,8 @@ def build_project(src_path, build_path, target, toolchain_name,
|
|||
prev_features = features
|
||||
config.validate_config()
|
||||
|
||||
# And add the configuration macros to the toolchain
|
||||
toolchain.add_macros(config.get_config_data_macros())
|
||||
# Set the toolchain's prefix header with the config data
|
||||
toolchain.set_prefix_header_content(config.get_config_data_header())
|
||||
|
||||
# Compile Sources
|
||||
for path in src_paths:
|
||||
|
@ -403,8 +403,8 @@ def build_library(src_paths, build_path, target, toolchain_name,
|
|||
prev_features = features
|
||||
config.validate_config()
|
||||
|
||||
# And add the configuration macros to the toolchain
|
||||
toolchain.add_macros(config.get_config_data_macros())
|
||||
# Set the toolchain's prefix header with the config data
|
||||
toolchain.set_prefix_header_content(config.get_config_data_header())
|
||||
|
||||
# Compile Sources
|
||||
for path in src_paths:
|
||||
|
|
|
@ -265,6 +265,9 @@ class mbedToolchain:
|
|||
|
||||
self.flags = deepcopy(self.DEFAULT_FLAGS)
|
||||
|
||||
# prefix_header_content will hold the content of the prefix header (if used)
|
||||
self.prefix_header_content = None
|
||||
|
||||
def get_output(self):
|
||||
return self.output
|
||||
|
||||
|
@ -867,6 +870,26 @@ class mbedToolchain:
|
|||
map_csv = splitext(map)[0] + "_map.csv"
|
||||
memap.generate_output('csv-ci', map_csv)
|
||||
|
||||
# "Prefix headers" are automatically included by the compiler at the beginning of
|
||||
# each source file.
|
||||
# header_content - the content of the prefix header file.
|
||||
def set_prefix_header_content(self, header_content):
|
||||
self.prefix_header_content = header_content
|
||||
|
||||
# Return the location of the prefix header. This function will create the prefix
|
||||
# header first if needed. The header will be written in a file called "mbed_prefix.h"
|
||||
# located in the project's build directory.
|
||||
# If prefix headers are not used (self.prefix_header_content is None), the function
|
||||
# returns None
|
||||
def get_prefix_header(self):
|
||||
if self.prefix_header_content is None:
|
||||
return None
|
||||
prefix_file = join(self.build_dir, "mbed_prefix.h")
|
||||
if not exists(prefix_file):
|
||||
with open(prefix_file, "wt") as f:
|
||||
f.write(self.prefix_header_content)
|
||||
return prefix_file
|
||||
|
||||
|
||||
from tools.settings import ARM_BIN
|
||||
from tools.settings import GCC_ARM_PATH, GCC_CR_PATH
|
||||
|
|
|
@ -115,7 +115,11 @@ class ARM(mbedToolchain):
|
|||
return ["--depend", dep_path]
|
||||
|
||||
def get_compile_options(self, defines, includes):
|
||||
return ['-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)]
|
||||
prefix_header = self.get_prefix_header()
|
||||
if prefix_header is not None:
|
||||
opts = opts + ['--preinclude', prefix_header]
|
||||
return opts
|
||||
|
||||
@hook_tool
|
||||
def assemble(self, source, object, includes):
|
||||
|
|
|
@ -166,7 +166,11 @@ class GCC(mbedToolchain):
|
|||
return ["-MD", "-MF", dep_path]
|
||||
|
||||
def get_compile_options(self, defines, includes):
|
||||
return ['-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)]
|
||||
prefix_header = self.get_prefix_header()
|
||||
if prefix_header is not None:
|
||||
opts = opts + ['-include', prefix_header]
|
||||
return opts
|
||||
|
||||
@hook_tool
|
||||
def assemble(self, source, object, includes):
|
||||
|
|
|
@ -119,7 +119,11 @@ class IAR(mbedToolchain):
|
|||
return ["-l", base + '.s.txt']
|
||||
|
||||
def get_compile_options(self, defines, includes):
|
||||
return ['-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)]
|
||||
prefix_header = self.get_prefix_header()
|
||||
if prefix_header is not None:
|
||||
opts = opts + ['--preinclude', prefix_header]
|
||||
return opts
|
||||
|
||||
@hook_tool
|
||||
def assemble(self, source, object, includes):
|
||||
|
|
Loading…
Reference in New Issue