Skip to content

Commit

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

This commit merges the multiple sub libraries under soc_arm and
arch_arm, e.g. arch_arm_Y_Z into a single arch_arm libraries.

It also moves arch related stray files from libzephyr.a and places them
inside the arch_${ARCH} and soc_${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 98d479e commit d55b171
Show file tree
Hide file tree
Showing 58 changed files with 272 additions and 189 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,7 @@ add_subdirectory(misc)
# property which is set implicitly for custom command outputs
include(misc/generated/CMakeLists.txt)

if(EXISTS ${SOC_DIR}/${ARCH}/CMakeLists.txt)
add_subdirectory(${SOC_DIR}/${ARCH} soc/${ARCH})
else()
add_subdirectory(${SOC_DIR}/${ARCH}/${SOC_PATH} soc/${ARCH}/${SOC_PATH})
endif()
add_subdirectory(${SOC_DIR} soc/${ARCH})

add_subdirectory(boards)
add_subdirectory(ext)
Expand Down
14 changes: 13 additions & 1 deletion arch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
add_definitions(-D__ZEPHYR_SUPERVISOR__)

add_library(arch_${ARCH} STATIC "")
target_link_libraries(arch_${ARCH} PUBLIC zephyr_interface)
target_link_libraries(zephyr_app_linking INTERFACE arch_${ARCH})

add_subdirectory(common)
add_subdirectory(${ARCH})

if( ${ARCH} STREQUAL arm )
include_relative(${ARCH}/CMakeLists.txt)
else()
# Not updated archs
add_subdirectory(${ARCH})
# To ensure a file is always present in arch not updated yet.
target_sources(arch_${ARCH} PRIVATE $ENV{ZEPHYR_BASE}/misc/empty_file.c)
endif()
2 changes: 1 addition & 1 deletion arch/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ zephyr_ld_options(
${ARCH_FLAG}
)

add_subdirectory(core)
include_relative(core/CMakeLists.txt)
48 changes: 24 additions & 24 deletions arch/arm/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
zephyr_library()

zephyr_library_sources(
exc_exit.S
irq_init.c
swap.c
swap_helper.S
fault.c
irq_manage.c
thread.c
cpu_idle.S
fault_s.S
fatal.c
sys_fatal_error_handler.c
thread_abort.c
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
exc_exit.S
irq_init.c
swap.c
swap_helper.S
fault.c
irq_manage.c
thread.c
cpu_idle.S
fault_s.S
fatal.c
sys_fatal_error_handler.c
thread_abort.c
IFDEF:${CONFIG_GEN_SW_ISR_TABLE} isr_wrapper.S
IFDEF:${CONFIG_CPLUSPLUS} __aeabi_atexit.c
IFDEF:${CONFIG_IRQ_OFFLOAD} irq_offload.c
IFDEF:${CONFIG_CPU_CORTEX_M0} irq_relay.S
IFDEF:${CONFIG_USERSPACE} userspace.S
)

zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S)
zephyr_library_sources_ifdef(CONFIG_CPLUSPLUS __aeabi_atexit.c)
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
zephyr_library_sources_ifdef(CONFIG_CPU_CORTEX_M0 irq_relay.S)
zephyr_library_sources_ifdef(CONFIG_USERSPACE userspace.S)
target_sources(arch_arm PRIVATE ${PRIVATE_SOURCES})

add_subdirectory_ifdef(CONFIG_CPU_CORTEX_M cortex_m)
add_subdirectory_ifdef(CONFIG_ARM_MPU cortex_m/mpu)
add_subdirectory_ifdef(CONFIG_CPU_CORTEX_M_HAS_CMSE cortex_m/cmse)
add_subdirectory_ifdef(CONFIG_ARM_SECURE_FIRMWARE cortex_m/tz)
include_relative_ifdef(CONFIG_CPU_CORTEX_M cortex_m/CMakeLists.txt)
include_relative_ifdef(CONFIG_ARM_MPU cortex_m/mpu/CMakeLists.txt)
include_relative_ifdef(CONFIG_CPU_CORTEX_M_HAS_CMSE cortex_m/cmse/CMakeLists.txt)
include_relative_ifdef(CONFIG_ARM_SECURE_FIRMWARE cortex_m/tz/CMakeLists.txt)
22 changes: 12 additions & 10 deletions arch/arm/core/cortex_m/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
zephyr_library()

zephyr_library_sources(
vector_table.S
reset.S
nmi_on_reset.S
prep_c.c
scb.c
nmi.c
exc_manage.c
)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
vector_table.S
reset.S
nmi_on_reset.S
prep_c.c
scb.c
nmi.c
exc_manage.c
)

target_sources(arch_arm PRIVATE ${PRIVATE_SOURCES})
2 changes: 1 addition & 1 deletion arch/arm/core/cortex_m/cmse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
zephyr_sources(arm_core_cmse.c)
target_sources(arch_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/arm_core_cmse.c)
18 changes: 10 additions & 8 deletions arch/arm/core/cortex_m/mpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
zephyr_library()

zephyr_library_sources( arm_core_mpu.c)
zephyr_library_sources_ifdef(CONFIG_CPU_HAS_ARM_MPU arm_mpu.c)
zephyr_library_sources_ifdef(CONFIG_CPU_HAS_NXP_MPU nxp_mpu.c)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
arm_core_mpu.c
IFDEF:${CONFIG_CPU_HAS_ARM_MPU} arm_mpu.c
IFDEF:${CONFIG_CPU_HAS_NXP_MPU} nxp_mpu.c
)

zephyr_library_include_directories(
.
../../../include/cortex_m
target_sources(arch_arm PRIVATE ${PRIVATE_SOURCES})
target_include_directories(arch_arm PRIVATE
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/arm/include/cortex_m
)
1 change: 1 addition & 0 deletions arch/arm/soc/nxp_kinetis/kl2x/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target_sources(arch_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
1 change: 1 addition & 0 deletions arch/arm/soc/silabs_exx32/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target_sources(arch_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc_gpio.c)
1 change: 1 addition & 0 deletions arch/arm/soc/silabs_exx32/efm32wg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target_sources(arch_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
16 changes: 7 additions & 9 deletions arch/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
# garbage collect them
zephyr_cc_option(-ffunction-sections -fdata-sections)

zephyr_sources_ifdef(
CONFIG_GEN_ISR_TABLES
isr_tables.c
sw_isr_common.c
)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
IFDEF:${CONFIG_GEN_ISR_TABLES} isr_tables.c
sw_isr_common.c
IFDEF:${CONFIG_EXECUTION_BENCHMARKING} timing_info_bench.c
)

zephyr_sources_ifdef(
CONFIG_EXECUTION_BENCHMARKING
timing_info_bench.c
)
target_sources(arch_${ARCH} PRIVATE ${PRIVATE_SOURCES})
20 changes: 20 additions & 0 deletions cmake/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ endmacro()
# param[in] IFNDEF:${KCONFIG_VAR} <item1> ... <itemN> Set the items <item1> ... <itemN> in the list
# if ${KCONFIG_VAR} is not defined or different
# from <y|True|1>
# param[in] IF_KCONFIG <item1> ... <itemN> Set the items <item1> ... <itemN> in the list
# if the matching KConfig value is defined and
# <y|True|1>.
# Can be used when <item> (directory / source
# file) have a matching KConfig value.
#
# Note, items to always add must come first in list before using the keywords IFDEF or IFNDEF.
# Note, the arguments APPEND, PREPEND_STR, OUTPUT must be specified before any file name is given.
Expand Down Expand Up @@ -435,15 +440,30 @@ function(zephyr_list)
if("${arg}" MATCHES "^IFDEF:(y|True|1)$")
# The IFDEF is y,True,1 and thus the following arguments are sources until next keyword.
set(PARSE_ARGUMENT_ITEMS True)
set(PARSE_KCONFIG_ITEMS False)
elseif("${arg}" MATCHES "^IFDEF:.*$")
# The IFDEF was either not given a y,True,1 value but is empty or something else, hense, skip sources unitil next keyword.
set(PARSE_ARGUMENT_ITEMS False)
set(PARSE_KCONFIG_ITEMS False)
elseif("${arg}" MATCHES "^IFNDEF:(y|True|1)$")
# The IFNDEF is y,True,1 and thus the following arguments are sources until next keyword, but IFNDEF means we shuld skip the files.
set(PARSE_ARGUMENT_ITEMS False)
set(PARSE_KCONFIG_ITEMS False)
elseif("${arg}" MATCHES "^IFNDEF:.*$")
# The IFNDEF was either not given a y,True,1 value but is empty or something else, so add sources until next keyword.
set(PARSE_ARGUMENT_ITEMS True)
set(PARSE_KCONFIG_ITEMS False)
elseif("${arg}" MATCHES "^IF_KCONFIG")
# IF_KCONFIG was specified, use the following values to look up corresponding KConfig setting.
set(PARSE_ARGUMENT_ITEMS False)
set(PARSE_KCONFIG_ITEMS True)
elseif(PARSE_KCONFIG_ITEMS)
# Only for sources for now
get_filename_component(arg_basename ${arg} NAME_WE)
string(TOUPPER CONFIG_${arg_basename} UPPER_CASE_CONFIG)
if(${UPPER_CASE_CONFIG})
list(APPEND LOCAL_LIST "${LOCAL_PREPEND_STR}${arg}")
endif()
elseif(PARSE_ARGUMENT_ITEMS)
list(APPEND LOCAL_LIST "${LOCAL_PREPEND_STR}${arg}")
endif()
Expand Down
10 changes: 10 additions & 0 deletions soc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
add_library(soc_${ARCH} STATIC "")
target_link_libraries(soc_${ARCH} PUBLIC zephyr_interface)
target_link_libraries(zephyr_app_linking INTERFACE soc_${ARCH})
zephyr_set_property(TARGET soc_${ARCH} MEMORY_SPACE kernel)

if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/${ARCH}/CMakeLists.txt)
include(${SOC_DIR}/${ARCH}/CMakeLists.txt)
else()
include(${SOC_DIR}/${ARCH}/${SOC_PATH}/CMakeLists.txt)
endif()
2 changes: 1 addition & 1 deletion soc/arm/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_subdirectory(${SOC_SERIES})
include_relative(${SOC_SERIES}/CMakeLists.txt)
13 changes: 8 additions & 5 deletions soc/arm/arm/beetle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
zephyr_sources(
soc.c
power.c
)
zephyr_sources_ifdef(CONFIG_ARM_MPU arm_mpu_regions.c)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
soc.c
power.c
IFDEF:${CONFIG_ARM_MPU} arm_mpu_regions.c
)

target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
7 changes: 3 additions & 4 deletions soc/arm/arm/mps2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
zephyr_sources(
soc.c
arm_mpu_regions.c
)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c
${CMAKE_CURRENT_LIST_DIR}/arm_mpu_regions.c
)
4 changes: 2 additions & 2 deletions soc/arm/atmel_sam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# SPDX-License-Identifier: Apache-2.0
#

add_subdirectory(${SOC_SERIES})
add_subdirectory_ifdef(CONFIG_ASF common)
include_relative(${SOC_SERIES}/CMakeLists.txt)
include_relative_ifdef(CONFIG_ASF common/CMakeLists.txt)
16 changes: 8 additions & 8 deletions soc/arm/atmel_sam/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
zephyr_include_directories(.)
zephyr_sources(
soc_pmc.c
soc_gpio.c
)

zephyr_sources_ifdef(
CONFIG_ARM_MPU
arm_mpu_regions.c
)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
soc_pmc.c
soc_gpio.c
IFDEF:${CONFIG_ARM_MPU} arm_mpu_regions.c
)

target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
4 changes: 1 addition & 3 deletions soc/arm/atmel_sam/sam3x/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
zephyr_sources(
soc.c
)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
4 changes: 1 addition & 3 deletions soc/arm/atmel_sam/sam4s/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
zephyr_sources(
soc.c
)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
11 changes: 7 additions & 4 deletions soc/arm/atmel_sam/same70/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
zephyr_sources(
soc.c
soc_config.c
)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
soc.c
soc_config.c
)

target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
2 changes: 1 addition & 1 deletion soc/arm/atmel_sam0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Copyright (c) 2017 Google LLC.
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(${SOC_SERIES})
include_relative(${SOC_SERIES}/CMakeLists.txt)
2 changes: 1 addition & 1 deletion soc/arm/atmel_sam0/samd20/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Copyright (c) 2018 Sean Nyekjaer
# SPDX-License-Identifier: Apache-2.0

zephyr_sources(soc.c)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
3 changes: 1 addition & 2 deletions soc/arm/atmel_sam0/samd21/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
#
# Copyright (c) 2017 Google LLC.
# SPDX-License-Identifier: Apache-2.0

zephyr_sources(soc.c)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
2 changes: 1 addition & 1 deletion soc/arm/cypress/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# SPDX-License-Identifier: Apache-2.0
#

add_subdirectory(${SOC_SERIES})
include_relative(${SOC_SERIES}/CMakeLists.txt)
6 changes: 1 addition & 5 deletions soc/arm/cypress/psoc6/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@
#
# SPDX-License-Identifier: Apache-2.0
#

zephyr_include_directories(.)
zephyr_sources(
soc.c
)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
2 changes: 1 addition & 1 deletion soc/arm/nordic_nrf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ zephyr_include_directories(
include
)

add_subdirectory(${SOC_SERIES})
include_relative(${SOC_SERIES}/CMakeLists.txt)
7 changes: 3 additions & 4 deletions soc/arm/nordic_nrf/nrf51/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
zephyr_sources(
power.c
soc.c
)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c
${CMAKE_CURRENT_LIST_DIR}/power.c
)
12 changes: 7 additions & 5 deletions soc/arm/nordic_nrf/nrf52/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
zephyr_sources(
power.c
soc.c
)
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
power.c
soc.c
IFDEF:${CONFIG_ARM_MPU} mpu_regions.c
)

zephyr_sources_ifdef(CONFIG_ARM_MPU mpu_regions.c)
target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
2 changes: 1 addition & 1 deletion soc/arm/nxp_imx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# SPDX-License-Identifier: Apache-2.0
#

add_subdirectory(${SOC_SERIES})
include_relative(${SOC_SERIES}/CMakeLists.txt)
3 changes: 1 addition & 2 deletions soc/arm/nxp_imx/mcimx6x_m4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
#
# SPDX-License-Identifier: Apache-2.0
#

zephyr_sources(soc.c)
target_sources(soc_arm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/soc.c)
10 changes: 6 additions & 4 deletions soc/arm/nxp_imx/mcimx7_m4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#
# SPDX-License-Identifier: Apache-2.0
#
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
soc.c
soc_clk_freq.c
)

zephyr_sources(
soc.c
soc_clk_freq.c
)
target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
11 changes: 6 additions & 5 deletions soc/arm/nxp_imx/rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#
# SPDX-License-Identifier: Apache-2.0
#
zephyr_list(SOURCES
OUTPUT PRIVATE_SOURCES
soc.c
IFDEF:${CONFIG_ARM_MPU} arm_mpu_regions.c
)

zephyr_sources(
soc.c
)

zephyr_sources_ifdef(CONFIG_ARM_MPU arm_mpu_regions.c)
target_sources(soc_arm PRIVATE ${PRIVATE_SOURCES})
Loading

0 comments on commit d55b171

Please sign in to comment.