Skip to content

Commit 03914d1

Browse files
committed
CMake: Remove references of APP_TARGET
This needs to be removed as there should not be a name requirement for application CMake variable name. Furthermore, in certain uses cases it prevents successful builds for some Mbed targets. For instance when building Greentea test applications for Mbed targets that require post build operations as they do not define APP_TARGET.
1 parent 8340ea2 commit 03914d1

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

targets/TARGET_Cypress/scripts/PSOC6.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#
1818

1919
import argparse
20+
import pathlib
2021
import logging
2122
import os
2223
import sys
@@ -59,6 +60,12 @@ class AddSignatureError(Exception):
5960
adding signature to Secure Boot image
6061
"""
6162

63+
64+
class ArtefactsError(Exception):
65+
"""An exception to indicate that the artefact(s) needed for processing
66+
ave not been found."""
67+
68+
6269
# Base class for all configuration exceptions
6370
class ConfigException(Exception):
6471
"""Config system only exception. Makes it easier to distinguish config
@@ -306,13 +313,29 @@ def complete(message_func, elf0, hexf0, hexf1=None):
306313

307314
def merge_action(args):
308315
"""Entry point for the "merge" CLI command."""
316+
try:
317+
elf_file = list(pathlib.Path(args.artefacts_location).glob("*.elf"))[0]
318+
m4hex_file = list(pathlib.Path(args.artefacts_location).glob("*.hex"))[0]
319+
except IndexError:
320+
raise ArtefactsError(
321+
f"Could not find elf and/or hex file in {args.artefacts_location}"
322+
)
323+
309324
complete_func(
310-
print, args.elf, args.m4hex, args.m0hex
325+
print, elf_file, m4hex_file, args.m0hex
311326
)
312327

313328

314329
def sign_action(args):
315330
"""Entry point for the "sign" CLI command."""
331+
try:
332+
elf_file = list(pathlib.Path(args.artefacts_location).glob("*.elf"))[0]
333+
m4hex_file = list(pathlib.Path(args.artefacts_location).glob("*.hex"))[0]
334+
except IndexError:
335+
raise ArtefactsError(
336+
f"Could not find elf and/or hex file in {args.artefacts_location}"
337+
)
338+
316339
sign_hex(
317340
args.build_dir,
318341
args.m0hex_filename,
@@ -322,8 +345,8 @@ def sign_action(args):
322345
args.boot_scheme,
323346
args.cm0_img_id,
324347
args.cm4_img_id,
325-
args.elf,
326-
args.m4hex,
348+
elf_file,
349+
m4hex_file,
327350
args.m0hex
328351
)
329352

@@ -340,10 +363,7 @@ def parse_args():
340363
"merge", help="Merge Cortex-M4 and Cortex-M0 HEX files."
341364
)
342365
merge_subcommand.add_argument(
343-
"--elf", required=True, help="the application ELF file."
344-
)
345-
merge_subcommand.add_argument(
346-
"--m4hex", required=True, help="the path to the Cortex-M4 HEX to merge."
366+
"--artefacts-location", required=True, help="the path to the application artefacts."
347367
)
348368
merge_subcommand.add_argument(
349369
"--m0hex", help="the path to the Cortex-M0 HEX to merge."
@@ -375,10 +395,7 @@ def parse_args():
375395
"--cm4-img-id", help="the Cortex-M4 image ID."
376396
)
377397
sign_subcommand.add_argument(
378-
"--elf", required=True, help="the application ELF file."
379-
)
380-
sign_subcommand.add_argument(
381-
"--m4hex", required=True, help="the path to the Cortex-M4 HEX to merge."
398+
"--artefacts-location", required=True, help="the path to the application artefacts."
382399
)
383400
sign_subcommand.add_argument(
384401
"--m0hex", help="the path to the Cortex-M0 HEX to merge."

targets/TARGET_Cypress/scripts/mbed_set_post_build_cypress.cmake

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ 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-
--elf $<TARGET_FILE:${APP_TARGET}>
26-
--m4hex ${CMAKE_BINARY_DIR}/${APP_TARGET}.hex
25+
--artefacts-location ${CMAKE_BINARY_DIR}
2726
--m0hex ${cortex_m0_hex}
2827
)
2928
else()
3029
set(post_build_command
3130
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_Cypress/scripts/PSOC6.py
3231
merge
33-
--elf $<TARGET_FILE:${APP_TARGET}>
34-
--m4hex ${CMAKE_BINARY_DIR}/${APP_TARGET}.hex
32+
--artefacts-location ${CMAKE_BINARY_DIR}
3533
)
3634
endif()
3735

@@ -63,8 +61,7 @@ function(mbed_post_build_psoc6_sign_image
6361
--boot-scheme ${boot_scheme}
6462
--cm0-img-id ${cm0_img_id}
6563
--cm4-img-id ${cm4_img_id}
66-
--elf $<TARGET_FILE:${APP_TARGET}>
67-
--m4hex ${CMAKE_BINARY_DIR}/${APP_TARGET}.hex
64+
--artefacts-location ${CMAKE_BINARY_DIR}
6865
--m0hex ${cortex_m0_hex}
6966
)
7067

targets/TARGET_NXP/scripts/LPC.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@
2424
the first 8 locations in sector 0 of the flash. If the result is 0, then execution control is
2525
transferred to the user code.
2626
"""
27+
import pathlib
2728
import os
2829
import sys
2930
from struct import unpack, pack
3031

3132

33+
class ArtefactsError(Exception):
34+
"""An exception to indicate that the artefact(s) needed for processing
35+
ave not been found."""
36+
37+
3238
def patch(bin_path):
3339
with open(bin_path, 'r+b') as bin:
3440
# Read entries 0 through 6 (Little Endian 32bits words)
@@ -47,6 +53,14 @@ def is_patched(bin_path):
4753

4854

4955
if __name__ == "__main__":
50-
binary = sys.argv[1]
56+
artefacts_location = sys.argv[1]
57+
58+
try:
59+
binary = list(pathlib.Path(artefacts_location).glob("*.bin"))[0]
60+
except IndexError:
61+
raise ArtefactsError(
62+
f"Could not find binary file in {artefacts_location}"
63+
)
64+
5165
print("LPC Patch: %s" % os.path.split(binary)[1])
5266
patch(binary)

targets/TARGET_NXP/scripts/mbed_set_post_build_nxp.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function(mbed_post_build_lpc_patch_vtable mbed_target_name)
1111

1212
set(post_build_command
1313
COMMAND ${Python3_EXECUTABLE} ${MBED_PATH}/targets/TARGET_NXP/scripts/LPC.py
14-
${CMAKE_BINARY_DIR}/${APP_TARGET}.bin
14+
${CMAKE_BINARY_DIR}
1515
)
1616

1717
mbed_set_post_build_operation()

0 commit comments

Comments
 (0)