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
Jaakko Heikkilä 2017-09-06 12:41:11 +03:00
parent e1d163ba0a
commit 9d386b23e4
3 changed files with 30 additions and 17 deletions

View File

@ -313,6 +313,12 @@ class Sw4STM32(GNUARMEclipse):
item = opts['ld']['flags'][index] item = opts['ld']['flags'][index]
if not item.startswith('-Wl,'): if not item.startswith('-Wl,'):
opts['ld']['flags'][index] = '-Wl,' + item 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): def generate(self):
""" """
@ -349,8 +355,9 @@ class Sw4STM32(GNUARMEclipse):
self.cpp_defines = self.c_defines self.cpp_defines = self.c_defines
print 'Symbols: {0}'.format(len(self.c_defines)) print 'Symbols: {0}'.format(len(self.c_defines))
self.include_path = [self.filter_dot(s) self.include_path = []
for s in self.resources.inc_dirs] for s in self.resources.inc_dirs:
self.include_path.append("../" + self.filter_dot(s))
print ('Include folders: {0}'.format(len(self.include_path))) print ('Include folders: {0}'.format(len(self.include_path)))
self.compute_exclusions() self.compute_exclusions()
@ -362,6 +369,15 @@ class Sw4STM32(GNUARMEclipse):
lib_dirs = [self.filter_dot(s) for s in self.resources.lib_dirs] 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']: for id in ['debug', 'release']:
opts = {} opts = {}
opts['common'] = {} opts['common'] = {}
@ -407,13 +423,6 @@ class Sw4STM32(GNUARMEclipse):
self.process_sw_options(opts, flags) 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['c']['defines'] = self.c_defines
opts['cpp']['defines'] = self.cpp_defines opts['cpp']['defines'] = self.cpp_defines
@ -447,7 +456,7 @@ class Sw4STM32(GNUARMEclipse):
'libraries': libraries, 'libraries': libraries,
'board_name': self.BOARDS[self.target.upper()]['name'], 'board_name': self.BOARDS[self.target.upper()]['name'],
'mcu_name': self.BOARDS[self.target.upper()]['mcuId'], 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
'cpp_cmd': " ".join(self.toolchain.preproc), 'cpp_cmd': preproc_cmd,
'options': options, 'options': options,
# id property of 'u' will generate new random identifier every time # id property of 'u' will generate new random identifier every time
# when called. # when called.

View File

@ -16,7 +16,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <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 &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${ProjName}.bin&quot; &amp;&amp; arm-none-eabi-size -B &quot;${BuildArtifactFileName}&quot; &amp;&amp; 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 &quot;${BuildArtifactFileBaseName}.elf&quot; &quot;${ProjName}.bin&quot; &amp;&amp; arm-none-eabi-size -B &quot;${BuildArtifactFileName}&quot; &amp;&amp; make ldclean" preannouncebuildStep="Creating makefile.defs:" prebuildStep="echo &quot;export PREPROC_CMD = ${openstm32_compiler_path}/${compiler_prefix}cpp -E -P&quot; &gt; ${ProjDirPath}/makefile.defs">
<folderInfo id="fr.ac6.managedbuild.config.gnu.cross.exe.{{cfg_id}}.{{opts['uid']['config']}}." name="/" resourcePath=""> <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}}"> <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"/> <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 %} {% 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"> <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 %} {% for path in include_paths %}
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/> <listOptionValue builtIn="false" value="&quot;{{path}}&quot;"/>
{% endfor %} {% endfor %}
</option> </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"> <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 %} {% endif %}
<option id="gnu.cpp.compiler.option.include.paths.{{u.id}}" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> <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 %} {% for path in include_paths %}
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/> <listOptionValue builtIn="false" value="&quot;{{path}}&quot;"/>
{% endfor %} {% endfor %}
</option> </option>
<option id="gnu.cpp.compiler.option.preprocessor.def.{{u.id}}" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> <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>
<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"> <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"/> <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'] != '' %} {% 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(' ') }}" valueType="string"/> <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 %} {% endif %}
<option id="gnu.cpp.link.option.userobjs.{{u.id}}" name="Other objects" superClass="gnu.cpp.link.option.userobjs" valueType="userObjs"> <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 %} {% 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"> <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"> <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 %} {% for path in include_paths %}
<listOptionValue builtIn="false" value="&quot;${ProjDirPath}/{{path}}&quot;"/> <listOptionValue builtIn="false" value="&quot;{{path}}&quot;"/>
{% endfor %} {% endfor %}
</option> </option>
<option id="gnu.both.asm.option.flags.{{u.id}}" superClass="gnu.both.asm.option.flags" useByScannerDiscovery="false" value="{{opts['as']['other']}}" valueType="string"/> <option id="gnu.both.asm.option.flags.{{u.id}}" superClass="gnu.both.asm.option.flags" useByScannerDiscovery="false" value="{{opts['as']['other']}}" valueType="string"/>

View File

@ -1,5 +1,9 @@
# DO NOT REMOVE! Generated by the SW4STM32 exporter from the mbed project. # DO NOT REMOVE! Generated by the SW4STM32 exporter from the mbed project.
ifeq ($(strip $(PREPROC_CMD)),)
PREPROC_CMD := {{cpp_cmd}}
endif
ldclean: ldclean:
{% for config, opts in options.iteritems() %} {% for config, opts in options.iteritems() %}
$(RM) {{opts['ld']['script']}} $(RM) {{opts['ld']['script']}}
@ -7,7 +11,7 @@ ldclean:
{% for config, opts in options.iteritems() %} {% for config, opts in options.iteritems() %}
{{opts['ld']['script']}}: ../{{ld_script}} {{opts['ld']['script']}}: ../{{ld_script}}
{{cpp_cmd}} {{opts.ld.other}} $< -o $@ $(PREPROC_CMD) {{opts.ld.other}} $< -o $@
{{name}}-{{config}}.elf: {{opts['ld']['script']}} {{name}}-{{config}}.elf: {{opts['ld']['script']}}