Skip to content

Commit bc11dfd

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 bc11dfd

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

targets/TARGET_Cypress/scripts/PSOC6.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ 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:
321+
elf_file = os.path.join(args.artefacts_location, args.application_name + ".elf")
322+
m4hex_file = os.path.join(args.artefacts_location, args.application_name + ".hex")
323+
324+
if not os.path.isfile(elf_file) or not os.path.isfile(m4hex_file):
325325
raise ArtefactsError(
326326
f"Could not find elf and/or hex file in {args.artefacts_location}"
327327
)
@@ -333,10 +333,9 @@ def merge_action(args):
333333

334334
def sign_action(args):
335335
"""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:
336+
elf_file = os.path.join(args.artefacts_location, args.application_name + ".elf")
337+
m4hex_file = os.path.join(args.artefacts_location, args.application_name + ".hex")
338+
if not os.path.isfile(elf_file) or not os.path.isfile(m4hex_file):
340339
raise ArtefactsError(
341340
f"Could not find elf and/or hex file in {args.artefacts_location}"
342341
)
@@ -370,6 +369,9 @@ def parse_args():
370369
merge_subcommand.add_argument(
371370
"--artefacts-location", required=True, help="the path to the application artefacts."
372371
)
372+
merge_subcommand.add_argument(
373+
"--application-name", required=True, help="Name of the application."
374+
)
373375
merge_subcommand.add_argument(
374376
"--m0hex", help="the path to the Cortex-M0 HEX to merge."
375377
)
@@ -402,6 +404,9 @@ def parse_args():
402404
sign_subcommand.add_argument(
403405
"--artefacts-location", required=True, help="the path to the application artefacts."
404406
)
407+
sign_subcommand.add_argument(
408+
"--application-name", required=True, help="Name of the application."
409+
)
405410
sign_subcommand.add_argument(
406411
"--m0hex", help="the path to the Cortex-M0 HEX to merge."
407412
)

targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ function(mbed_post_build_psoc6_merge_hex mbed_target_name)
2323
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
2424
merge
2525
--artefacts-location ${CMAKE_BINARY_DIR}
26+
--application-name $<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>
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
3233
--artefacts-location ${CMAKE_BINARY_DIR}
34+
--application-name $<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>
3335
)
3436
endif()
3537

@@ -62,6 +64,7 @@ function(mbed_post_build_psoc6_sign_image
6264
--cm0-img-id ${cm0_img_id}
6365
--cm4-img-id ${cm4_img_id}
6466
--artefacts-location ${CMAKE_BINARY_DIR}
67+
--application-name $<TARGET_PROPERTY:mbed-post-build-bin-${mbed_target_name},application>
6568
--m0hex ${cortex_m0_hex}
6669
)
6770

0 commit comments

Comments
 (0)