diff options
author | Yuval Peress <peress@google.com> | 2022-07-19 23:15:16 -0600 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-20 21:55:33 +0000 |
commit | 72f82950205d47a83442f610b6c57c210b45fe25 (patch) | |
tree | 3776f735d8904b670a35f7df7137c5edacd1355d | |
parent | edddbb2066ea245f6b9c88b4090a98252a0b1ee5 (diff) | |
download | chrome-ec-72f82950205d47a83442f610b6c57c210b45fe25.tar.gz |
zephyr: test: drivers: Simplify build rules
Replace the complicated library mechanism with a more native cmake
construct. The idea of having separate libraries works great in
theory but it really wasn't working well. For this to properly work
one of the following would need to happen:
1. The cros ec would need to be compiled as a library adding the
include path with PUBLIC visibility. Test libraries can then link
to the cros ec library.
2. The cros ec headers would be added directly to zephyr using
zephyr_include_directories. The downside of this approach is that
it adds the chromium headers at the same level as Zephyr's (which
are visible at the system like <> include brackets).
BRANCH=none
BUG=none
TEST=zmake test test-drivers*
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: Iefbab4c4745f6ce4c0a8dc61018db9554c204434
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3774764
Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Reviewed-by: Aaron Massey <aaronmassey@google.com>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | zephyr/test/drivers/CMakeLists.txt | 5 | ||||
-rw-r--r-- | zephyr/test/drivers/chargesplash/CMakeLists.txt | 15 | ||||
-rw-r--r-- | zephyr/test/drivers/isl923x/CMakeLists.txt | 21 | ||||
-rw-r--r-- | zephyr/test/drivers/led_driver/CMakeLists.txt | 16 | ||||
-rw-r--r-- | zephyr/test/drivers/usb_malfunction_sink/CMakeLists.txt | 15 | ||||
-rw-r--r-- | zephyr/test/drivers/usbc_alt_mode/CMakeLists.txt | 9 |
6 files changed, 13 insertions, 68 deletions
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt index 91b90a9dc4..1db421dd7b 100644 --- a/zephyr/test/drivers/CMakeLists.txt +++ b/zephyr/test/drivers/CMakeLists.txt @@ -6,8 +6,9 @@ cmake_minimum_required(VERSION 3.13.1) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(${ZMAKE_PROJECT_NAME}) -zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -zephyr_include_directories("${PLATFORM_EC}/driver/ppc/") +target_include_directories(app PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/include + "${PLATFORM_EC}/driver/ppc/") # Common sources target_sources(app PRIVATE diff --git a/zephyr/test/drivers/chargesplash/CMakeLists.txt b/zephyr/test/drivers/chargesplash/CMakeLists.txt index aa8de2c683..1dbd58fd76 100644 --- a/zephyr/test/drivers/chargesplash/CMakeLists.txt +++ b/zephyr/test/drivers/chargesplash/CMakeLists.txt @@ -2,18 +2,5 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Create library name based on current directory -zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name) - -# Create interface library -zephyr_interface_library_named(${lib_name}) - -# Add include paths -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") - # Add source files -zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/chargesplash.c") - -# Link in the library -zephyr_library_link_libraries(${lib_name}) +target_sources(app PRIVATE src/chargesplash.c) diff --git a/zephyr/test/drivers/isl923x/CMakeLists.txt b/zephyr/test/drivers/isl923x/CMakeLists.txt index 36a97589c1..809d9f0862 100644 --- a/zephyr/test/drivers/isl923x/CMakeLists.txt +++ b/zephyr/test/drivers/isl923x/CMakeLists.txt @@ -2,21 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Create library name based on current directory -zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name) - -# Create interface library -zephyr_interface_library_named(${lib_name}) - -# Add include paths -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") - # Add source files -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON - "${CMAKE_CURRENT_SOURCE_DIR}/src/console_cmd_amon_bmon.c") -zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_RAMP_HW - "${CMAKE_CURRENT_SOURCE_DIR}/src/charge_ramp_hw.c") - -# Link in the library -zephyr_library_link_libraries(${lib_name}) +target_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON + app PRIVATE src/console_cmd_amon_bmon.c) +target_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_RAMP_HW + app PRIVATE src/charge_ramp_hw.c) diff --git a/zephyr/test/drivers/led_driver/CMakeLists.txt b/zephyr/test/drivers/led_driver/CMakeLists.txt index 2f96eba2d3..3e4f48724d 100644 --- a/zephyr/test/drivers/led_driver/CMakeLists.txt +++ b/zephyr/test/drivers/led_driver/CMakeLists.txt @@ -2,19 +2,9 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Create library name based on current directory -zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name) - -# Create interface library -zephyr_interface_library_named(${lib_name}) - # Add include paths -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") -zephyr_include_directories("${PLATFORM_EC}/zephyr/shim/src/led_driver") +target_include_directories(app PRIVATE + "${PLATFORM_EC}/zephyr/shim/src/led_driver") # Add source files -zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/led.c") - -# Link in the library -zephyr_library_link_libraries(${lib_name}) +target_sources(app PRIVATE src/led.c) diff --git a/zephyr/test/drivers/usb_malfunction_sink/CMakeLists.txt b/zephyr/test/drivers/usb_malfunction_sink/CMakeLists.txt index 770f01b6d9..719366cb86 100644 --- a/zephyr/test/drivers/usb_malfunction_sink/CMakeLists.txt +++ b/zephyr/test/drivers/usb_malfunction_sink/CMakeLists.txt @@ -2,18 +2,5 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Create library name based on current directory -zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name) - -# Create interface library -zephyr_interface_library_named(${lib_name}) - -# Add include paths -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") - # Add source files -zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/usb_malfunction_sink.c") - -# Link in the library -zephyr_library_link_libraries(${lib_name}) +target_sources(app PRIVATE src/usb_malfunction_sink.c) diff --git a/zephyr/test/drivers/usbc_alt_mode/CMakeLists.txt b/zephyr/test/drivers/usbc_alt_mode/CMakeLists.txt index f8f265c021..1093c92968 100644 --- a/zephyr/test/drivers/usbc_alt_mode/CMakeLists.txt +++ b/zephyr/test/drivers/usbc_alt_mode/CMakeLists.txt @@ -2,11 +2,4 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -zephyr_library_get_current_dir_lib_name(${ZEPHYR_BASE} lib_name) -zephyr_interface_library_named(${lib_name}) - -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}") -zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include") -zephyr_library_sources("${CMAKE_CURRENT_SOURCE_DIR}/src/usbc_alt_mode.c") - -zephyr_library_link_libraries(${lib_name}) +target_sources(app PRIVATE src/usbc_alt_mode.c) |