Merge pull request #7061 from TTornblom/master

Tools: Include configuration in ASM
pull/7540/merge
Cruz Monrreal 2018-07-20 08:02:44 -05:00 committed by GitHub
commit 4bcca894ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 246 additions and 241 deletions

View File

@ -112,8 +112,8 @@ class IAR(Exporter):
self.resources.objects + self.libraries
flags = self.flags
c_flags = list(set(flags['common_flags']
+ flags['c_flags']
+ flags['cxx_flags']))
+ flags['c_flags']
+ flags['cxx_flags']))
# Flags set in template to be set by user in IDE
template = ["--vla", "--no_static_destruction"]
# Flag invalid if set in template
@ -133,7 +133,7 @@ class IAR(Exporter):
'include_paths': [self.format_file(src) for src in self.resources.inc_dirs],
'device': self.iar_device(),
'ewp': sep+self.project_name + ".ewp",
'debugger': debugger
'debugger': debugger,
}
ctx.update(flags)
@ -200,5 +200,3 @@ class IAR(Exporter):
return -1
else:
return 0

View File

@ -10,166 +10,166 @@
<settings>
<name>General</name>
<archiveVersion>3</archiveVersion>
<data>
<version>24</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>GRuntimeLibThreads</name>
<state>0</state>
</option>
<option>
<name>ExePath</name>
<state>$PROJ_DIR$\BUILD\Exe</state>
</option>
<option>
<name>ObjPath</name>
<state>$PROJ_DIR$\BUILD\Obj</state>
</option>
<option>
<name>ListPath</name>
<state>$PROJ_DIR$\BUILD\List</state>
</option>
<option>
<name>GEndianMode</name>
<state>0</state>
</option>
<option>
<name>Input variant</name>
<version>3</version>
<state>1</state>
</option>
<option>
<name>Input description</name>
<state>Full formatting.</state>
</option>
<option>
<name>Output variant</name>
<version>2</version>
<state>3</state>
</option>
<option>
<name>Output description</name>
<state>No specifier a, A.</state>
</option>
<option>
<name>GOutputBinary</name>
<state>0</state>
</option>
<option>
<name>OGCoreOrChip</name>
<state>1</state>
</option>
<option>
<name>GRuntimeLibSelect</name>
<version>0</version>
<state>2</state>
</option>
<option>
<name>GRuntimeLibSelectSlave</name>
<version>0</version>
<state>2</state>
</option>
<option>
<name>RTDescription</name>
<state>Use the full configuration of the C/C++ runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.</state>
</option>
<option>
<name>OGProductVersion</name>
<state>5.10.0.159</state>
</option>
<option>
<name>OGLastSavedByProductVersion</name>
<state>7.80.2.11970</state>
</option>
<option>
<name>GeneralEnableMisra</name>
<state>0</state>
</option>
<option>
<name>GeneralMisraVerbose</name>
<state>0</state>
</option>
<option>
<name>OGChipSelectEditMenu</name>
<state>{{device.OGChipSelectEditMenu}}</state>
</option>
<option>
<name>GenLowLevelInterface</name>
<state>0</state>
</option>
<option>
<name>GEndianModeBE</name>
<state>1</state>
</option>
<option>
<name>OGBufferedTerminalOutput</name>
<state>0</state>
</option>
<option>
<name>GenStdoutInterface</name>
<state>0</state>
</option>
<option>
<name>GeneralMisraRules98</name>
<version>0</version>
<state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
</option>
<option>
<name>GeneralMisraVer</name>
<state>0</state>
</option>
<option>
<name>GeneralMisraRules04</name>
<version>0</version>
<state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
</option>
<option>
<name>RTConfigPath2</name>
<state>$TOOLKIT_DIR$\INC\c\DLib_Config_Full.h</state>
</option>
<option>
<name>GBECoreSlave</name>
<version>24</version>
<state>{{device.GBECoreSlave}}</state>
</option>
<option>
<name>OGUseCmsis</name>
<state>0</state>
</option>
<option>
<name>OGUseCmsisDspLib</name>
<state>0</state>
</option>
<option>
<name>CoreVariant</name>
<version>24</version>
<state>{{device.CoreVariant}}</state>
</option>
<option>
<name>GFPUDeviceSlave</name>
<state></state>
</option>
<option>
<name>FPU2</name>
<version>0</version>
<state>{{device.FPU2}}</state>
</option>
<option>
<name>NrRegs</name>
<version>0</version>
<state>{{device.NrRegs}}</state>
</option>
<option>
<name>NEON</name>
<state>{{device.NEON}}</state>
</option>
<option>
<name>GFPUCoreSlave2</name>
<version>24</version>
<state>{{device.GFPUCoreSlave2}}</state>
</option>
</data>
<data>
<version>24</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>GRuntimeLibThreads</name>
<state>0</state>
</option>
<option>
<name>ExePath</name>
<state>$PROJ_DIR$\BUILD\Exe</state>
</option>
<option>
<name>ObjPath</name>
<state>$PROJ_DIR$\BUILD\Obj</state>
</option>
<option>
<name>ListPath</name>
<state>$PROJ_DIR$\BUILD\List</state>
</option>
<option>
<name>GEndianMode</name>
<state>0</state>
</option>
<option>
<name>Input variant</name>
<version>3</version>
<state>1</state>
</option>
<option>
<name>Input description</name>
<state>Full formatting.</state>
</option>
<option>
<name>Output variant</name>
<version>2</version>
<state>3</state>
</option>
<option>
<name>Output description</name>
<state>No specifier a, A.</state>
</option>
<option>
<name>GOutputBinary</name>
<state>0</state>
</option>
<option>
<name>OGCoreOrChip</name>
<state>1</state>
</option>
<option>
<name>GRuntimeLibSelect</name>
<version>0</version>
<state>2</state>
</option>
<option>
<name>GRuntimeLibSelectSlave</name>
<version>0</version>
<state>2</state>
</option>
<option>
<name>RTDescription</name>
<state>Use the full configuration of the C/C++ runtime library. Full locale interface, C locale, file descriptor support, multibytes in printf and scanf, and hex floats in strtod.</state>
</option>
<option>
<name>OGProductVersion</name>
<state>5.10.0.159</state>
</option>
<option>
<name>OGLastSavedByProductVersion</name>
<state>7.80.2.11970</state>
</option>
<option>
<name>GeneralEnableMisra</name>
<state>0</state>
</option>
<option>
<name>GeneralMisraVerbose</name>
<state>0</state>
</option>
<option>
<name>OGChipSelectEditMenu</name>
<state>{{device.OGChipSelectEditMenu}}</state>
</option>
<option>
<name>GenLowLevelInterface</name>
<state>0</state>
</option>
<option>
<name>GEndianModeBE</name>
<state>1</state>
</option>
<option>
<name>OGBufferedTerminalOutput</name>
<state>0</state>
</option>
<option>
<name>GenStdoutInterface</name>
<state>0</state>
</option>
<option>
<name>GeneralMisraRules98</name>
<version>0</version>
<state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
</option>
<option>
<name>GeneralMisraVer</name>
<state>0</state>
</option>
<option>
<name>GeneralMisraRules04</name>
<version>0</version>
<state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
</option>
<option>
<name>RTConfigPath2</name>
<state>$TOOLKIT_DIR$\INC\c\DLib_Config_Full.h</state>
</option>
<option>
<name>GBECoreSlave</name>
<version>24</version>
<state>{{device.GBECoreSlave}}</state>
</option>
<option>
<name>OGUseCmsis</name>
<state>0</state>
</option>
<option>
<name>OGUseCmsisDspLib</name>
<state>0</state>
</option>
<option>
<name>CoreVariant</name>
<version>24</version>
<state>{{device.CoreVariant}}</state>
</option>
<option>
<name>GFPUDeviceSlave</name>
<state></state>
</option>
<option>
<name>FPU2</name>
<version>0</version>
<state>{{device.FPU2}}</state>
</option>
<option>
<name>NrRegs</name>
<version>0</version>
<state>{{device.NrRegs}}</state>
</option>
<option>
<name>NEON</name>
<state>{{device.NEON}}</state>
</option>
<option>
<name>GFPUCoreSlave2</name>
<version>24</version>
<state>{{device.GFPUCoreSlave2}}</state>
</option>
</data>
</settings>
<settings>
<name>ICCARM</name>
@ -265,9 +265,9 @@
</option>
<option>
<name>IExtraOptions</name>
{% for flag in c_flags %}
{% for flag in c_flags -%}
<state>{{flag}}</state>
{% endfor %}
{% endfor -%}
</option>
<option>
<name>CCLangConformance</name>
@ -315,9 +315,9 @@
</option>
<option>
<name>CCIncludePath2</name>
{% for file in include_paths %}
{% for file in include_paths -%}
<state>{{file}}</state>
{% endfor %}
{% endfor -%}
</option>
<option>
<name>CCStdIncCheck</name>
@ -583,9 +583,9 @@
</option>
<option>
<name>AExtraOptionsV2</name>
{% for flag in asm_flags %}
<state>{{flag}}</state>
{% endfor %}
{% for flag in asm_flags -%}
<state>{{flag|escape}}</state>
{% endfor -%}
</option>
<option>
<name>AsmNoLiteralPool</name>
@ -765,9 +765,9 @@
</option>
<option>
<name>IlinkExtraOptions</name>
{% for flag in ld_flags %}
{% for flag in ld_flags -%}
<state>{{flag}}</state>
{% endfor %}
{% endfor -%}
</option>
<option>
<name>IlinkLowLevelInterfaceSlave</name>
@ -963,14 +963,12 @@
<data></data>
</settings>
</configuration>
{% for group in groups %}
<group>
<name>{{group.name}}</name>
{% for file in group.files %}
<file>
<name>{{file}}</name>
</file>
{% endfor %}
</group>
{% endfor %}
{% for group in groups -%}
<group>
<name>{{group.name}}</name>
{% for file in group.files -%}
<file> <name>{{file}}</name> </file>
{% endfor -%}
</group>
{% endfor -%}
</project>

View File

@ -125,8 +125,15 @@ class Makefile(Exporter):
ctx.update(self.format_flags())
# Add the virtual path the the include option in the ASM flags
ctx['asm_flags'] = map(lambda item: "-I" + ctx['vpath'][0] + "/" + item[2:]
if item.startswith('-I') else item, ctx['asm_flags'])
new_asm_flags = []
for flag in ctx['asm_flags']:
if flag.startswith('-I'):
new_asm_flags.append("-I{}/{}".format(ctx['vpath'][0], flag[2:]))
elif flag.startswith('--preinclude='):
new_asm_flags.append("--preinclude={}/{}".format(ctx['vpath'][0], flag[13:]))
else:
new_asm_flags.append(flag)
ctx['asm_flags'] = new_asm_flags
for templatefile in \
['makefile/%s_%s.tmpl' % (self.TEMPLATE,
@ -147,7 +154,7 @@ class Makefile(Exporter):
"""Format toolchain flags for Makefile"""
flags = {}
for k, v in self.flags.items():
if k in ['asm_flags', 'c_flags', 'cxx_flags']:
if k in ['c_flags', 'cxx_flags']:
flags[k] = map(lambda x: x.replace('"', '\\"'), v)
else:
flags[k] = v

View File

@ -187,6 +187,8 @@ def test_toolchain_profile_asm(profile, source_file):
notify=MockNotifier)
toolchain.inc_md5 = ""
toolchain.build_dir = ""
toolchain.config = MagicMock()
toolchain.config.get_config_data_macros.return_value = []
for parameter in profile['asm']:
assert any(parameter in cmd for cmd in toolchain.asm), \
"Toolchain %s did not propagate arg %s" % (toolchain.name,

View File

@ -308,50 +308,42 @@ class mbedToolchain:
mkdir(obj_dir)
return join(obj_dir, name + '.o')
# Generate response file for all includes.
# ARM, GCC, IAR cross compatible
def make_option_file(self, options, naming=".options_{}.txt"):
""" Generate a via file for a pile of defines
ARM, GCC, IAR cross compatible
"""
option_md5 = md5(' '.join(options).encode('utf-8')).hexdigest()
via_file = join(self.build_dir, naming.format(option_md5))
if not exists(via_file):
with open(via_file, "w") as fd:
string = " ".join(options)
fd.write(string)
return via_file
def get_inc_file(self, includes):
include_file = join(self.build_dir, ".includes_%s.txt" % self.inc_md5)
if not exists(include_file):
with open(include_file, "w") as f:
cmd_list = []
for c in includes:
if c:
c = c.replace("\\", "/")
if self.CHROOT:
c = c.replace(self.CHROOT, '')
cmd_list.append('"-I%s"' % c)
string = " ".join(cmd_list)
f.write(string)
return include_file
"""Generate a via file for all includes.
ARM, GCC, IAR cross compatible
"""
cmd_list = ("-I{}".format(c.replace("\\", "/")) for c in includes if c)
if self.CHROOT:
cmd_list = (c.replace(self.CHROOT, '') for c in cmd_list)
return self.make_option_file(list(cmd_list), naming=".includes_{}.txt")
# Generate response file for all objects when linking.
# ARM, GCC, IAR cross compatible
def get_link_file(self, cmd):
link_file = join(self.build_dir, ".link_files.txt")
with open(link_file, "w") as f:
cmd_list = []
for c in cmd:
if c:
c = c.replace("\\", "/")
if self.CHROOT:
c = c.replace(self.CHROOT, '')
cmd_list.append(('"%s"' % c) if not c.startswith('-') else c)
string = " ".join(cmd_list)
f.write(string)
return link_file
"""Generate a via file for all objects when linking.
ARM, GCC, IAR cross compatible
"""
cmd_list = (c.replace("\\", "/") for c in cmd if c)
if self.CHROOT:
cmd_list = (c.replace(self.CHROOT, '') for c in cmd_list)
return self.make_option_file(list(cmd_list), naming=".link_options.txt")
# Generate response file for all objects when archiving.
# ARM, GCC, IAR cross compatible
def get_arch_file(self, objects):
archive_file = join(self.build_dir, ".archive_files.txt")
with open(archive_file, "w") as f:
o_list = []
for o in objects:
o_list.append('"%s"' % o)
string = " ".join(o_list).replace("\\", "/")
f.write(string)
return archive_file
""" Generate a via file for all objects when archiving.
ARM, GCC, IAR cross compatible
"""
cmd_list = (c.replace("\\", "/") for c in objects if c)
return self.make_option_file(list(cmd_list), ".archive_files.txt")
# THIS METHOD IS BEING CALLED BY THE MBED ONLINE BUILD SYSTEM
# ANY CHANGE OF PARAMETERS OR RETURN VALUES WILL BREAK COMPATIBILITY

View File

@ -175,6 +175,9 @@ class ARM(mbedToolchain):
def get_compile_options(self, defines, includes, for_asm=False):
opts = ['-D%s' % d for d in defines]
config_header = self.get_config_header()
if config_header is not None:
opts = opts + self.get_config_option(config_header)
if for_asm:
return opts
if self.RESPONSE_FILES:
@ -182,9 +185,6 @@ class ARM(mbedToolchain):
else:
opts += ["-I%s" % i for i in includes]
config_header = self.get_config_header()
if config_header is not None:
opts = opts + self.get_config_option(config_header)
return opts
@hook_tool

View File

@ -180,10 +180,9 @@ class GCC(mbedToolchain):
else:
opts += ["-I%s" % i for i in includes]
if not for_asm:
config_header = self.get_config_header()
if config_header is not None:
opts = opts + self.get_config_option(config_header)
config_header = self.get_config_header()
if config_header is not None:
opts = opts + self.get_config_option(config_header)
return opts
@hook_tool

View File

@ -165,17 +165,26 @@ class IAR(mbedToolchain):
def get_compile_options(self, defines, includes, for_asm=False):
opts = ['-D%s' % d for d in defines]
if for_asm :
if for_asm:
config_macros = self.config.get_config_data_macros()
macros_cmd = ['"-D%s"' % d.replace('"', '') for d in config_macros]
if self.RESPONSE_FILES:
via_file = self.make_option_file(
macros_cmd, "asm_macros_{}.xcl")
opts += ['-f', via_file]
else:
opts += macros_cmd
return opts
if self.RESPONSE_FILES:
opts += ['-f', self.get_inc_file(includes)]
else:
opts += ["-I%s" % i for i in includes]
if self.RESPONSE_FILES:
opts += ['-f', self.get_inc_file(includes)]
else:
opts += ["-I%s" % i for i in includes]
config_header = self.get_config_header()
if config_header is not None:
opts = opts + self.get_config_option(config_header)
config_header = self.get_config_header()
if config_header is not None:
opts = opts + self.get_config_option(config_header)
return opts
return opts
@hook_tool
def assemble(self, source, object, includes):