mirror of https://github.com/ARMmbed/mbed-os.git
export: Fix Windows problems with Sw4STM32
Quoting linker preprocessor command, if path contains parentheses. Using relative path to shorten list of included directories. Using Eclipse variables to get path to preprocessor.pull/4779/head
parent
e1d163ba0a
commit
9d386b23e4
|
@ -313,6 +313,12 @@ class Sw4STM32(GNUARMEclipse):
|
|||
item = opts['ld']['flags'][index]
|
||||
if not item.startswith('-Wl,'):
|
||||
opts['ld']['flags'][index] = '-Wl,' + item
|
||||
# Assembler options
|
||||
for as_def in self.as_defines:
|
||||
if '=' in as_def:
|
||||
opts['as']['other'] += ' --defsym ' + as_def
|
||||
else:
|
||||
opts['as']['other'] += ' --defsym ' + as_def + '=1'
|
||||
|
||||
def generate(self):
|
||||
"""
|
||||
|
@ -349,8 +355,9 @@ class Sw4STM32(GNUARMEclipse):
|
|||
self.cpp_defines = self.c_defines
|
||||
print 'Symbols: {0}'.format(len(self.c_defines))
|
||||
|
||||
self.include_path = [self.filter_dot(s)
|
||||
for s in self.resources.inc_dirs]
|
||||
self.include_path = []
|
||||
for s in self.resources.inc_dirs:
|
||||
self.include_path.append("../" + self.filter_dot(s))
|
||||
print ('Include folders: {0}'.format(len(self.include_path)))
|
||||
|
||||
self.compute_exclusions()
|
||||
|
@ -362,6 +369,15 @@ class Sw4STM32(GNUARMEclipse):
|
|||
|
||||
lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs]
|
||||
|
||||
preproc_cmd = ""
|
||||
# Hack for Windows. Build fails if command contains parentheses.
|
||||
if ('(' in self.toolchain.preproc[0] or ')' in self.toolchain.preproc[0]) and self.toolchain.preproc[0][0] != "'":
|
||||
preproc_cmd = '"' + \
|
||||
self.toolchain.preproc[0] + '"' + " " + \
|
||||
" ".join(self.toolchain.preproc[1:])
|
||||
else:
|
||||
preproc_cmd = " ".join(self.toolchain.preproc)
|
||||
|
||||
for id in ['debug', 'release']:
|
||||
opts = {}
|
||||
opts['common'] = {}
|
||||
|
@ -407,13 +423,6 @@ class Sw4STM32(GNUARMEclipse):
|
|||
|
||||
self.process_sw_options(opts, flags)
|
||||
|
||||
if opts['as']['usepreprocessor']:
|
||||
opts['as']['other'] += ' -x assembler-with-cpp'
|
||||
for as_def in self.as_defines:
|
||||
if '=' in as_def:
|
||||
opts['as']['other'] += ' -Wa,--defsym ' + as_def
|
||||
else:
|
||||
opts['as']['other'] += ' -Wa,--defsym ' + as_def + '=1'
|
||||
opts['c']['defines'] = self.c_defines
|
||||
opts['cpp']['defines'] = self.cpp_defines
|
||||
|
||||
|
@ -447,7 +456,7 @@ class Sw4STM32(GNUARMEclipse):
|
|||
'libraries': libraries,
|
||||
'board_name': self.BOARDS[self.target.upper()]['name'],
|
||||
'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
|
||||
'cpp_cmd': " ".join(self.toolchain.preproc),
|
||||
'cpp_cmd': preproc_cmd,
|
||||
'options': options,
|
||||
# id property of 'u' will generate new random identifier every time
|
||||
# when called.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}-{{cfg_id}}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.{{cfg_id}}" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.{{cfg_id}}.{{opts['uid']['config']}}" name="{{opts['name']}}" parent="fr.ac6.managedbuild.config.gnu.cross.exe.{{cfg_id}}" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${ProjName}.bin" && arm-none-eabi-size -B "${BuildArtifactFileName}" && make ldclean">
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}-{{cfg_id}}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.{{cfg_id}}" cleanCommand="rm -rf" description="" id="fr.ac6.managedbuild.config.gnu.cross.exe.{{cfg_id}}.{{opts['uid']['config']}}" name="{{opts['name']}}" parent="fr.ac6.managedbuild.config.gnu.cross.exe.{{cfg_id}}" postannouncebuildStep="Generating binary and Printing size information:" postbuildStep="arm-none-eabi-objcopy -O binary "${BuildArtifactFileBaseName}.elf" "${ProjName}.bin" && arm-none-eabi-size -B "${BuildArtifactFileName}" && make ldclean" preannouncebuildStep="Creating makefile.defs:" prebuildStep="echo "export PREPROC_CMD = ${openstm32_compiler_path}/${compiler_prefix}cpp -E -P" > ${ProjDirPath}/makefile.defs">
|
||||
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.{{cfg_id}}.{{opts['uid']['config']}}." name="/" resourcePath="">
|
||||
<toolChain id="fr.ac6.managedbuild.toolchain.gnu.cross.exe.{{cfg_id}}.{{u.id}}" name="Ac6 STM32 MCU GCC" superClass="fr.ac6.managedbuild.toolchain.gnu.cross.exe.{{cfg_id}}">
|
||||
<option id="fr.ac6.managedbuild.option.gnu.cross.mcu.{{u.id}}" name="Mcu" superClass="fr.ac6.managedbuild.option.gnu.cross.mcu" value="{{mcu_name}}" valueType="string"/>
|
||||
|
@ -39,7 +39,7 @@
|
|||
{% endif %}
|
||||
<option id="gnu.c.compiler.option.include.paths.{{u.id}}" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
|
||||
{% for path in include_paths %}
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{path}}""/>
|
||||
<listOptionValue builtIn="false" value=""{{path}}""/>
|
||||
{% endfor %}
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.{{u.id}}" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
|
@ -124,7 +124,7 @@
|
|||
{% endif %}
|
||||
<option id="gnu.cpp.compiler.option.include.paths.{{u.id}}" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||
{% for path in include_paths %}
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{path}}""/>
|
||||
<listOptionValue builtIn="false" value=""{{path}}""/>
|
||||
{% endfor %}
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.preprocessor.def.{{u.id}}" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols">
|
||||
|
@ -196,8 +196,8 @@
|
|||
</tool>
|
||||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.{{u.id}}" name="MCU G++ Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<option id="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.script.{{u.id}}" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.cpp.linker.script" value="${ProjDirPath}/{{opts['name']}}/{{opts['ld']['script']}}" valueType="string"/>
|
||||
{% if opts['ld']['flags'] != '' %}
|
||||
<option id="gnu.cpp.link.option.flags.{{u.id}}" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="{{ opts['ld']['flags']|join(' ') }}" valueType="string"/>
|
||||
{% if opts['ld']['flags'] != '' or opts['ld']['other'] != '' %}
|
||||
<option id="gnu.cpp.link.option.flags.{{u.id}}" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="{{ opts['ld']['flags']|join(' ') }} {{opts['ld']['other']}}" valueType="string"/>
|
||||
{% endif %}
|
||||
<option id="gnu.cpp.link.option.userobjs.{{u.id}}" name="Other objects" superClass="gnu.cpp.link.option.userobjs" valueType="userObjs">
|
||||
{% for path in object_files %}
|
||||
|
@ -256,7 +256,7 @@
|
|||
<tool id="fr.ac6.managedbuild.tool.gnu.cross.assembler.{{u.id}}" name="MCU GCC Assembler" superClass="fr.ac6.managedbuild.tool.gnu.cross.assembler">
|
||||
<option id="gnu.both.asm.option.include.paths.{{u.id}}" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||
{% for path in include_paths %}
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/{{path}}""/>
|
||||
<listOptionValue builtIn="false" value=""{{path}}""/>
|
||||
{% endfor %}
|
||||
</option>
|
||||
<option id="gnu.both.asm.option.flags.{{u.id}}" superClass="gnu.both.asm.option.flags" useByScannerDiscovery="false" value="{{opts['as']['other']}}" valueType="string"/>
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# DO NOT REMOVE! Generated by the SW4STM32 exporter from the mbed project.
|
||||
|
||||
ifeq ($(strip $(PREPROC_CMD)),)
|
||||
PREPROC_CMD := {{cpp_cmd}}
|
||||
endif
|
||||
|
||||
ldclean:
|
||||
{% for config, opts in options.iteritems() %}
|
||||
$(RM) {{opts['ld']['script']}}
|
||||
|
@ -7,7 +11,7 @@ ldclean:
|
|||
|
||||
{% for config, opts in options.iteritems() %}
|
||||
{{opts['ld']['script']}}: ../{{ld_script}}
|
||||
{{cpp_cmd}} {{opts.ld.other}} $< -o $@
|
||||
$(PREPROC_CMD) {{opts.ld.other}} $< -o $@
|
||||
|
||||
{{name}}-{{config}}.elf: {{opts['ld']['script']}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue