Skip to content

Commit 95d3716

Browse files
committed
Incorporating the review comments
1 parent 1dd6af0 commit 95d3716

File tree

2 files changed

+71
-41
lines changed

2 files changed

+71
-41
lines changed

tools/cmake/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,20 @@ If you're running CMake directly, you may need to pass it in yourself as follows
7575
```
7676
cmake -S <source-dir> -B <build-dir> -DCMAKE_BUILD_TYPE=debug
7777
```
78+
79+
## How to build a greentea test
80+
81+
Install prerequisites suggested in the previous section and follow the below steps to build:
82+
* Generate .mbed_build configuration for DISCO_L475VG_IOT01A target from blinky example and copied into the test_suite directory.
83+
* Change directory into the test suite directory
84+
* run below command to build full profile green tea
85+
86+
```
87+
touch mbed-os.lib;mkdir build;cd build;cmake .. -GNinja;cmake --build .
88+
```
89+
* run below command to build baremetal profile green tea
90+
```
91+
touch mbed-os.lib;mkdir build;cd build;cmake .. -GNinja -DMBED_BAREMETAL_GREENTEA_TEST=ON;cmake --build .
92+
```
93+
94+
Note: This steps will get evolve once mbedtools have a proper way of invoking greentea test using mbedtools command

tools/cmake/mbed_greentea.cmake

+54-41
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
2-
# SPDX-License-Identifier: Apache-2.0# the macro
2+
# SPDX-License-Identifier: Apache-2.0
33

44
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
55

@@ -13,53 +13,66 @@ include(${MBED_PATH}/tools/cmake/app.cmake)
1313
# TEST_REQUIRED_LIBS - Test suite required libraries
1414
#
1515
# calling the macro:
16-
# mbed_greentea_cmake_macro(TEST_NAME mbed-platform-system-reset TEST_INCLUDE_DIRS mbed_store TEST_SOURCES foo.cpp bar.cpp TEST_REQUIRED_LIBS mbed-kvstore mbed-xyz)
16+
# mbed_greentea_cmake_macro(
17+
# TEST_NAME mbed-platform-system-reset
18+
# TEST_INCLUDE_DIRS mbed_store
19+
# TEST_SOURCES foo.cpp bar.cpp
20+
# TEST_REQUIRED_LIBS mbed-kvstore mbed-xyz
21+
# )
1722

1823
macro(mbed_greentea_cmake_macro)
1924
set(options)
2025
set(singleValueArgs TEST_NAME)
21-
set(multipleValueArgs TEST_INCLUDE_DIRS TEST_SOURCES TEST_REQUIRED_LIBS)
22-
cmake_parse_arguments(MBED_GREENTEA "${options}" "${singleValueArgs}"
23-
"${multipleValueArgs}" ${ARGN} )
24-
25-
set(TEST_NAME ${MBED_GREENTEA_TEST_NAME})
26-
27-
add_subdirectory(${MBED_PATH} build)
28-
29-
add_executable(${TEST_NAME})
30-
31-
mbed_configure_app_target(${TEST_NAME})
32-
33-
mbed_set_mbed_target_linker_script(${TEST_NAME})
34-
35-
target_include_directories(${TEST_NAME}
36-
PRIVATE
37-
.
38-
${MBED_GREENTEA_TEST_INCLUDE_DIRS}
39-
)
40-
41-
target_sources(${TEST_NAME}
42-
PRIVATE
43-
main.cpp
44-
${MBED_GREENTEA_TEST_SOURCES}
45-
)
46-
47-
if(MBED_BAREMETAL_GREENTEA_TEST)
48-
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-baremetal mbed-greentea)
49-
else()
26+
set(multipleValueArgs
27+
TEST_INCLUDE_DIRS
28+
TEST_SOURCES
29+
TEST_REQUIRED_LIBS
30+
)
31+
cmake_parse_arguments(MBED_GREENTEA
32+
"${options}"
33+
"${singleValueArgs}"
34+
"${multipleValueArgs}"
35+
${ARGN}
36+
)
37+
38+
set(TEST_NAME ${MBED_GREENTEA_TEST_NAME})
39+
40+
add_subdirectory(${MBED_PATH} build)
41+
42+
add_executable(${TEST_NAME})
43+
44+
mbed_configure_app_target(${TEST_NAME})
45+
46+
mbed_set_mbed_target_linker_script(${TEST_NAME})
47+
48+
target_include_directories(${TEST_NAME}
49+
PRIVATE
50+
.
51+
${MBED_GREENTEA_TEST_INCLUDE_DIRS}
52+
)
53+
54+
target_sources(${TEST_NAME}
55+
PRIVATE
56+
main.cpp
57+
${MBED_GREENTEA_TEST_SOURCES}
58+
)
59+
60+
if(MBED_BAREMETAL_GREENTEA_TEST)
61+
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-baremetal mbed-greentea)
62+
else()
5063
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os mbed-greentea)
51-
endif()
64+
endif()
5265

53-
target_link_libraries(${TEST_NAME}
54-
PRIVATE
55-
${MBED_GREENTEA_TEST_REQUIRED_LIBS}
56-
)
66+
target_link_libraries(${TEST_NAME}
67+
PRIVATE
68+
${MBED_GREENTEA_TEST_REQUIRED_LIBS}
69+
)
5770

58-
mbed_set_post_build(${TEST_NAME})
71+
mbed_set_post_build(${TEST_NAME})
5972

60-
option(VERBOSE_BUILD "Have a verbose build process")
61-
if(VERBOSE_BUILD)
62-
set(CMAKE_VERBOSE_MAKEFILE ON)
63-
endif()
73+
option(VERBOSE_BUILD "Have a verbose build process")
74+
if(VERBOSE_BUILD)
75+
set(CMAKE_VERBOSE_MAKEFILE ON)
76+
endif()
6477

6578
endmacro()

0 commit comments

Comments
 (0)