Skip to content

Commit 5353b62

Browse files
committed
Cypress: Query exact application names in post build
This removes the need to use "glob" a file extension, and uses precise application names.
1 parent ad27a3e commit 5353b62

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

targets/TARGET_Cypress/scripts/PSOC6.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,13 @@ def complete(message_func, elf0, hexf0, hexf1=None):
318318

319319
def merge_action(args):
320320
"""Entry point for the "merge" CLI command."""
321-
try:
322-
elf_file = list(pathlib.Path(args.artefacts_location).glob("*.elf"))[0]
323-
m4hex_file = list(pathlib.Path(args.artefacts_location).glob("*.hex"))[0]
324-
except IndexError:
325-
raise ArtefactsError(
326-
f"Could not find elf and/or hex file in {args.artefacts_location}"
327-
)
328-
329321
complete_func(
330-
print, elf_file, m4hex_file, args.m0hex
322+
print, args.elf, args.m4hex, args.m0hex
331323
)
332324

333325

334326
def sign_action(args):
335327
"""Entry point for the "sign" CLI command."""
336-
try:
337-
elf_file = list(pathlib.Path(args.artefacts_location).glob("*.elf"))[0]
338-
m4hex_file = list(pathlib.Path(args.artefacts_location).glob("*.hex"))[0]
339-
except IndexError:
340-
raise ArtefactsError(
341-
f"Could not find elf and/or hex file in {args.artefacts_location}"
342-
)
343-
344328
sign_hex(
345329
args.build_dir,
346330
args.m0hex_filename,
@@ -350,8 +334,8 @@ def sign_action(args):
350334
args.boot_scheme,
351335
args.cm0_img_id,
352336
args.cm4_img_id,
353-
elf_file,
354-
m4hex_file,
337+
args.elf,
338+
args.m4hex,
355339
args.m0hex
356340
)
357341

@@ -368,7 +352,10 @@ def parse_args():
368352
"merge", help="Merge Cortex-M4 and Cortex-M0 HEX files."
369353
)
370354
merge_subcommand.add_argument(
371-
"--artefacts-location", required=True, help="the path to the application artefacts."
355+
"--elf", required=True, help="the application ELF file."
356+
)
357+
merge_subcommand.add_argument(
358+
"--m4hex", required=True, help="the path to the Cortex-M4 HEX to merge."
372359
)
373360
merge_subcommand.add_argument(
374361
"--m0hex", help="the path to the Cortex-M0 HEX to merge."
@@ -400,7 +387,10 @@ def parse_args():
400387
"--cm4-img-id", type=int, help="the Cortex-M4 image ID."
401388
)
402389
sign_subcommand.add_argument(
403-
"--artefacts-location", required=True, help="the path to the application artefacts."
390+
"--elf", required=True, help="the application ELF file."
391+
)
392+
sign_subcommand.add_argument(
393+
"--m4hex", required=True, help="the path to the Cortex-M4 HEX to merge."
404394
)
405395
sign_subcommand.add_argument(
406396
"--m0hex", help="the path to the Cortex-M0 HEX to merge."

targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ function(mbed_post_build_psoc6_merge_hex mbed_target_name)
2222
set(post_build_command
2323
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
2424
merge
25-
--artefacts-location ${CMAKE_BINARY_DIR}
25+
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
26+
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex
2627
--m0hex ${cortex_m0_hex}
2728
)
2829
else()
2930
set(post_build_command
3031
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
3132
merge
32-
--artefacts-location ${CMAKE_BINARY_DIR}
33+
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
34+
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex
3335
)
3436
endif()
3537

@@ -61,7 +63,8 @@ function(mbed_post_build_psoc6_sign_image
6163
--boot-scheme ${boot_scheme}
6264
--cm0-img-id ${cm0_img_id}
6365
--cm4-img-id ${cm4_img_id}
64-
--artefacts-location ${CMAKE_BINARY_DIR}
66+
--elf ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.elf
67+
--m4hex ${CMAKE_BINARY_DIR}/$<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>.hex
6568
--m0hex ${cortex_m0_hex}
6669
)
6770

0 commit comments

Comments
 (0)