Skip to content

Commit 7b7d5fc

Browse files
Thomas SailerThomas Sailer
authored andcommitted
exporter: properly export libraries
1 parent 84fe7ed commit 7b7d5fc

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

tools/export/codeblocks/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ def filter_dot(str_in):
5151
return str_in[2:]
5252
return str_in
5353

54+
@staticmethod
55+
def prepare_lib(libname):
56+
if "lib" == libname[:3]:
57+
libname = libname[3:-2]
58+
return "-l" + libname
59+
60+
@staticmethod
61+
def prepare_sys_lib(libname):
62+
return "-l" + libname
63+
5464
def generate(self):
5565
self.resources.win_to_unix()
5666

@@ -79,6 +89,10 @@ def generate(self):
7989
not x.startswith('obj'))];
8090

8191
c_sources = sorted([self.filter_dot(s) for s in self.resources.c_sources])
92+
libraries = [self.prepare_lib(basename(lib)) for lib
93+
in self.resources.libraries]
94+
sys_libs = [self.prepare_sys_lib(lib) for lib
95+
in self.toolchain.sys_libs]
8296

8397
ctx = {
8498
'project_name': self.project_name,
@@ -91,7 +105,8 @@ def generate(self):
91105
'cpp_sources': sorted([self.filter_dot(s) for s in self.resources.cpp_sources]),
92106
'include_paths': inc_dirs,
93107
'linker_script': self.filter_dot(self.resources.linker_script),
94-
'libraries': self.resources.libraries,
108+
'libraries': libraries,
109+
'sys_libs': sys_libs,
95110
'openocdboard': ''
96111
}
97112

tools/export/codeblocks/cbp.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@
4545
<Add option="{{f}}" />
4646
{% endfor -%}
4747
<Add option="-T {{linker_script}}" />
48+
<Add option="-Wl,--start-group {{sys_libs|join(" ")}} {{libraries|join(" ")}} -Wl,--end-group" />
49+
{% for f in sys_libs -%}
50+
<Add option="{{f}}" />
51+
{% endfor -%}
4852
{% for f in libraries -%}
49-
<Add library="{{f}}" />
53+
<Add option="{{f}}" />
5054
{% endfor -%}
5155
</Linker>
5256
{% for f in headers -%}

0 commit comments

Comments
 (0)