Skip to content

Commit 2283274

Browse files
vmedcyCruz Monrreal II
authored andcommitted
PSOC6: enable export to CMake
The approach for the hex_files subset selection is identical to makefile exporter: #9466 Single hex file should be passed to srec_cat when hex_filename is set in targets.json or mbed_app.json.
1 parent 6cbe7a7 commit 2283274

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tools/export/cmake/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class CMake(Exporter):
4444
"MCU_NRF51Code.binary_hook",
4545
"TEENSY3_1Code.binary_hook",
4646
"LPCTargetCode.lpc_patch",
47-
"LPC4088Code.binary_hook"
47+
"LPC4088Code.binary_hook",
48+
"PSOC6Code.complete"
4849
])
4950

5051
@classmethod
@@ -74,6 +75,12 @@ def generate(self):
7475
# sort includes reverse, so the deepest dir comes first (ensures short includes)
7576
includes = sorted([re.sub(r'^[.]/', '', l) for l in self.resources.inc_dirs], reverse=True)
7677

78+
# select dependant hex files to merge into compiled hex image
79+
hex_files = self.resources.hex_files
80+
if hasattr(self.toolchain.target, 'hex_filename'):
81+
hex_filename = self.toolchain.target.hex_filename
82+
hex_files = list(f for f in hex_files if basename(f) == hex_filename)
83+
7784
ctx = {
7885
'name': self.project_name,
7986
'target': self.target,
@@ -83,7 +90,7 @@ def generate(self):
8390
'include_paths': includes,
8491
'library_paths': sorted([re.sub(r'^[.]/', '', l) for l in self.resources.lib_dirs]),
8592
'linker_script': self.resources.linker_script,
86-
'hex_files': self.resources.hex_files,
93+
'hex_files': hex_files,
8794
'ar': basename(self.toolchain.ar),
8895
'cc': basename(self.toolchain.cc[0]),
8996
'cc_flags': " ".join(flag for flag in self.toolchain.cc[1:] if not flag == "-c"),

0 commit comments

Comments
 (0)