Skip to content

Enforce ordering of pico_add_extra_outputs and picotool functions #2054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ function(pico_init_picotool)
endif()
endfunction()

function(picotool_check_configurable TARGET)
get_target_property(configured ${TARGET} PICOTOOL_PROCESSING_CONFIGURED)
if (configured)
message(FATAL_ERROR "All picotool post-processing functions for \"${TARGET}\" must come before pico_add_extra_outputs(${TARGET})")
endif()
endfunction()

# Generate pio header and include it in the build
# 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
function(pico_generate_pio_header TARGET PIO)
Expand Down Expand Up @@ -198,6 +205,7 @@ endfunction()
# dropping, and it will be copied to SRAM by the bootrom before execution.
# This sets PICOTOOL_UF2_PACKAGE_ADDR to PACKADDR.
function(pico_package_uf2_output TARGET PACKADDR)
picotool_check_configurable(${TARGET})
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_UF2_PACKAGE_ADDR ${PACKADDR}
)
Expand All @@ -207,6 +215,7 @@ endfunction()
# Output the public key hash and other necessary rows to an otp JSON file.
# This sets PICOTOOL_OTP_FILE to OTPFILE.
function(pico_set_otp_key_output_file TARGET OTPFILE)
picotool_check_configurable(${TARGET})
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_OTP_FILE ${OTPFILE}
)
Expand All @@ -217,6 +226,7 @@ endfunction()
# before loading the binary. This appends the `--clear` argument
# to PICOTOOL_EXTRA_PROCESS_ARGS.
function(pico_load_map_clear_sram TARGET)
picotool_check_configurable(${TARGET})
# get and set, to inherit list
get_target_property(extra_args ${TARGET} PICOTOOL_EXTRA_PROCESS_ARGS)
if (extra_args)
Expand All @@ -234,6 +244,7 @@ endfunction()
# to PICOTOOL_EXTRA_PROCESS_ARGS if setting the rollback version, or set as compile
# definitions if only setting the major/minor versions.
function(pico_set_binary_version TARGET)
picotool_check_configurable(${TARGET})
set(oneValueArgs MAJOR MINOR ROLLBACK)
set(multiValueArgs ROWS)
cmake_parse_arguments(PARSE_ARGV 1 SV "" "${oneValueArgs}" "${multiValueArgs}")
Expand Down Expand Up @@ -283,6 +294,7 @@ endfunction()
# Set the UF2 family to use when creating the UF2.
# This sets PICOTOOL_UF2_FAMILY to FAMILY.
function(pico_set_uf2_family TARGET FAMILY)
picotool_check_configurable(${TARGET})
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_UF2_FAMILY ${FAMILY}
)
Expand All @@ -295,6 +307,7 @@ endfunction()
# specify a common SIGFILE for multiple targets, the SIGFILE property can be
# set for a given scope, and then the SIGFILE argument is optional.
function(pico_sign_binary TARGET)
picotool_check_configurable(${TARGET})
# Enforce signing through target properties
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_SIGN_OUTPUT true
Expand All @@ -320,6 +333,7 @@ endfunction()
# pico_hash_binary(TARGET)
# Hash the target binary. This sets PICOTOOL_HASH_OUTPUT to true.
function(pico_hash_binary TARGET)
picotool_check_configurable(${TARGET})
# Enforce hashing through target properties
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_HASH_OUTPUT true
Expand All @@ -330,6 +344,7 @@ endfunction()
# Create the specified partition table from JSON, and embed it in the
# block loop. This sets PICOTOOL_EMBED_PT to PTFILE.
function(pico_embed_pt_in_binary TARGET PTFILE)
picotool_check_configurable(${TARGET})
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_EMBED_PT ${PTFILE}
)
Expand All @@ -341,6 +356,7 @@ endfunction()
# This sets PICOTOOL_AESFILE to AESFILE, and PICOTOOL_ENC_SIGFILE to SIGFILE
# if present, else PICOTOOL_SIGFILE.
function(pico_encrypt_binary TARGET AESFILE)
picotool_check_configurable(${TARGET})
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_AESFILE ${AESFILE}
)
Expand Down Expand Up @@ -422,6 +438,9 @@ endfunction()
# Run picotool post-processing on the binary - must be called after
# all required properties have been set
function(picotool_postprocess_binary TARGET)
set_target_properties(${TARGET} PROPERTIES
PICOTOOL_PROCESSING_CONFIGURED true
)
# Read target properties
get_target_property(picotool_sign_output ${TARGET} PICOTOOL_SIGN_OUTPUT)
if (picotool_sign_output)
Expand Down
Loading