Skip to content

Commit 6cd3f14

Browse files
committed
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
1 parent fb69ee2 commit 6cd3f14

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

CMakeLists.txt

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,40 @@ endif()
118118
# by libraries that depend on them.
119119
add_library(mbed-rtos-flags INTERFACE) # Collects flags that are in mbed-os but not mbed-baremetal
120120
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 common to mbed-baremetal and mbed-os
122-
add_library(mbed-core-sources INTERFACE) # Collects source files common to mbed-baremetal and mbed-os
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) AND
138+
(NOT MBED_ENABLE_OS_INTERNAL_TESTS OR NOT MBED_BUILD_GREENTEA_TESTS OR NOT MBED_GREENTEA_TEST_BAREMETAL))
139+
target_link_libraries(mbed-core-flags INTERFACE mbed-rtos-flags)
140+
target_link_libraries(mbed-core-sources INTERFACE mbed-rtos-sources)
141+
endif()
142+
143+
# Check if target.application-profile matches MBED_GREENTEA_TEST_BAREMETAL
144+
if(MBED_ENABLE_OS_INTERNAL_TESTS AND MBED_BUILD_GREENTEA_TESTS)
145+
if(application_profile_config_full AND MBED_GREENTEA_TEST_BAREMETAL)
146+
message(FATAL_ERROR
147+
"target.application-profile (full) doesn't match MBED_GREENTEA_TEST_BAREMETAL (TRUE)"
148+
)
149+
elseif(application_profile_config_baremetal AND NOT MBED_GREENTEA_TEST_BAREMETAL)
150+
message(FATAL_ERROR
151+
"target.application-profile (bare-metal) doesn't match MBED_GREENTEA_TEST_BAREMETAL (FALSE)"
152+
)
153+
endif()
154+
endif()
123155

124156
# Validate selected C library type
125157
# The C library type selected has to match the library that the target can support

targets/targets.json5

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
"semihosting-enabled": {
101101
"help": "Enable ARM Semihosting protocol. This uses a magic breakpoint instruction to enable the MCU to print data to and access files on a host machine. However, it can interfere with debuggers that are not semihost aware.",
102102
"value": false
103+
},
104+
"application-profile": {
105+
"help": "Select application profile. Options: auto, full, bare-metal.",
106+
"value": "auto"
103107
}
104108
}
105109
},

0 commit comments

Comments
 (0)