mirror of https://github.com/ARMmbed/mbed-os.git
Correct several exporter uses of file_basepath with a dedupe
parent
f143019e9a
commit
6a87510192
|
@ -69,13 +69,11 @@ class CCES(Exporter):
|
|||
|
||||
Skip macros because headless tools handles them separately
|
||||
"""
|
||||
config_header = self.toolchain.get_config_header()
|
||||
flags = {key + "_flags": copy.deepcopy(value) for key, value \
|
||||
in self.toolchain.flags.iteritems()}
|
||||
config_header = self.config_header_ref
|
||||
if config_header:
|
||||
config_header = os.path.relpath(config_header, \
|
||||
self.resources.file_basepath[config_header])
|
||||
config_header = "\\\"" + self.format_inc_path(config_header) \
|
||||
config_header = "\\\"" + self.format_inc_path(config_header.name) \
|
||||
+ "\\\""
|
||||
header_options = self.toolchain.get_config_option(config_header)
|
||||
flags['c_flags'] += header_options
|
||||
|
|
|
@ -101,9 +101,7 @@ class Exporter(object):
|
|||
asm_flags - assembler flags
|
||||
common_flags - common options
|
||||
"""
|
||||
config_header = self.toolchain.get_config_header()
|
||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||
in self.toolchain.flags.items()}
|
||||
flags = self.toolchain_flags(self.toolchain)
|
||||
asm_defines = self.toolchain.get_compile_options(
|
||||
self.toolchain.get_symbols(for_asm=True),
|
||||
filter(None, self.resources.inc_dirs),
|
||||
|
@ -112,18 +110,47 @@ class Exporter(object):
|
|||
flags['asm_flags'] += asm_defines
|
||||
flags['c_flags'] += c_defines
|
||||
flags['cxx_flags'] += c_defines
|
||||
config_header = self.config_header_ref
|
||||
if config_header:
|
||||
def is_config_header(f):
|
||||
return f.path == config_header
|
||||
config_header= filter(
|
||||
is_config_header, self.resources.get_file_refs(FileType.HEADER)
|
||||
)[0]
|
||||
flags['c_flags'] += self.toolchain.get_config_option(
|
||||
config_header.name)
|
||||
flags['cxx_flags'] += self.toolchain.get_config_option(
|
||||
config_header.name)
|
||||
return flags
|
||||
|
||||
def toolchain_flags(self, toolchain):
|
||||
"""Returns a dictionary of toolchain flags.
|
||||
Keys of the dictionary are:
|
||||
cxx_flags - c++ flags
|
||||
c_flags - c flags
|
||||
ld_flags - linker flags
|
||||
asm_flags - assembler flags
|
||||
common_flags - common options
|
||||
|
||||
The difference from the above is that it takes a parameter.
|
||||
"""
|
||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||
in toolchain.flags.items()}
|
||||
config_header = self.config_header_ref
|
||||
if config_header:
|
||||
header_options = self.toolchain.get_config_option(
|
||||
config_header.name)
|
||||
flags['c_flags'] += header_options
|
||||
flags['cxx_flags'] += header_options
|
||||
return flags
|
||||
|
||||
@property
|
||||
def config_header_ref(self):
|
||||
config_header = self.toolchain.get_config_header()
|
||||
if config_header:
|
||||
def is_config_header(f):
|
||||
return f.path == config_header
|
||||
return filter(
|
||||
is_config_header, self.resources.get_file_refs(FileType.HEADER)
|
||||
)[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_source_paths(self):
|
||||
"""Returns a list of the directories where source files are contained"""
|
||||
source_keys = ['s_sources', 'c_sources', 'cpp_sources', 'hex_files',
|
||||
|
|
|
@ -77,57 +77,6 @@ class GNUARMEclipse(Exporter):
|
|||
return apply_supported_whitelist(
|
||||
cls.TOOLCHAIN, POST_BINARY_WHITELIST, target)
|
||||
|
||||
# override
|
||||
@property
|
||||
def flags(self):
|
||||
"""Returns a dictionary of toolchain flags.
|
||||
Keys of the dictionary are:
|
||||
cxx_flags - c++ flags
|
||||
c_flags - c flags
|
||||
ld_flags - linker flags
|
||||
asm_flags - assembler flags
|
||||
common_flags - common options
|
||||
|
||||
The difference from the parent function is that it does not
|
||||
add macro definitions, since they are passed separately.
|
||||
"""
|
||||
|
||||
config_header = self.toolchain.get_config_header()
|
||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||
in self.toolchain.flags.items()}
|
||||
if config_header:
|
||||
config_header = relpath(config_header,
|
||||
self.resources.file_basepath[config_header])
|
||||
flags['c_flags'] += self.toolchain.get_config_option(config_header)
|
||||
flags['cxx_flags'] += self.toolchain.get_config_option(
|
||||
config_header)
|
||||
return flags
|
||||
|
||||
def toolchain_flags(self, toolchain):
|
||||
"""Returns a dictionary of toolchain flags.
|
||||
Keys of the dictionary are:
|
||||
cxx_flags - c++ flags
|
||||
c_flags - c flags
|
||||
ld_flags - linker flags
|
||||
asm_flags - assembler flags
|
||||
common_flags - common options
|
||||
|
||||
The difference from the above is that it takes a parameter.
|
||||
"""
|
||||
|
||||
# Note: use the config options from the currently selected toolchain.
|
||||
config_header = self.toolchain.get_config_header()
|
||||
|
||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||
in toolchain.flags.items()}
|
||||
if config_header:
|
||||
config_header = relpath(config_header,
|
||||
self.resources.file_basepath[config_header])
|
||||
header_options = self.toolchain.get_config_option(config_header)
|
||||
flags['c_flags'] += header_options
|
||||
flags['cxx_flags'] += header_options
|
||||
return flags
|
||||
|
||||
def validate_resources(self):
|
||||
if not self.resources.linker_script:
|
||||
raise NotSupportedException("No linker script found.")
|
||||
|
|
|
@ -24,6 +24,7 @@ import sys
|
|||
from subprocess import check_output, CalledProcessError, Popen, PIPE
|
||||
import shutil
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
from tools.resources import FileType
|
||||
from tools.export.exporters import Exporter, apply_supported_whitelist
|
||||
from tools.utils import NotSupportedException
|
||||
from tools.targets import TARGET_MAP
|
||||
|
@ -237,11 +238,12 @@ class Arm(Makefile):
|
|||
|
||||
def generate(self):
|
||||
if self.resources.linker_script:
|
||||
sct_file = self.resources.linker_script
|
||||
sct_file = self.resources.get_file_refs(FileType.LD_SCRIPT)[-1]
|
||||
new_script = self.toolchain.correct_scatter_shebang(
|
||||
sct_file, join(self.resources.file_basepath[sct_file], "BUILD"))
|
||||
sct_file.path, dirname(sct_file.name))
|
||||
if new_script is not sct_file:
|
||||
self.resources.linker_script = new_script
|
||||
self.resources.add_files_to_type(
|
||||
FileType.LD_SCRIPT, [new_script])
|
||||
self.generated_files.append(new_script)
|
||||
return super(Arm, self).generate()
|
||||
|
||||
|
|
|
@ -36,31 +36,6 @@ class GNUARMNetbeans(Exporter):
|
|||
def prepare_sys_lib(libname):
|
||||
return "-l" + libname
|
||||
|
||||
def toolchain_flags(self, toolchain):
|
||||
"""Returns a dictionary of toolchain flags.
|
||||
Keys of the dictionary are:
|
||||
cxx_flags - c++ flags
|
||||
c_flags - c flags
|
||||
ld_flags - linker flags
|
||||
asm_flags - assembler flags
|
||||
common_flags - common options
|
||||
|
||||
The difference from the above is that it takes a parameter.
|
||||
"""
|
||||
|
||||
# Note: use the config options from the currently selected toolchain.
|
||||
config_header = self.toolchain.get_config_header()
|
||||
|
||||
flags = {key + "_flags": copy.deepcopy(value) for key, value
|
||||
in toolchain.flags.items()}
|
||||
if config_header:
|
||||
config_header = relpath(config_header,
|
||||
self.resources.file_basepath[config_header])
|
||||
header_options = self.toolchain.get_config_option(config_header)
|
||||
flags['c_flags'] += header_options
|
||||
flags['cxx_flags'] += header_options
|
||||
return flags
|
||||
|
||||
@staticmethod
|
||||
def get_defines_and_remove_from_flags(flags_in, str_key):
|
||||
defines = []
|
||||
|
|
|
@ -433,10 +433,6 @@ class Sw4STM32(GNUARMEclipse):
|
|||
|
||||
self.resources.win_to_unix()
|
||||
|
||||
config_header = self.toolchain.get_config_header()
|
||||
if config_header:
|
||||
config_header = relpath(config_header, self.resources.file_basepath[config_header])
|
||||
|
||||
libraries = []
|
||||
for lib in self.resources.libraries:
|
||||
library, _ = splitext(basename(lib))
|
||||
|
@ -531,7 +527,7 @@ class Sw4STM32(GNUARMEclipse):
|
|||
'name': self.project_name,
|
||||
'platform': platform,
|
||||
'include_paths': self.include_path,
|
||||
'config_header': config_header,
|
||||
'config_header': self.config_header_ref.name,
|
||||
'exclude_paths': '|'.join(self.excluded_folders),
|
||||
'ld_script': ld_script,
|
||||
'library_paths': lib_dirs,
|
||||
|
|
|
@ -230,12 +230,16 @@ class ARM(mbedToolchain):
|
|||
def compile_cpp(self, source, object, includes):
|
||||
return self.compile(self.cppc, source, object, includes)
|
||||
|
||||
def correct_scatter_shebang(self, scatter_file, base_path=curdir):
|
||||
def correct_scatter_shebang(self, scatter_file, cur_dir_name=None):
|
||||
"""Correct the shebang at the top of a scatter file.
|
||||
|
||||
Positional arguments:
|
||||
scatter_file -- the scatter file to correct
|
||||
|
||||
Keyword arguments:
|
||||
cur_dir_name -- the name (not path) of the directory containing the
|
||||
scatter file
|
||||
|
||||
Return:
|
||||
The location of the correct scatter file
|
||||
|
||||
|
@ -249,8 +253,9 @@ class ARM(mbedToolchain):
|
|||
return scatter_file
|
||||
else:
|
||||
new_scatter = join(self.build_dir, ".link_script.sct")
|
||||
self.SHEBANG += " -I %s" % relpath(dirname(scatter_file),
|
||||
base_path)
|
||||
if cur_dir_name is None:
|
||||
cur_dir_name = dirname(scatter_file)
|
||||
self.SHEBANG += " -I %s" % cur_dir_name
|
||||
if self.need_update(new_scatter, [scatter_file]):
|
||||
with open(new_scatter, "w") as out:
|
||||
out.write(self.SHEBANG)
|
||||
|
|
Loading…
Reference in New Issue