Skip to content

Commit

Permalink
CMake: Add BUILD_IMAGE option
Browse files Browse the repository at this point in the history
  • Loading branch information
Lealem Amedie authored and danielinux committed May 21, 2024
1 parent f0b3400 commit 2d699b4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ add_option(
"no"
"yes;no")
add_option("DEBUG_UART" "Enable trace debugging over a UART (default: disabled)" "no" "yes;no")
add_option("BUILD_TEST_APPS" "Build the wolfBoot test apps (default: disabled)" "no" "yes;no")
add_option("BUILD_TEST_APPS" "Build the wolfBoot image and test apps (default: disabled)" "no" "yes;no")
add_option("BUILD_IMAGE" "Build the wolfBoot image (default: disabled)" "no" "yes;no")
add_option("PYTHON_KEYTOOLS" "Use wolfCrypt-py for key generation and signing (default: disabled)"
"no" "yes;no")
add_option(
Expand Down Expand Up @@ -650,9 +651,8 @@ set(WOLFBOOT_LSCRIPT_TEMPLATE hal/${WOLFBOOT_TARGET}.ld)
# wolfcrypt
add_subdirectory(lib)

if(BUILD_TEST_APPS)
# test applications
message(STATUS "Building wolfboot test apps")
if(BUILD_TEST_APPS OR BUILD_IMAGE)
message(STATUS "Building wolfBoot image")
add_subdirectory(test-app)
endif()

Expand Down
53 changes: 28 additions & 25 deletions test-app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,38 +104,41 @@ else()
gen_wolfboot_platform_target(${PLATFORM_NAME} bootloader_linker_script)
endif()

add_executable(image)
if(BUILD_TEST_APPS)
message(STATUS "Building wolfBoot test apps")
add_executable(image)

target_sources(image PRIVATE ${APP_SOURCES})
target_sources(image PRIVATE ${APP_SOURCES})

target_include_directories(image PRIVATE
../
../include
${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(image PRIVATE
../
../include
${CMAKE_CURRENT_BINARY_DIR})

target_link_libraries(image wolfboot target)
target_link_libraries(image wolfboot target)

target_compile_definitions(image PRIVATE PLATFORM_${WOLFBOOT_TARGET}
${TEST_APP_COMPILE_DEFINITIONS} ${WOLFBOOT_DEFS})
target_compile_definitions(image PRIVATE PLATFORM_${WOLFBOOT_TARGET}
${TEST_APP_COMPILE_DEFINITIONS} ${WOLFBOOT_DEFS})

target_compile_options(image PRIVATE -Wall -Wstack-usage=1024 -ffreestanding -Wno-unused
-nostartfiles)
target_compile_options(image PRIVATE -Wall -Wstack-usage=1024 -ffreestanding -Wno-unused
-nostartfiles)

if(WOLFBOOT_TARGET STREQUAL "sim")
target_link_options(image PRIVATE -Wl,-gc-sections -Wl,-Map=image.map)
else()
target_link_options(image PRIVATE -T${APP_LSCRIPT} -Wl,-gc-sections -Wl,-Map=image.map)
endif()
if(WOLFBOOT_TARGET STREQUAL "sim")
target_link_options(image PRIVATE -Wl,-gc-sections -Wl,-Map=image.map)
else()
target_link_options(image PRIVATE -T${APP_LSCRIPT} -Wl,-gc-sections -Wl,-Map=image.map)
endif()

if(WOLFBOOT_TARGET IN_LIST ARM_TARGETS)
message(STATUS "Binary output products will be generated")
gen_bin_target_outputs(image)
if(WOLFBOOT_TARGET IN_LIST ARM_TARGETS)
message(STATUS "Binary output products will be generated")
gen_bin_target_outputs(image)

# add boot address to cache
unset(${PLATFORM_NAME}_BOOT_ADDRESS CACHE)
set(${PLATFORM_NAME}_BOOT_ADDRESS ${WOLFBOOT_PARTITION_BOOT_ADDRESS} CACHE INTERNAL "")
# add boot address to cache
unset(${PLATFORM_NAME}_BOOT_ADDRESS CACHE)
set(${PLATFORM_NAME}_BOOT_ADDRESS ${WOLFBOOT_PARTITION_BOOT_ADDRESS} CACHE INTERNAL "")

gen_wolfboot_factory_image(${PLATFORM_NAME} image)
else()
gen_wolfboot_signed_image(image)
gen_wolfboot_factory_image(${PLATFORM_NAME} image)
else()
gen_wolfboot_signed_image(image)
endif()
endif()

0 comments on commit 2d699b4

Please sign in to comment.