Skip to content
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

Add support for non-recursive single-toolchain multi-image builds #13672

Closed
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
279 changes: 160 additions & 119 deletions CMakeLists.txt

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions arch/arm/core/cortex_m/tz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ if(CONFIG_ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS)
)

# Indicate that the entry veneers library file is created during linking of this firmware.
set_property(
GLOBAL APPEND PROPERTY
extra_post_build_byproducts
set_property(TARGET ${ZEPHYR_TARGET} APPEND PROPERTY extra_post_build_byproducts
${CMAKE_BINARY_DIR}/${CONFIG_ARM_ENTRY_VENEERS_LIB_NAME}
)
endif()
Expand Down
2 changes: 1 addition & 1 deletion arch/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ zephyr_compile_options(
# @Intent: Obtain compiler specific flags for no freestanding compilation
toolchain_cc_no_freestanding_options()

zephyr_include_directories(${BOARD_DIR})
zephyr_include_directories(${${IMAGE}BOARD_DIR})

if (CONFIG_COVERAGE)
toolchain_cc_coverage()
Expand Down
5 changes: 3 additions & 2 deletions arch/riscv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
add_subdirectory(core)

if(CONFIG_64BIT)
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf64-littleriscv)
set(output_format elf64-littleriscv)
else()
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littleriscv)
set(output_format elf32-littleriscv)
endif()
set_target_properties(${ZEPHYR_TARGET} PROPERTIES PROPERTY_OUTPUT_FORMAT ${output_format})
40 changes: 20 additions & 20 deletions arch/x86/ia32.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Copyright (c) 2019 Intel Corp.
# SPDX-License-Identifier: Apache-2.0

# Find out if we are optimizing for size
get_target_property(zephyr_COMPILE_OPTIONS zephyr_interface INTERFACE_COMPILE_OPTIONS)
if ("-Os" IN_LIST zephyr_COMPILE_OPTIONS)
if(CONFIG_SIZE_OPTIMIZATIONS)
zephyr_cc_option(-mpreferred-stack-boundary=2)
else()
zephyr_compile_definitions(PERF_OPT)
endif()

set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "i386")
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-i386")
define_property(TARGET PROPERTY PROPERTY_OUTPUT_ARCH BRIEF_DOCS " " FULL_DOCS " ")

set_target_properties(${ZEPHYR_TARGET} PROPERTIES PROPERTY_OUTPUT_ARCH "i386"
PROPERTY_OUTPUT_FORMAT "elf32-i386")

if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
zephyr_compile_options(-Qunused-arguments)
Expand All @@ -31,17 +31,16 @@ endif()

set(GENIDT ${ZEPHYR_BASE}/arch/x86/gen_idt.py)

define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH BRIEF_DOCS " " FULL_DOCS " ")

# Use gen_idt.py and objcopy to generate irq_int_vector_map.o,
# irq_vectors_alloc.o, and staticIdt.o from the elf file ${ZEPHYR_PREBUILT_EXECUTABLE}
set(gen_idt_output_files
${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.bin
${CMAKE_CURRENT_BINARY_DIR}/staticIdt.bin
${CMAKE_CURRENT_BINARY_DIR}/irq_vectors_alloc.bin
)
set(gen_idt_output_target ${IMAGE}gen_idt_output)
add_custom_target(
gen_idt_output
${gen_idt_output_target}
DEPENDS
${gen_idt_output_files}
)
Expand All @@ -62,8 +61,8 @@ add_custom_command(
# Must be last so that soc/ can override default exception handlers
add_subdirectory(core)

get_property(OUTPUT_ARCH GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH)
get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT)
get_target_property(OUTPUT_ARCH ${ZEPHYR_TARGET} PROPERTY_OUTPUT_ARCH)
get_target_property(OUTPUT_FORMAT ${ZEPHYR_TARGET} PROPERTY_OUTPUT_FORMAT)

# Convert the .bin file argument to a .o file, create a wrapper
# library for the .o file, and register the library as a generated
Expand All @@ -82,25 +81,26 @@ function(add_bin_file_to_the_next_link target_dependency bin)
DEPENDS ${target_dependency} ${bin}.bin
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_custom_target(${bin}_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o)
add_library(${bin} STATIC IMPORTED GLOBAL)
set_property(TARGET ${bin} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o)
add_dependencies(${bin} ${bin}_o)
set_property(GLOBAL APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES ${bin})
add_custom_target(${IMAGE}${bin}_o DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o)
add_library(${IMAGE}${bin} STATIC IMPORTED GLOBAL)
set_property(TARGET ${IMAGE}${bin} PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${bin}.o)
add_dependencies(${IMAGE}${bin} ${IMAGE}${bin}_o)
set_property(TARGET ${ZEPHYR_TARGET} APPEND PROPERTY GENERATED_KERNEL_OBJECT_FILES ${IMAGE}${bin})
endfunction()

add_bin_file_to_the_next_link(gen_idt_output staticIdt)
add_bin_file_to_the_next_link(gen_idt_output irq_int_vector_map)
add_bin_file_to_the_next_link(gen_idt_output irq_vectors_alloc)
add_bin_file_to_the_next_link(${gen_idt_output_target} staticIdt)
add_bin_file_to_the_next_link(${gen_idt_output_target} irq_int_vector_map)
add_bin_file_to_the_next_link(${gen_idt_output_target} irq_vectors_alloc)

if(CONFIG_GDT_DYNAMIC)
# Use gen_gdt.py and objcopy to generate gdt.o from from the elf
# file ${ZEPHYR_PREBUILT_EXECUTABLE}, creating the temp file gdt.bin along the
# way.
#
# ${ZEPHYR_PREBUILT_EXECUTABLE}.elf -> gdt.bin -> gdt.o
set(gdt_bin_target ${IMAGE}gdt_bin)
add_custom_target(
gdt_bin_target
${gdt_bin_target}
DEPENDS
gdt.bin
)
Expand All @@ -116,5 +116,5 @@ if(CONFIG_GDT_DYNAMIC)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

add_bin_file_to_the_next_link(gdt_bin_target gdt)
add_bin_file_to_the_next_link(${gdt_bin_target} gdt)
endif()
2 changes: 1 addition & 1 deletion arch/xtensa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-xtensa-le)
set_target_properties(${ZEPHYR_TARGET} PROPERTIES PROPERTY_OUTPUT_FORMAT elf32-xtensa-le)
add_subdirectory(core)
6 changes: 3 additions & 3 deletions boards/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# To avoid a lot of empty CMakeLists.txt files we assume it is not an
# error if it is missing

if(EXISTS ${BOARD_DIR}/CMakeLists.txt)
if(EXISTS ${${IMAGE}BOARD_DIR}/CMakeLists.txt)
if(USING_OUT_OF_TREE_BOARD)
set(build_dir boards/${ARCH}/${BOARD})
set(build_dir boards/${ARCH}/${${IMAGE}BOARD})
else()
unset(build_dir)
endif()

add_subdirectory(${BOARD_DIR} ${build_dir})
add_subdirectory(${${IMAGE}BOARD_DIR} ${build_dir})
endif()
2 changes: 2 additions & 0 deletions boards/arm/lpcxpresso54114/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# SPDX-License-Identifier: Apache-2.0
#

message(STATUS "============================ HELLO FOR ${BOARD}")

set_ifndef(LPCLINK_FW jlink)

if(LPCLINK_FW STREQUAL jlink)
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/mps2_an385/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} cortex-m3)
set(QEMU_FLAGS_${ARCH}
-cpu ${QEMU_CPU_TYPE_${ARCH}}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} cortex-m3)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-cpu cortex-m3
-machine mps2-an385
-nographic
-vga none
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/mps2_an521/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} cortex-m33)
set(QEMU_FLAGS_${ARCH}
-cpu ${QEMU_CPU_TYPE_${ARCH}}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} cortex-m33)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-cpu cortex-m33
-machine mps2-an521
-nographic
-m 16
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/qemu_cortex_m0/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} cortex-m0)
set(QEMU_FLAGS_${ARCH}
-cpu ${QEMU_CPU_TYPE_${ARCH}}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} cortex-m0)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-cpu cortex-m0
-machine microbit
-nographic
-vga none
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/qemu_cortex_m3/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} cortex-m3)
set(QEMU_FLAGS_${ARCH}
-cpu ${QEMU_CPU_TYPE_${ARCH}}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} cortex-m3)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-cpu cortex-m3
-machine lm3s6965evb
-nographic
-vga none
Expand Down
6 changes: 3 additions & 3 deletions boards/arm/qemu_cortex_r5/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
set(EMU_PLATFORM qemu)
set(QEMU_ARCH aarch64)

set(QEMU_CPU_TYPE_${ARCH} cortex-r5)
set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} cortex-r5)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-nographic
-machine xlnx-zcu102
-global xlnx,zynqmp.boot-cpu="rpu-cpu[0]"
-smp 6
)

set(QEMU_KERNEL_OPTION
"-device;loader,file=$<TARGET_FILE:zephyr_final>,cpu-num=4"
"-device;loader,file=$<TARGET_FILE:${IMAGE}zephyr_final>,cpu-num=4"
)

board_set_debugger_ifnset(qemu)
5 changes: 2 additions & 3 deletions boards/nios2/qemu_nios2/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} nios2)

set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} nios2)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-machine altera_10m50_zephyr
-nographic
)
Expand Down
5 changes: 2 additions & 3 deletions boards/riscv/hifive1/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} riscv32)

set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} riscv32)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-nographic
-machine sifive_e
)
Expand Down
7 changes: 3 additions & 4 deletions boards/riscv/qemu_riscv32/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

set(EMU_PLATFORM qemu)

set(QEMU_binary_suffix riscv32)
set(QEMU_CPU_TYPE_${ARCH} riscv32)

set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_binary_suffix riscv32)
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} riscv32)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-nographic
-machine sifive_e
)
Expand Down
7 changes: 3 additions & 4 deletions boards/riscv/qemu_riscv64/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

set(EMU_PLATFORM qemu)

set(QEMU_binary_suffix riscv64)
set(QEMU_CPU_TYPE_${ARCH} riscv64)

set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_binary_suffix riscv64)
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} riscv64)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-nographic
-machine sifive_e
)
Expand Down
8 changes: 6 additions & 2 deletions boards/x86/qemu_x86/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ if(NOT CONFIG_REBOOT)
endif()

if(CONFIG_X86_LONGMODE)
set(QEMU_binary_suffix x86_64)
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_binary_suffix x86_64)
endif()

if(CONFIG_X86_LONGMODE)
set(QEMU_CPU_TYPE_${ARCH} qemu64,+x2apic)
else()
set(QEMU_CPU_TYPE_${ARCH} qemu32,+nx,+pae)
endif()

set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} ${QEMU_CPU_TYPE_${ARCH}})
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-m 9
-cpu ${QEMU_CPU_TYPE_${ARCH}}
-device isa-debug-exit,iobase=0xf4,iosize=0x04
Expand Down
2 changes: 1 addition & 1 deletion boards/x86_64/qemu_x86_64/board.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

set(EMU_PLATFORM qemu)
set(QEMU_FLAGS_${ARCH} -nographic)
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_FLAGS_${ARCH} -nographic)
4 changes: 2 additions & 2 deletions boards/xtensa/intel_s1000_crb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if(CONFIG_PINMUX_INTEL_S1000)
zephyr_library_sources(pinmux.c)
endif()

set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${BOARD_DIR}/support/create_board_img.py
set_property(TARGET ${ZEPHYR_TARGET} APPEND PROPERTY extra_post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${${IMAGE}BOARD_DIR}/support/create_board_img.py
-i ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin
-o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}_${BOARD}.bin
-l $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}>
Expand Down
5 changes: 2 additions & 3 deletions boards/xtensa/qemu_xtensa/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

set(EMU_PLATFORM qemu)

set(QEMU_CPU_TYPE_${ARCH} sample_controller)

set(QEMU_FLAGS_${ARCH}
set_target_properties(${ZEPHYR_TARGET} PROPERTIES QEMU_CPU_TYPE_${ARCH} sample_controller)
set_property(TARGET ${ZEPHYR_TARGET} PROPERTY QEMU_FLAGS_${ARCH}
-machine sim -semihosting -nographic -cpu sample_controller
)

Expand Down
19 changes: 19 additions & 0 deletions cmake/Kconfig.template.build_strategy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
#

choice
prompt "build strategy"
default $(image)_BUILD_STRATEGY_FROM_SOURCE

config $(image)_BUILD_STRATEGY_SKIP_BUILD
# Mandatory option when being built through 'zephyr_add_image'
bool "Skip building"

config $(image)_BUILD_STRATEGY_FROM_SOURCE
# Mandatory option when being built through 'zephyr_add_image'
bool "Build from source"

endchoice
Loading