Skip to content

Commit 6bf5d9b

Browse files
authored
Enforce ordering of pico_add_extra_outputs and picotool functions (#2054)
* Thow FATAL_ERROR when using post-processing functions after pico_add_extra_outputs * Remove property definition, and rename to `PICOTOOL_PROCESSING_CONFIGURED` and `picotool_check_configurable` * done -> configured
1 parent 9a2b75e commit 6bf5d9b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ function(pico_init_picotool)
146146
endif()
147147
endfunction()
148148

149+
function(picotool_check_configurable TARGET)
150+
get_target_property(configured ${TARGET} PICOTOOL_PROCESSING_CONFIGURED)
151+
if (configured)
152+
message(FATAL_ERROR "All picotool post-processing functions for \"${TARGET}\" must come before pico_add_extra_outputs(${TARGET})")
153+
endif()
154+
endfunction()
155+
149156
# Generate pio header and include it in the build
150157
# PICO_CMAKE_CONFIG: PICO_DEFAULT_PIOASM_OUTPUT_FORMAT, Default output format used by pioasm when using pico_generate_pio_header, type=string, default=c-sdk, group=build
151158
function(pico_generate_pio_header TARGET PIO)
@@ -198,6 +205,7 @@ endfunction()
198205
# dropping, and it will be copied to SRAM by the bootrom before execution.
199206
# This sets PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR.
200207
function(pico_package_uf2_output TARGET PACKADDR)
208+
picotool_check_configurable(${TARGET})
201209
set_target_properties(${TARGET} PROPERTIES
202210
PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR}
203211
)
@@ -207,6 +215,7 @@ endfunction()
207215
# Output the public key hash and other necessary rows to an otp JSON file.
208216
# This sets PICOTOOL_OTP_FILE to OTPFILE.
209217
function(pico_set_otp_key_output_file TARGET OTPFILE)
218+
picotool_check_configurable(${TARGET})
210219
set_target_properties(${TARGET} PROPERTIES
211220
PICOTOOL_OTP_FILE ${OTPFILE}
212221
)
@@ -217,6 +226,7 @@ endfunction()
217226
# before loading the binary. This appends the `--clear` argument
218227
# to PICOTOOL_EXTRA_PROCESS_ARGS.
219228
function(pico_load_map_clear_sram TARGET)
229+
picotool_check_configurable(${TARGET})
220230
# get and set, to inherit list
221231
get_target_property(extra_args ${TARGET} PICOTOOL_EXTRA_PROCESS_ARGS)
222232
if (extra_args)
@@ -234,6 +244,7 @@ endfunction()
234244
# to PICOTOOL_EXTRA_PROCESS_ARGS if setting the rollback version, or set as compile
235245
# definitions if only setting the major/minor versions.
236246
function(pico_set_binary_version TARGET)
247+
picotool_check_configurable(${TARGET})
237248
set(oneValueArgs MAJOR MINOR ROLLBACK)
238249
set(multiValueArgs ROWS)
239250
cmake_parse_arguments(PARSE_ARGV 1 SV "" "${oneValueArgs}" "${multiValueArgs}")
@@ -283,6 +294,7 @@ endfunction()
283294
# Set the UF2 family to use when creating the UF2.
284295
# This sets PICOTOOL_UF2_FAMILY to FAMILY.
285296
function(pico_set_uf2_family TARGET FAMILY)
297+
picotool_check_configurable(${TARGET})
286298
set_target_properties(${TARGET} PROPERTIES
287299
PICOTOOL_UF2_FAMILY ${FAMILY}
288300
)
@@ -295,6 +307,7 @@ endfunction()
295307
# specify a common SIGFILE for multiple targets, the SIGFILE property can be
296308
# set for a given scope, and then the SIGFILE argument is optional.
297309
function(pico_sign_binary TARGET)
310+
picotool_check_configurable(${TARGET})
298311
# Enforce signing through target properties
299312
set_target_properties(${TARGET} PROPERTIES
300313
PICOTOOL_SIGN_OUTPUT true
@@ -320,6 +333,7 @@ endfunction()
320333
# pico_hash_binary(TARGET)
321334
# Hash the target binary. This sets PICOTOOL_HASH_OUTPUT to true.
322335
function(pico_hash_binary TARGET)
336+
picotool_check_configurable(${TARGET})
323337
# Enforce hashing through target properties
324338
set_target_properties(${TARGET} PROPERTIES
325339
PICOTOOL_HASH_OUTPUT true
@@ -330,6 +344,7 @@ endfunction()
330344
# Create the specified partition table from JSON, and embed it in the
331345
# block loop. This sets PICOTOOL_EMBED_PT to PTFILE.
332346
function(pico_embed_pt_in_binary TARGET PTFILE)
347+
picotool_check_configurable(${TARGET})
333348
set_target_properties(${TARGET} PROPERTIES
334349
PICOTOOL_EMBED_PT ${PTFILE}
335350
)
@@ -341,6 +356,7 @@ endfunction()
341356
# This sets PICOTOOL_AESFILE to AESFILE, and PICOTOOL_ENC_SIGFILE to SIGFILE
342357
# if present, else PICOTOOL_SIGFILE.
343358
function(pico_encrypt_binary TARGET AESFILE)
359+
picotool_check_configurable(${TARGET})
344360
set_target_properties(${TARGET} PROPERTIES
345361
PICOTOOL_AESFILE ${AESFILE}
346362
)
@@ -422,6 +438,9 @@ endfunction()
422438
# Run picotool post-processing on the binary - must be called after
423439
# all required properties have been set
424440
function(picotool_postprocess_binary TARGET)
441+
set_target_properties(${TARGET} PROPERTIES
442+
PICOTOOL_PROCESSING_CONFIGURED true
443+
)
425444
# Read target properties
426445
get_target_property(picotool_sign_output ${TARGET} PICOTOOL_SIGN_OUTPUT)
427446
if (picotool_sign_output)

0 commit comments

Comments
 (0)