Skip to content

Commit

Permalink
cmake: Merged n times arch_xtensa_Y libs into soc_xtensa and arch_xtensa
Browse files Browse the repository at this point in the history
Fixes: zephyrproject-rtos#8441

This commit merges the multiple sub libraries under soc_xtense and
arch_xtensa, e.g. arch_xtensa_Y_Z into a single arch_xtensa libraries.

It also moves arch related stray files from libzephyr.a and places them
inside the arch_${ARCH} library, see zephyrproject-rtos#8826.

Signed-off-by: Torsten Rasmussen <torsten.rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand committed Dec 6, 2018
1 parent 340fa5e commit 8b8adf8
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 43 deletions.
1 change: 1 addition & 0 deletions arch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ if( ( ${ARCH} STREQUAL arm ) OR
( ${ARCH} STREQUAL arc ) OR
( ${ARCH} STREQUAL posix ) OR
( ${ARCH} STREQUAL riscv32 ) OR
( ${ARCH} STREQUAL xtensa ) OR
( ${ARCH} STREQUAL nios2 )
)
include_relative(${ARCH}/CMakeLists.txt)
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-xtensa-le)
add_subdirectory(core)
include_relative(core/CMakeLists.txt)
48 changes: 21 additions & 27 deletions arch/xtensa/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
zephyr_cc_option(-mlongcalls)
zephyr_sources(
cpu_idle.c
fatal.c
window_vectors.S
)

zephyr_sources_ifdef(CONFIG_XTENSA_ASM2
xtensa-asm2-util.S
xtensa-asm2.c
)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
cpu_idle.c
fatal.c
window_vectors.S
IFDEF:${CONFIG_XTENSA_ASM2} xtensa-asm2-util.S
xtensa-asm2.c
IFDEF:${CONFIG_XTENSA_USE_CORE_CRT1} crt1.S
IFDEF:${CONFIG_IRQ_OFFLOAD} irq_offload.c
IFNDEF:${CONFIG_XTENSA_ASM2} xtensa_intr.c
irq_manage.c
swap.S
thread.c
xtensa_context.S
xtensa_intr_asm.S
xtensa_vectors.S
xt_zephyr.S
IFNDEF:${CONFIG_ATOMIC_OPERATIONS_C} atomic.S
)

zephyr_sources_ifndef(CONFIG_XTENSA_ASM2
xtensa_intr.c
irq_manage.c
swap.S
thread.c
xtensa_context.S
xtensa_intr_asm.S
xtensa_vectors.S
xt_zephyr.S
)
target_sources(arch_xtensa PRIVATE ${PRIVATE_SOURCES})

zephyr_sources_ifndef(CONFIG_ATOMIC_OPERATIONS_C atomic.S)
zephyr_sources_ifdef(CONFIG_XTENSA_USE_CORE_CRT1
crt1.S
)
zephyr_sources_ifdef(CONFIG_IRQ_OFFLOAD
irq_offload.c
)
add_subdirectory(startup)
include_relative(startup/CMakeLists.txt)
22 changes: 10 additions & 12 deletions arch/xtensa/core/startup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
if(CONFIG_XTENSA_RESET_VECTOR)
zephyr_library()
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
reset-vector.S
memerror-vector.S
memctl_default.S
)
zephyr_sources_cc_option( SOURCES ${PRIVATE_SOURCES}
OPTIONS -c -mtext-section-literals -mlongcalls
)

zephyr_library_cc_option(
-c
-mtext-section-literals
-mlongcalls
)

zephyr_library_sources(
reset-vector.S
memerror-vector.S
memctl_default.S
)
target_sources(arch_xtensa PRIVATE ${PRIVATE_SOURCES})
endif()
7 changes: 7 additions & 0 deletions arch/xtensa/soc/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
soc.c
esp32-mp.c
)

target_sources(arch_xtensa PRIVATE ${PRIVATE_SOURCES})
37 changes: 37 additions & 0 deletions cmake/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,43 @@ function(zephyr_library_cc_option)
endforeach()
endfunction()

function(zephyr_sources_cc_option)
set(multi_args SOURCES OPTIONS)
cmake_parse_arguments(ZEPHYR_CC_OPTIONS "" "" "${multi_args}" ${ARGN} )

if(ZEPHYR_CC_OPTIONS_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "zephyr_sources_cc_option called with unknown argument(s): \n\
${ZEPHYR_CC_OPTIONS_UNPARSED_ARGUMENTS}\n\
Syntax is: zephyr_sources_cc_option(SOURCES src [src [...]]\n\
OPTIONS opt [opt [...]]")
endif()

foreach(option ${ZEPHYR_CC_OPTIONS_OPTIONS})
string(MAKE_C_IDENTIFIER check${option} check)
zephyr_check_compiler_flag(C ${option} ${check})

if(${check})
# The looping over each source is because zephyr currently requires
# cmake version 3.8.2-3.10 only support COMPILE_FLAGS on each source
# COMPILE_FLAGS is a string and thus on each source must fetch and
# update the string.
# Note: APPEND will not work as the string will then contain ';' later in
# the process due to APPEND treating the string as a list
foreach(source ${ZEPHYR_CC_OPTIONS_SOURCES})
GET_PROPERTY( OPTIONS SOURCE ${source}
PROPERTY COMPILE_FLAGS)
SET_PROPERTY( SOURCE ${source}
PROPERTY COMPILE_FLAGS "${OPTIONS} ${option}")
endforeach()
# If updating cmake_minimum_required(...) to 3.11 or later the following
# simplified code can be used instead of the above foreach() loop, as
# COMPILE_OPTIONS is a new property supported on sources.
# SET_PROPERTY( SOURCE ${ZEPHYR_CC_OPTIONS_SOURCES}
# APPEND PROPERTY COMPILE_OPTIONS ${option})
endif()
endforeach()
endfunction()

# Add the existing CMake library 'library' to the global list of
# Zephyr CMake libraries. This is done automatically by the
# constructor but must called explicitly on CMake libraries that do
Expand Down
2 changes: 1 addition & 1 deletion soc/xtensa/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ zephyr_list(SOURCES
soc_config.c
)

target_sources(arch_arm PRIVATE ${PRIVATE_SOURCES})
target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
3 changes: 1 addition & 2 deletions soc/xtensa/intel_s1000/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
zephyr_library()
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
zephyr_library_sources(soc.c)
target_sources(soc_xtensa PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
1 change: 1 addition & 0 deletions soc/xtensa/sample_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# intentionally left empty
target_sources(soc_xtensa PRIVATE ${ZEPHYR_BASE}/misc/empty_file.c)

0 comments on commit 8b8adf8

Please sign in to comment.