Skip to content

Commit 2d699b4

Browse files
Lealem Amediedanielinux
authored andcommitted
CMake: Add BUILD_IMAGE option
1 parent f0b3400 commit 2d699b4

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ add_option(
126126
"no"
127127
"yes;no")
128128
add_option("DEBUG_UART" "Enable trace debugging over a UART (default: disabled)" "no" "yes;no")
129-
add_option("BUILD_TEST_APPS" "Build the wolfBoot test apps (default: disabled)" "no" "yes;no")
129+
add_option("BUILD_TEST_APPS" "Build the wolfBoot image and test apps (default: disabled)" "no" "yes;no")
130+
add_option("BUILD_IMAGE" "Build the wolfBoot image (default: disabled)" "no" "yes;no")
130131
add_option("PYTHON_KEYTOOLS" "Use wolfCrypt-py for key generation and signing (default: disabled)"
131132
"no" "yes;no")
132133
add_option(
@@ -650,9 +651,8 @@ set(WOLFBOOT_LSCRIPT_TEMPLATE hal/${WOLFBOOT_TARGET}.ld)
650651
# wolfcrypt
651652
add_subdirectory(lib)
652653

653-
if(BUILD_TEST_APPS)
654-
# test applications
655-
message(STATUS "Building wolfboot test apps")
654+
if(BUILD_TEST_APPS OR BUILD_IMAGE)
655+
message(STATUS "Building wolfBoot image")
656656
add_subdirectory(test-app)
657657
endif()
658658

test-app/CMakeLists.txt

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,38 +104,41 @@ else()
104104
gen_wolfboot_platform_target(${PLATFORM_NAME} bootloader_linker_script)
105105
endif()
106106

107-
add_executable(image)
107+
if(BUILD_TEST_APPS)
108+
message(STATUS "Building wolfBoot test apps")
109+
add_executable(image)
108110

109-
target_sources(image PRIVATE ${APP_SOURCES})
111+
target_sources(image PRIVATE ${APP_SOURCES})
110112

111-
target_include_directories(image PRIVATE
112-
../
113-
../include
114-
${CMAKE_CURRENT_BINARY_DIR})
113+
target_include_directories(image PRIVATE
114+
../
115+
../include
116+
${CMAKE_CURRENT_BINARY_DIR})
115117

116-
target_link_libraries(image wolfboot target)
118+
target_link_libraries(image wolfboot target)
117119

118-
target_compile_definitions(image PRIVATE PLATFORM_${WOLFBOOT_TARGET}
119-
${TEST_APP_COMPILE_DEFINITIONS} ${WOLFBOOT_DEFS})
120+
target_compile_definitions(image PRIVATE PLATFORM_${WOLFBOOT_TARGET}
121+
${TEST_APP_COMPILE_DEFINITIONS} ${WOLFBOOT_DEFS})
120122

121-
target_compile_options(image PRIVATE -Wall -Wstack-usage=1024 -ffreestanding -Wno-unused
122-
-nostartfiles)
123+
target_compile_options(image PRIVATE -Wall -Wstack-usage=1024 -ffreestanding -Wno-unused
124+
-nostartfiles)
123125

124-
if(WOLFBOOT_TARGET STREQUAL "sim")
125-
target_link_options(image PRIVATE -Wl,-gc-sections -Wl,-Map=image.map)
126-
else()
127-
target_link_options(image PRIVATE -T${APP_LSCRIPT} -Wl,-gc-sections -Wl,-Map=image.map)
128-
endif()
126+
if(WOLFBOOT_TARGET STREQUAL "sim")
127+
target_link_options(image PRIVATE -Wl,-gc-sections -Wl,-Map=image.map)
128+
else()
129+
target_link_options(image PRIVATE -T${APP_LSCRIPT} -Wl,-gc-sections -Wl,-Map=image.map)
130+
endif()
129131

130-
if(WOLFBOOT_TARGET IN_LIST ARM_TARGETS)
131-
message(STATUS "Binary output products will be generated")
132-
gen_bin_target_outputs(image)
132+
if(WOLFBOOT_TARGET IN_LIST ARM_TARGETS)
133+
message(STATUS "Binary output products will be generated")
134+
gen_bin_target_outputs(image)
133135

134-
# add boot address to cache
135-
unset(${PLATFORM_NAME}_BOOT_ADDRESS CACHE)
136-
set(${PLATFORM_NAME}_BOOT_ADDRESS ${WOLFBOOT_PARTITION_BOOT_ADDRESS} CACHE INTERNAL "")
136+
# add boot address to cache
137+
unset(${PLATFORM_NAME}_BOOT_ADDRESS CACHE)
138+
set(${PLATFORM_NAME}_BOOT_ADDRESS ${WOLFBOOT_PARTITION_BOOT_ADDRESS} CACHE INTERNAL "")
137139

138-
gen_wolfboot_factory_image(${PLATFORM_NAME} image)
139-
else()
140-
gen_wolfboot_signed_image(image)
140+
gen_wolfboot_factory_image(${PLATFORM_NAME} image)
141+
else()
142+
gen_wolfboot_signed_image(image)
143+
endif()
141144
endif()

0 commit comments

Comments
 (0)