Skip to content

Commit 0a40a52

Browse files
committed
flatten the compiled files list
1 parent c5119ca commit 0a40a52

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

tools/export/cmake/CMakeLists.txt.tmpl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,11 @@ INCLUDE_DIRECTORIES(
5050
{% for p in include_paths %}{{p}}
5151
{% endfor %})
5252

53-
{% for libname,libsrcs in dependencies.items() %}
54-
# target for library "{{libname}}"
55-
ADD_LIBRARY({{libname}} STATIC
56-
{% for libsrc in libsrcs %}{{libsrc}}
57-
{% endfor %})
58-
{% endfor %}
59-
6053
# executable {{name}}
6154
ADD_EXECUTABLE({{name}}
6255
{% for src in sources %}{{src}}
6356
{% endfor %})
6457
SET_TARGET_PROPERTIES({{name}} PROPERTIES ENABLE_EXPORTS 1)
65-
TARGET_LINK_LIBRARIES({{name}}
66-
{% for libname in dependencies.keys()|sort(reverse=true) %}{{libname}}
67-
{% endfor %})
6858
# add syslibs dependencies to create the correct linker order
6959
TARGET_LINK_LIBRARIES({{name}} {{ld_sys_libs|join(" ")}})
7060

tools/export/cmake/__init__.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,26 @@ def generate(self):
5858
# get all source files including headers, adding headers allows IDEs to detect which files
5959
# belong to the project, otherwise headers may be greyed out and not work with inspection
6060
# (that is true for CLion and definitely for Visual Code)
61-
allSourceFiles = set(self.resources.c_sources +
62-
self.resources.cpp_sources +
63-
self.resources.s_sources +
64-
self.resources.headers)
65-
66-
# create a list of dependencies (mbed add ...)
67-
dependencies = [l[:-4] for l in self.resources.lib_refs]
68-
# separate the individual dependency source files into a map with the dep name as key and an array if files
69-
depSources = {re.sub(r'^[.]/', '', l).replace('/', '_'):
70-
sorted([f for f in allSourceFiles if f.startswith(l)]) for l in dependencies}
71-
# delete dependencies that have no source files (may happen if a sub-dependency is ignored by .mbedignore)
72-
depSources = {k: v for k, v in depSources.items() if len(v) != 0}
73-
74-
# remove all source files that ended up being part of one of the dependencies
75-
srcs = allSourceFiles
76-
for dep in depSources.values():
77-
srcs.difference_update(dep)
61+
srcs = set(self.resources.c_sources +
62+
self.resources.cpp_sources +
63+
self.resources.s_sources +
64+
self.resources.headers)
65+
srcs = [re.sub(r'^[.]/', '', f) for f in srcs]
7866

7967
# additional libraries
8068
libraries = [self.prepare_lib(basename(lib)) for lib in self.resources.libraries]
8169
sys_libs = [self.prepare_sys_lib(lib) for lib in self.toolchain.sys_libs]
8270

71+
# sort includes reverse, so the deepest dir comes first (ensures short includes)
72+
includes = sorted([re.sub(r'^[.]/', '', l) for l in self.resources.inc_dirs], reverse=True)
73+
8374
ctx = {
8475
'name': self.project_name,
8576
'target': self.target,
8677
'sources': sorted(srcs),
87-
'dependencies': depSources,
8878
'libraries': libraries,
8979
'ld_sys_libs': sys_libs,
90-
'include_paths': sorted(list(set(self.resources.inc_dirs))),
80+
'include_paths': includes,
9181
'library_paths': sorted([re.sub(r'^[.]/', '', l) for l in self.resources.lib_dirs]),
9282
'linker_script': self.resources.linker_script,
9383
'hex_files': self.resources.hex_files,
@@ -180,7 +170,6 @@ def build(project_name, log_name="build_log.txt", cleanup=True):
180170
if exists('BUILD'):
181171
shutil.rmtree('BUILD')
182172

183-
184173
if ret_code != 0:
185174
# Seems like something went wrong.
186175
return -1

0 commit comments

Comments
 (0)