Skip to content

Commit a468f27

Browse files
authored
Fix application profile link mess (#410)
* Fix mbed-rtos-flags/mbed-rtos-sources typo * Fix parameter order error to mbed_setup_linker_script * Support application profile link selection This provides one approach to address cmake link mess with mbed-core-flags/mbed-rtos-flags whose links or not depends on selected application profile, full or bare-metal. 1. Add target config option application-profile for application to select which application profile to use. Applications are responsible for making this target config option consitent with link selection of mbed-os/mbed-baremetal. 2. Overload mbed-core-flags/mbed-core-sources so that they can involve mbed-rtos-flags/mbed-rtos-sources or not depending on target.application-profile setting * Guard from mismatch of target.application-profile and mbed-os/mbed-baremetal This guards from mismatch of target.application-profile and link libraries mbed-os/mbed-baremetal. * Make all libraries link mbed-core-flags instead of mbed-rtos-flags With mbed-core-flags overloaded to match target.application-profile setting, all libraries should link mbed-core-flags instead of mbed-rtos-flags so that they build upon correct application profile, involving mbed-rtos-flags or not. * Make mbed-os link mbed-core-flags/mbed-core-sources only With mbed-core-flags/mbed-core-sources being overloaded to match target.application-profile setting, mbed-os should link only mbed-core-flags/mbed-core-sources which will involve mbed-rtos-flags/ mbed-rtos-sources as config. * Remove MBED_GREENTEA_TEST_BAREMETAL from target.application-profile MBED_GREENTEA_TEST_BAREMETAL can become deprecated and be removed. The 'auto' option of target.application-profile needn't respect it. * Respect target.application-profile setting for Greentea build MBED_GREENTEA_TEST_BAREMETAL can become deprecated and be removed. Respect target.application-profile setting instead to resolve link library.
1 parent 875cc5d commit a468f27

File tree

18 files changed

+56
-25
lines changed

18 files changed

+56
-25
lines changed

CMakeLists.txt

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,28 @@ endif()
116116
# These targets are made visible here so their source files which
117117
# are spread in different directories can be referenced and can be linked against
118118
# by libraries that depend on them.
119-
add_library(mbed-rtos-flags INTERFACE) # Collects source files that are in mbed-os but not mbed-baremetal
120-
add_library(mbed-rtos-sources INTERFACE) # Collects flags that are in mbed-os but not mbed-baremetal
121-
add_library(mbed-core-flags INTERFACE) # Collects flags common to mbed-baremetal and mbed-os
122-
add_library(mbed-core-sources INTERFACE) # Collects source files common to mbed-baremetal and mbed-os
119+
add_library(mbed-rtos-flags INTERFACE) # Collects flags that are in mbed-os but not mbed-baremetal
120+
add_library(mbed-rtos-sources INTERFACE) # Collects source files that are in mbed-os but not mbed-baremetal
121+
add_library(mbed-core-flags INTERFACE) # Collects flags that are in mbed-os or mbed-baremetal
122+
# depending on target.application-profile setting
123+
add_library(mbed-core-sources INTERFACE) # Collects source files that are in mbed-os or mbed-baremetal
124+
# depending on target.application-profile setting
125+
126+
if("MBED_CONF_TARGET_APPLICATION_PROFILE=full" IN_LIST MBED_CONFIG_DEFINITIONS)
127+
set(APPLICATION_PROFILE_CONFIG_FULL TRUE)
128+
endif()
129+
if("MBED_CONF_TARGET_APPLICATION_PROFILE=bare-metal" IN_LIST MBED_CONFIG_DEFINITIONS)
130+
set(APPLICATION_PROFILE_CONFIG_BAREMETAL TRUE)
131+
endif()
132+
if(NOT APPLICATION_PROFILE_CONFIG_FULL AND NOT APPLICATION_PROFILE_CONFIG_BAREMETAL)
133+
set(APPLICATION_PROFILE_CONFIG_AUTO TRUE)
134+
endif()
135+
136+
# mbed-core-flags/mbed-core-sources link mbed-rtos-flags/mbed-rtos-sources or not
137+
if(APPLICATION_PROFILE_CONFIG_AUTO OR APPLICATION_PROFILE_CONFIG_FULL)
138+
target_link_libraries(mbed-core-flags INTERFACE mbed-rtos-flags)
139+
target_link_libraries(mbed-core-sources INTERFACE mbed-rtos-sources)
140+
endif()
123141

124142
# Validate selected C library type
125143
# The C library type selected has to match the library that the target can support
@@ -282,10 +300,10 @@ if(NOT MBED_IS_NATIVE_BUILD)
282300
# Note that many different source files will compile differently depending on if the RTOS is in use.
283301
# So, it's needed to compile the core sources twice, once for RTOS and once for non-RTOS.
284302
mbed_create_distro(mbed-baremetal ${MBED_TARGET_CMAKE_NAME} mbed-core-flags mbed-core-sources)
285-
mbed_create_distro(mbed-os ${MBED_TARGET_CMAKE_NAME} mbed-core-flags mbed-core-sources mbed-rtos-flags mbed-rtos-sources)
303+
mbed_create_distro(mbed-os ${MBED_TARGET_CMAKE_NAME} mbed-core-flags mbed-core-sources)
286304

287305
# Set up the linker script and hook it up to the top-level OS targets
288-
mbed_setup_linker_script(mbed-baremetal mbed-os ${CMAKE_CURRENT_BINARY_DIR}/generated-headers/mbed-target-config.h)
306+
mbed_setup_linker_script(mbed-os mbed-baremetal ${CMAKE_CURRENT_BINARY_DIR}/generated-headers/mbed-target-config.h)
289307

290308
# Make sure that things linking mbed-core-flags can also get the target-specific include dirs and flags.
291309
mbed_extract_flags(${MBED_TARGET_CMAKE_NAME}-flags ${MBED_TARGET_CMAKE_NAME})

TESTS/configs/greentea_baremetal.json5

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"target_overrides": {
33
"*": {
4-
"target.c_lib": "small"
4+
"target.c_lib": "small",
5+
"target.application-profile": "bare-metal"
56
}
67
},
78
"overrides": {

connectivity/cellular/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ target_link_libraries(mbed-cellular
3939
PUBLIC
4040
mbed-netsocket-api
4141
mbed-core-flags
42-
mbed-rtos-flags
4342
mbed-randlib
4443
)

connectivity/drivers/802.15.4_RF/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro(create_mbed_802_15_4_target)
77
add_library(mbed-802.15.4-rf STATIC EXCLUDE_FROM_ALL)
88

99
# Nanostack drivers always require Mbed RTOS
10-
target_link_libraries(mbed-802.15.4-rf PUBLIC mbed-core-flags mbed-rtos-flags)
10+
target_link_libraries(mbed-802.15.4-rf PUBLIC mbed-core-flags)
1111

1212
# For NanostackRfPhy.h
1313
target_link_libraries(mbed-802.15.4-rf PUBLIC mbed-nanostack)

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_BlueNRG_2/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ target_link_libraries(mbed-bluenrg2
88
PUBLIC
99
mbed-core-flags
1010
mbed-ble
11-
PRIVATE
12-
mbed-rtos-flags)
11+
)
1312

1413
# circular dependency between mbed-ble and the BlueNRG driver, because of the ble_cordio_get_hci_driver() implementation
1514
target_link_libraries(mbed-ble PUBLIC mbed-bluenrg2)

connectivity/drivers/ble/FEATURE_BLE/COMPONENT_BlueNRG_MS/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ target_link_libraries(mbed-bluenrg-ms
88
PUBLIC
99
mbed-core-flags
1010
mbed-ble
11-
PRIVATE
12-
mbed-rtos-flags)
11+
)
1312

1413

1514
# circular dependency between mbed-ble and the BlueNRG driver, because of the ble_cordio_get_hci_driver() implementation

connectivity/drivers/emac/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ target_link_libraries(mbed-emac
3333
PUBLIC
3434
mbed-netsocket-api
3535
PRIVATE
36-
mbed-rtos-flags
36+
mbed-core-flags
3737
)

connectivity/drivers/wifi/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ macro(create_mbed_wifi_target)
88

99
target_link_libraries(mbed-wifi
1010
PUBLIC
11-
mbed-rtos-flags
11+
mbed-core-flags
1212
mbed-netsocket-api
1313
)
1414
endif()

connectivity/drivers/wifi/COMPONENT_WHD/whd-bsp-integration/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ target_sources(mbed-wifi
1515
target_link_libraries(mbed-wifi
1616
PUBLIC
1717
mbed-lwipstack
18-
mbed-rtos-flags
18+
mbed-core-flags
1919
)
2020

2121
if("DEVICE_EMAC=1" IN_LIST MBED_TARGET_DEFINITIONS)

connectivity/libraries/ppp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ target_link_libraries(mbed-ppp
5757
PUBLIC
5858
mbed-netsocket-api
5959
PRIVATE
60-
mbed-rtos-flags
60+
mbed-core-flags
6161
)

0 commit comments

Comments
 (0)