Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
jlatusek committed Dec 7, 2023
1 parent 3308a3a commit 9505eb8
Showing 1 changed file with 37 additions and 30 deletions.
67 changes: 37 additions & 30 deletions src/test_driver/openiotsdk/unit-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,28 @@ set(CONFIG_CHIP_AUTOMATION_LOGGING YES)
set(CONFIG_CHIP_ERROR_LOGGING NO)

set(PW_ROOT ${CHIP_ROOT}/third_party/pigweed/repo)
set(pw_unit_test_AUTOMATIC_RUNNER "")
set(pw_sys_io_BACKEND "pw_sys_io_stdio")
set(pw_assert_BACKEND "pw_assert_log")
set(pw_log_BACKEND "pw_log_basic")
# set(pw_unit_test_AUTOMATIC_RUNNER "")
# set(pw_unit_test_MAIN "")
# set(pw_sys_io_BACKEND "pw_sys_io_stdio")
# set(pw_assert_BACKEND "pw_assert_log")
# set(pw_log_BACKEND "pw_log_basic")


# Toolchain files need to exist before first call to project
include(toolchain)

project(chip-open-iot-sdk-unit-tests LANGUAGES C CXX ASM)

include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
include($ENV{PW_ROOT}/pw_unit_test/test.cmake)
include(${PW_ROOT}/pw_build/pigweed.cmake)
include(${PW_ROOT}/pw_unit_test/test.cmake)
include(${PW_ROOT}/pw_assert/backend.cmake)
include(${PW_ROOT}/pw_log/backend.cmake)
include(${PW_ROOT}/pw_sys_io/backend.cmake)

pw_set_backend(pw_log pw_log_basic)
pw_set_backend(pw_assert.check pw_assert_log.check_backend)
pw_set_backend(pw_assert.assert pw_assert.assert_compatibility_backend)
pw_set_backend(pw_sys_io pw_sys_io_stdio)

include(sdk)
include(chip)
Expand All @@ -51,13 +61,15 @@ add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build)
add_subdirectory(${PW_ROOT} pigweed_build)

file(STRINGS test_components.txt TEST_NAMES_FROM_FILE)
# TODO [PW_MIGRATION] Remove the following variable once the migration to pw_unit_test is complete.
file(STRINGS test_components_nl.txt TEST_NAMES_FROM_FILE_NL)

target_compile_definitions(openiotsdk-startup
PRIVATE
IOT_SDK_APP_MAIN_STACK_SIZE=20480
)

# TODO [PW_MIGRATION] Remove the following targets once the migration to pw_unit_test is complete.
foreach(TEST_NAME IN LISTS TEST_NAMES_FROM_FILE_NL)
set(APP_TARGET ${TEST_NAME}_ns)
add_executable(${APP_TARGET})
Expand Down Expand Up @@ -90,36 +102,31 @@ endforeach()

foreach(TEST_NAME IN LISTS TEST_NAMES_FROM_FILE)
set(APP_TARGET ${TEST_NAME}_ns)
# add_executable(${APP_TARGET})
pw_add_test(${APP_TARGET}
SOURCES
main/main_ns.cpp
PRIVATE_DEPS
openiotsdk-startup
openiotsdk-app
# pw_unit_test
PRIVATE_LINK_OPTIONS
-Wl,--whole-archive "${CMAKE_CURRENT_BINARY_DIR}/chip_build/lib/lib${TEST_NAME}.a"
-Wl,--no-whole-archive
)
target_include_directories(${APP_TARGET}.bin
add_executable(${APP_TARGET})
target_include_directories(${APP_TARGET}
PRIVATE
main/include
${CHIP_ROOT}/third_party/nlunit-test/repo/src
)

# target_sources(${APP_TARGET}
# PRIVATE
# main/main_ns.cpp
# )
target_sources(${APP_TARGET}
PRIVATE
main/main_ns.cpp
)

# target_link_libraries(${APP_TARGET}.bin
# openiotsdk-startup
# openiotsdk-app
# pw_unit_test
# )
target_link_libraries(${APP_TARGET} PRIVATE
PRIVATE
openiotsdk-startup
openiotsdk-app
pw_unit_test
)

# Link the *whole-archives* to keep the static test objects.
target_link_options(${APP_TARGET}
PUBLIC
-Wl,--whole-archive "${CMAKE_CURRENT_BINARY_DIR}/chip_build/lib/lib${TEST_NAME}.a"
-Wl,--no-whole-archive)

set_target_link(${APP_TARGET}.bin)
sdk_post_build(${APP_TARGET}.bin)
set_target_link(${APP_TARGET})
sdk_post_build(${APP_TARGET})
endforeach()

0 comments on commit 9505eb8

Please sign in to comment.