Skip to content
Merged
Show file tree
Hide file tree
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
24 changes: 21 additions & 3 deletions src/ic_bundle.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ FULL_NAME <name>
[EXTRA_FILES <file paths list>] default: [empty cmake list]
A list of paths to extra build artifacts that should be bundled, example:
EXTRA_FILES "${CMAKE_BINARY_DIR}/bootloader/zephyr/zephyr.hex"
Each file is copied as "${FULL_NAME}_<file name>", so the example above
would be bundled as "${FULL_NAME}_zephyr.hex".

[DEPENDS <target>] default: ${PROJECT_NAME}
The target to depend on for the bundle target. For Zephyr projects, this
Expand All @@ -65,16 +67,20 @@ function(ic_bundle)
)
set(optional_keyword_args
PREFIX
EXTRA_FILES
EXTRA_POSTFIXES
DEPENDS
BUNDLE_DIR
)
set(multi_value_keyword_args
EXTRA_FILES
EXTRA_POSTFIXES
)
list(APPEND keyword_args
${required_keyword_args}
${optional_keyword_args}
)
cmake_parse_arguments(PARSE_ARGV 0 "" "" "${keyword_args}" "")
cmake_parse_arguments(
PARSE_ARGV 0 "" "" "${keyword_args}" "${multi_value_keyword_args}"
)

if(_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unparsed arguments: ${_UNPARSED_ARGUMENTS}")
Expand Down Expand Up @@ -105,6 +111,18 @@ function(ic_bundle)
foreach(extra_postfix ${_EXTRA_POSTFIXES})
add_artifact("${extra_postfix}")
endforeach()

foreach(extra_file ${_EXTRA_FILES})
cmake_path(GET extra_file FILENAME extra_file_name)
_add_artifact(artifact_list
bundle
"${_BUNDLE_DIR}"
"${extra_file}"
""
"${_FULL_NAME}_${extra_file_name}"
"${_DEPENDS}"
)
endforeach()

add_custom_command(
OUTPUT "${_FULL_NAME}.zip"
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ test_cmake_begin()

include(test_ic_project.cmake)
include(test_ic_bundle/minimal_args.cmake)
include(test_ic_bundle_extra_args/extra_args.cmake)

test_cmake_end()
Empty file.
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions tests/script.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
# Build the examples since the tests check for build artifacts
execute_process(COMMAND cmake "-B" "tests/test_ic_bundle/build" "-S" "tests/test_ic_bundle")
execute_process(COMMAND cmake "--build" "tests/test_ic_bundle/build")
execute_process(
COMMAND cmake "-B" "tests/test_ic_bundle_extra_args/build" "-S" "tests/test_ic_bundle_extra_args"
)
execute_process(COMMAND cmake "--build" "tests/test_ic_bundle_extra_args/build")

# Run the tests
execute_process(
Expand Down
21 changes: 21 additions & 0 deletions tests/test_ic_bundle_extra_args/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2026 Intercreate, Inc.
# SPDX-License-Identifier: Apache-2.0
#
# Authors: J.P. Hutchins <jp@intercreate.io>

cmake_minimum_required(VERSION 3.20.0)
project(create_the_ic_bundle_extra_args_build)

include(${CMAKE_SOURCE_DIR}/../../ic.cmake)

add_custom_target(test_ic_bundle_extra_args ALL)

set(FULL_NAME "client_project_board@rev_1.0.0_123456")

ic_bundle(
FULL_NAME "${FULL_NAME}"
PREFIX ${CMAKE_SOURCE_DIR}/../fixtures/ic_bundle/project
EXTRA_POSTFIXES .signed.bin .signed.hex
EXTRA_FILES ${CMAKE_SOURCE_DIR}/../fixtures/ic_bundle/bootloader.hex
DEPENDS test_ic_bundle_extra_args
)
28 changes: 28 additions & 0 deletions tests/test_ic_bundle_extra_args/extra_args.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2026 Intercreate, Inc.
# SPDX-License-Identifier: Apache-2.0
#
# Authors: J.P. Hutchins <jp@intercreate.io>

test_cmake_group_begin("ic_bundle() EXTRA_POSTFIXES and EXTRA_FILES")

set(FULL_NAME "client_project_board@rev_1.0.0_123456")

set(BUNDLE_DIR "${CMAKE_CURRENT_LIST_DIR}/build/${FULL_NAME}")

# More than one postfix, which a one-value keyword could not accept
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}.signed.bin")
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}.signed.hex")

# A file from outside PREFIX, named after the bundle rather than its source
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}_bootloader.hex")
assert(NOT EXISTS "${BUNDLE_DIR}/bootloader.hex")

# The default artifacts are still bundled alongside them
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}.elf")
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}.bin")
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}.hex")
assert(EXISTS "${BUNDLE_DIR}/${FULL_NAME}.map")

assert(EXISTS "${BUNDLE_DIR}.zip")

test_cmake_group_end()
Loading