Skip to content

Commit 9fe172d

Browse files
committed
libraries addition, link command correction
1 parent df403f2 commit 9fe172d

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

workspace_tools/export/coide.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,22 @@
2020

2121
class CoIDE(Exporter):
2222
NAME = 'CoIDE'
23+
FILE_TYPES = {
24+
'c_sources':'1',
25+
'cpp_sources':'8',
26+
's_sources':'2'
27+
}
2328
TARGETS = ['KL25Z']
2429
TOOLCHAIN = 'GCC_ARM'
2530

2631
def generate(self):
27-
to_be_compiled = []
28-
for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
29-
r = getattr(self.resources, r_type)
30-
if r:
31-
for source in r:
32-
base, ext = splitext(source)
33-
to_be_compiled.append(base + '.o')
32+
self.resources.win_to_unix()
33+
source_files = []
34+
for r_type, n in CoIDE.FILE_TYPES.iteritems():
35+
for file in getattr(self.resources, r_type):
36+
source_files.append({
37+
'name': basename(file), 'path': file
38+
})
3439

3540
libraries = []
3641
for lib in self.resources.libraries:
@@ -39,14 +44,14 @@ def generate(self):
3944

4045
ctx = {
4146
'name': self.program_name,
42-
'to_be_compiled': to_be_compiled,
47+
'source_files': source_files,
4348
'include_paths': self.resources.inc_dirs,
44-
'library_paths': self.resources.lib_dirs,
4549
'scatter_file': self.resources.linker_script,
4650
'object_files': self.resources.objects,
51+
'libraries': libraries,
4752
'symbols': self.toolchain.get_symbols()
4853
}
4954
target = self.target.lower()
5055

5156
# Project file
52-
self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '.coproj')
57+
self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '%s.coproj' % self.program_name)

workspace_tools/export/coide_kl25z.coproj.tmpl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
<Device manufacturerId="4" manufacturerName="Freescale" chipId="86" chipName="MKL25Z128VLK4" boardId="" boardName=""/>
55
<BuildOption>
66
<Compile>
7-
<Option name="OptimizationLevel" value="0"/>
7+
<Option name="OptimizationLevel" value="4"/>
88
<Option name="UseFPU" value="0"/>
9-
<Option name="UserEditCompiler" value="-Wl, --specs=nano.specs -fno-common; -fmessage-length=0; -Wall; -fno-exceptions; -ffunction-sections; -fdata-sections; {% for s in symbols %}-D{{s}}; {% endfor %} -std=gnu++98"/>
9+
<Option name="UserEditCompiler" value="-fno-common; -fmessage-length=0; -Wall; -fno-strict-aliasing; -fno-rtti; -fno-exceptions; -ffunction-sections; -fdata-sections; -std=gnu++98"/>
1010
<Includepaths>
11-
<Includepath path="."/>
12-
<Includepath path="mbed"/>
13-
<Includepath path="mbed/target_kl25z"/>
14-
<Includepath path="mbed/target_kl25z/toolchain_gcc_arm"/>
11+
{% for path in include_paths %} <Includepath path="{{path}}"/> {% endfor %}
1512
</Includepaths>
1613
<DefinedSymbols>
17-
<Define name="MKL25Z128VLK4"/>
14+
{% for s in symbols %} <Define name="{{s}}"/> {% endfor %}
1815
</DefinedSymbols>
1916
</Compile>
2017
<Link useDefault="0">
@@ -25,15 +22,16 @@
2522
<Option name="IsNewStartupCode" value="1"/>
2623
<Option name="Library" value="Not use C Library"/>
2724
<Option name="nostartfiles" value="0"/>
28-
<Option name="UserEditLinker" value="C:/CooCox/CoIDE/workspace/{{name}}/mbed/target_kl25z/toolchain_gcc_arm/cmsis_nvic.o; C:/CooCox/CoIDE/workspace/{{name}}/mbed/target_kl25z/toolchain_gcc_arm/retarget.o; C:/CooCox/CoIDE/workspace/{{name}}/mbed/target_kl25z/toolchain_gcc_arm/startup_MKL25Z4.o; C:/CooCox/CoIDE/workspace/{{name}}/mbed/target_kl25z/toolchain_gcc_arm/system_MKL25Z4.o; -lmbed; -lstdc++; -lsupc++; -lm; -lc; -lgcc; -lnosys; -lmbed; -lstdc++; -lsupc++; -lm; -lc; -lgcc; -lnosys; "/>
25+
<Option name="UserEditLinker" value="--specs=nano.specs; -u _printf_float; -u _scanf_float; {% for file in object_files %}
26+
${project.path}/{{file}}; {% endfor %} {% for lib in libraries %} -l{{lib}}; {% endfor %} -lstdc++; -lsupc++; -lm; -lc; -lgcc; -lnosys;"/>
2927
<LinkedLibraries/>
3028
<MemoryAreas debugInFlashNotRAM="1">
3129
<Memory name="IROM1" type="ReadOnly" size="0x00020000" startValue="0x00000000"/>
3230
<Memory name="IRAM1" type="ReadWrite" size="0x00001000" startValue="0x1FFFF000"/>
3331
<Memory name="IROM2" type="ReadOnly" size="" startValue=""/>
3432
<Memory name="IRAM2" type="ReadWrite" size="" startValue=""/>
3533
</MemoryAreas>
36-
<LocateLinkFile path="mbed/target_kl25z/toolchain_gcc_arm/mkl25z4.ld" type="0"/>
34+
<LocateLinkFile path="{{scatter_file}}" type="0"/>
3735
</Link>
3836
<Output>
3937
<Option name="OutputFileType" value="0"/>
@@ -70,6 +68,8 @@
7068
</Target>
7169
<Components path="./"/>
7270
<Files>
73-
<File name="main.cpp" path="main.cpp" type="1"/>
71+
{% for file in source_files %}
72+
<File name="{{file.name}}" path="{{file.path}}.{{file.type}}" type="1"/>
73+
{% endfor %}
7474
</Files>
7575
</Project>

0 commit comments

Comments
 (0)