Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors many exporters to use toolchain flags #1872

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/export/atmelstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def generate(self):
'solution_uuid': solution_uuid.upper(),
'project_uuid': project_uuid.upper()
}
ctx.update(self.progen_flags)
target = self.target.lower()
self.gen_file('atmelstudio6_2.atsln.tmpl', ctx, '%s.atsln' % self.program_name)
self.gen_file('atmelstudio6_2.cppproj.tmpl', ctx, '%s.cppproj' % self.program_name)
14 changes: 7 additions & 7 deletions tools/export/atmelstudio6_2.cppproj.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<armgcc.compiler.optimization.level>Optimize for size (-Os)</armgcc.compiler.optimization.level>
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP</armgcc.compiler.miscellaneous.OtherFlags>
<armgcc.compiler.miscellaneous.OtherFlags>{{c_flags|join(" ")}} {{common_flags|join(" ")}} -MMD -MP</armgcc.compiler.miscellaneous.OtherFlags>
<armgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
Expand All @@ -77,7 +77,7 @@
<armgcccpp.compiler.optimization.level>Optimize for size (-Os)</armgcccpp.compiler.optimization.level>
<armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcccpp.compiler.warnings.AllWarnings>True</armgcccpp.compiler.warnings.AllWarnings>
<armgcccpp.compiler.miscellaneous.OtherFlags>-std=gnu++98 -fno-rtti -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP</armgcccpp.compiler.miscellaneous.OtherFlags>
<armgcccpp.compiler.miscellaneous.OtherFlags>{{cxx_flags|join(" ")}} {{common_flags|join(" ")}} -MMD -MP</armgcccpp.compiler.miscellaneous.OtherFlags>
<armgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
Expand All @@ -88,7 +88,7 @@
</ListValues>
</armgcccpp.linker.libraries.LibrarySearchPaths>
<armgcccpp.linker.optimization.GarbageCollectUnusedSections>True</armgcccpp.linker.optimization.GarbageCollectUnusedSections>
<armgcccpp.linker.miscellaneous.LinkerFlags>{% for p in library_paths %}-L../{{p}} {% endfor %} {% for f in object_files %}../{{f}} {% endfor %} {% for lib in libraries %}-l{{lib}} {% endfor %} -T../{{linker_script}} -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,--cref -lstdc++ -lsupc++ -lm -lgcc -Wl,--start-group -lc -lc -lnosys -Wl,--end-group </armgcccpp.linker.miscellaneous.LinkerFlags>
<armgcccpp.linker.miscellaneous.LinkerFlags>{% for p in library_paths %}-L../{{p}} {% endfor %} {% for f in object_files %}../{{f}} {% endfor %} {% for lib in libraries %}-l{{lib}} {% endfor %} -T../{{linker_script}} {{ld_flags|join(" ")}} {{common_flags|join(" ")}}</armgcccpp.linker.miscellaneous.LinkerFlags>
<armgcccpp.preprocessingassembler.general.IncludePaths>
<ListValues>
{% for i in include_paths %}<Value>../{{i}}</Value>
Expand Down Expand Up @@ -123,7 +123,7 @@
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
<armgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP</armgcc.compiler.miscellaneous.OtherFlags>
<armgcc.compiler.miscellaneous.OtherFlags>{{c_flags|join(" ")}} {{common_flags|join(" ")}} -MMD -MP</armgcc.compiler.miscellaneous.OtherFlags>
<armgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
Expand All @@ -141,7 +141,7 @@
<armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcccpp.compiler.optimization.DebugLevel>Maximum (-g3)</armgcccpp.compiler.optimization.DebugLevel>
<armgcccpp.compiler.warnings.AllWarnings>True</armgcccpp.compiler.warnings.AllWarnings>
<armgcccpp.compiler.miscellaneous.OtherFlags>-std=gnu++98 -fno-rtti -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP</armgcccpp.compiler.miscellaneous.OtherFlags>
<armgcccpp.compiler.miscellaneous.OtherFlags>{{cxx_flags|join(" ")}} {{common_flags|join(" ")}} -MMD -MP</armgcccpp.compiler.miscellaneous.OtherFlags>
<armgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
Expand All @@ -152,7 +152,7 @@
</ListValues>
</armgcccpp.linker.libraries.LibrarySearchPaths>
<armgcccpp.linker.optimization.GarbageCollectUnusedSections>True</armgcccpp.linker.optimization.GarbageCollectUnusedSections>
<armgcccpp.linker.miscellaneous.LinkerFlags>{% for p in library_paths %}-L../{{p}} {% endfor %} {% for f in object_files %}../{{f}} {% endfor %} {% for lib in libraries %}-l{{lib}} {% endfor %} -T../{{linker_script}} -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,--cref -lstdc++ -lsupc++ -lm -lgcc -Wl,--start-group -lc -lc -lnosys -Wl,--end-group </armgcccpp.linker.miscellaneous.LinkerFlags>
<armgcccpp.linker.miscellaneous.LinkerFlags>{% for p in library_paths %}-L../{{p}} {% endfor %} {% for f in object_files %}../{{f}} {% endfor %} {% for lib in libraries %}-l{{lib}} {% endfor %} -T../{{linker_script}} {{ld_flags|join(" ")}} {{common_flags|join(" ")}}</armgcccpp.linker.miscellaneous.LinkerFlags>
<armgcccpp.assembler.debugging.DebugLevel>Default (-g)</armgcccpp.assembler.debugging.DebugLevel>
<armgcccpp.preprocessingassembler.general.IncludePaths>
<ListValues>
Expand All @@ -173,4 +173,4 @@
{% endfor %}
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>
</Project>
1 change: 1 addition & 0 deletions tools/export/codered.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ def generate(self):
'libraries': libraries,
'symbols': self.get_symbols()
}
ctx.update(self.progen_flags)
self.gen_file('codered_%s_project.tmpl' % self.target.lower(), ctx, '.project')
self.gen_file('codered_%s_cproject.tmpl' % self.target.lower(), ctx, '.cproject')
12 changes: 6 additions & 6 deletions tools/export/codered_cproject_common.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<listOptionValue builtIn="false" value="{{s}}"/>
{% endfor %}
</option>
<option id="gnu.cpp.compiler.option.other.other.1100343989" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti" valueType="string"/>
<option id="gnu.cpp.compiler.option.other.other.1100343989" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c {{cxx_flags|join(" ")}} {{common_flags|join(" ")}}" valueType="string"/>

<option id="gnu.cpp.compiler.option.include.paths.1011871574" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
{% for path in include_paths %}
Expand All @@ -56,7 +56,7 @@
<listOptionValue builtIn="false" value="{{s}}"/>
{% endfor %}
</option>
<option id="gnu.c.compiler.option.misc.other.1521041525" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti" valueType="string"/>
<option id="gnu.c.compiler.option.misc.other.1521041525" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c {{c_flags|join(" ")}} {{common_flags|join(" ")}}" valueType="string"/>

<option id="gnu.c.compiler.option.include.paths.1293117680" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
{% for path in include_paths %}
Expand All @@ -69,7 +69,7 @@
<tool id="com.crt.advproject.gas.exe.debug.1277199919" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug">
<option id="com.crt.advproject.gas.arch.1079400011" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.{{ self.core() }}" valueType="enumerated"/>
<option id="com.crt.advproject.gas.thumb.1976113150" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="gnu.both.asm.option.flags.crt.1501250871" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__NEWLIB__ -DDEBUG -D__CODE_RED " valueType="string"/>
<option id="gnu.both.asm.option.flags.crt.1501250871" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c {{asm_flags|join(" ")}} {{common_flags|join(" ")}} -D__NEWLIB__ -DDEBUG -D__CODE_RED " valueType="string"/>
<option id="com.crt.advproject.gas.hdrlib.473313643" name="Use headers for C library" superClass="com.crt.advproject.gas.hdrlib" value="com.crt.advproject.gas.hdrlib.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.assembler.input.910682278" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
Expand Down Expand Up @@ -949,7 +949,7 @@
<listOptionValue builtIn="false" value="{{s}}"/>
{% endfor %}
</option>
<option id="gnu.cpp.compiler.option.other.other.1338090461" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti" valueType="string"/>
<option id="gnu.cpp.compiler.option.other.other.1338090461" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c {{cxx_flags|join(" ")}} {{common_flags|join(" ")}}" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.475225500" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" value="-Os" valueType="string"/>

<option id="gnu.cpp.compiler.option.include.paths.17539784" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
Expand All @@ -972,14 +972,14 @@
<listOptionValue builtIn="false" value="{{s}}"/>
{% endfor %}
</option>
<option id="gnu.c.compiler.option.misc.other.2015545820" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti" valueType="string"/>
<option id="gnu.c.compiler.option.misc.other.2015545820" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c {{c_flags|join(" ")}} {{common_flags|join(" ")}}" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.675461365" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" value="-Os" valueType="string"/>
<inputType id="com.crt.advproject.compiler.input.1938378962" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.exe.release.579950187" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.release">
<option id="com.crt.advproject.gas.arch.1401271875" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.{{ self.core() }}" valueType="enumerated"/>
<option id="com.crt.advproject.gas.thumb.1024544278" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="gnu.both.asm.option.flags.crt.637466836" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__NEWLIB__ -DNDEBUG -D__CODE_RED " valueType="string"/>
<option id="gnu.both.asm.option.flags.crt.637466836" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c {{asm_flags|join(" ")}} {{common_flags|join(" ")}} -D__NEWLIB__ -DNDEBUG -D__CODE_RED " valueType="string"/>
<option id="com.crt.advproject.gas.hdrlib.492600365" name="Use headers for C library" superClass="com.crt.advproject.gas.hdrlib" value="com.crt.advproject.gas.hdrlib.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.assembler.input.812068162" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
Expand Down
6 changes: 3 additions & 3 deletions tools/export/emblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def generate(self):
'symbols': self.get_symbols(),
'object_files': self.resources.objects,
'sys_libs': self.toolchain.sys_libs,
'cc_org': self.toolchain.cc[1:],
'ld_org': self.toolchain.ld[1:],
'cppc_org': self.toolchain.cppc[1:]
'cc_org': self.flags['common'] + self.flags['c'],
'ld_org': self.flags['common'] + self.flags['ld'],
'cppc_org': self.flags['common'] + self.flags['cxx']
}

# EmBlocks intermediate file template
Expand Down
10 changes: 10 additions & 0 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def __init__(self, target, inputDir, program_name, build_url_resolver, extra_sym
def get_toolchain(self):
return self.TOOLCHAIN

@property
def flags(self):
return self.toolchain.flags

@property
def progen_flags(self):
if not hasattr(self, "_progen_flag_cache") :
self._progen_flag_cache = dict([(key + "_flags", value) for key,value in self.flags.iteritems()])
return self._progen_flag_cache

def __scan_and_copy(self, src_path, trg_path):
resources = self.toolchain.scan_resources(src_path)

Expand Down
23 changes: 9 additions & 14 deletions tools/export/gcc_arm_common.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,12 @@ endif
{%- endblock %}

CPU = {% block cpu %}{% for cf in cpu_flags %}{{cf|replace("-mfloat-abi=softfp","-mfloat-abi=$(FLOAT_ABI)")}} {% endfor %}{% endblock %}
CC_FLAGS = {% block cc_flags %}$(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP{% endblock %}
CC_FLAGS = {% block cc_flags %}{{common_flags|join(" ")}} {{c_flags|join(" ")}} -MMD -MP{% endblock %}
CPPC_FLAGS = {% block cppc_flags %}{{common_flags|join(" ")}} {{cxx_flags|join(" ")}} -MMD -MP{% endblock %}
ASM_FLAGS = {% block asm_flags %}{{asm_flags|join(" ")}} {{common_flags|join(" ")}}{% endblock %}
CC_SYMBOLS = {% block cc_symbols %}{% for s in symbols %}-D{{s}} {% endfor %}{% endblock %}

LD_FLAGS = {%- block ld_flags -%}
{%- if "-mcpu=cortex-m0" in cpu_flags or "-mcpu=cortex-m0plus" in cpu_flags -%}
{{ ' ' }}$(CPU) -Wl,--gc-sections --specs=nano.specs -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref
#LD_FLAGS += -u _printf_float -u _scanf_float
{%- else -%}
{{ ' ' }}$(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref
{%- endif -%}
{% endblock %}
LD_FLAGS = {%- block ld_flags -%} {{ld_flags|join(" ")}} {% endblock %}
LD_SYS_LIBS = {% block ld_sys_libs %}-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys{% endblock %}
{% endblock %}

Expand All @@ -66,17 +61,17 @@ clean:
{% endblock %}

.asm.o:
$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<
.s.o:
$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<
.S.o:
$(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<
$(CC) $(CPU) -c $(ASM_FLAGS) -o $@ $<

.c.o:
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<
$(CC) $(CC_FLAGS) $(CC_SYMBOLS) $(INCLUDE_PATHS) -o $@ $<

.cpp.o:
$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
$(CPP) $(CPPC_FLAGS) $(CC_SYMBOLS) $(INCLUDE_PATHS) -o $@ $<


{% block target_project_elf %}
Expand Down
1 change: 1 addition & 0 deletions tools/export/gccarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,5 @@ def generate(self):
'symbols': self.get_symbols(),
'cpu_flags': self.toolchain.cpu
}
ctx.update(self.progen_flags)
self.gen_file('gcc_arm_%s.tmpl' % self.target.lower(), ctx, 'Makefile')
2 changes: 2 additions & 0 deletions tools/export/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def generate(self):
}

project_data['tool_specific'] = {}
project_data['tool_specific'].setdefault("iar", {})
project_data['tool_specific']['iar'].update(self.progen_flags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flags should be in misc, I got a local patch, IAR builds! will send another PR on top of this one.

project_data['tool_specific'].update(tool_specific)
project_data['common']['build_dir'] = os.path.join(project_data['common']['build_dir'], 'iar_arm')
self.progen_gen_file('iar_arm', project_data)
Expand Down
1 change: 1 addition & 0 deletions tools/export/simplicityv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def generate(self):
'kit': self.KITS[self.target],
'loopcount': 0
}
ctx.update(self.progen_flags)

## Strip main folder from include paths because ssproj is not capable of handling it
if '.' in ctx['include_paths']:
Expand Down
Loading