From b9656ecb22eabf492d9368f7dc234ed4094f7f08 Mon Sep 17 00:00:00 2001 From: Radu Dobroiu Date: Mon, 25 Sep 2023 12:17:07 +0000 Subject: [PATCH] pw_i2c: Add cmake integration Add cmake integration for pw_i2c submodule and create all interfaces and libraries as in BUILD.gn. Change-Id: I56792ada26b49d8a1e52bd6370a5c1914b37b57c Signed-off-by: Radu Dobroiu Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/172210 Reviewed-by: Cosmin Petrisor Presubmit-Verified: CQ Bot Account Reviewed-by: Ewout van Bekkum --- CMakeLists.txt | 1 + pw_i2c/CMakeLists.txt | 185 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 pw_i2c/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c10b5da9e..59817b7937 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,6 +93,7 @@ add_subdirectory(pw_file EXCLUDE_FROM_ALL) add_subdirectory(pw_function EXCLUDE_FROM_ALL) add_subdirectory(pw_fuzzer EXCLUDE_FROM_ALL) add_subdirectory(pw_hdlc EXCLUDE_FROM_ALL) +add_subdirectory(pw_i2c EXCLUDE_FROM_ALL) add_subdirectory(pw_interrupt EXCLUDE_FROM_ALL) add_subdirectory(pw_interrupt_cortex_m EXCLUDE_FROM_ALL) add_subdirectory(pw_interrupt_zephyr EXCLUDE_FROM_ALL) diff --git a/pw_i2c/CMakeLists.txt b/pw_i2c/CMakeLists.txt new file mode 100644 index 0000000000..39e0c51a02 --- /dev/null +++ b/pw_i2c/CMakeLists.txt @@ -0,0 +1,185 @@ +# Copyright 2023 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +include($ENV{PW_ROOT}/pw_build/pigweed.cmake) +include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) + +pw_add_library(pw_i2c.address STATIC + HEADERS + public/pw_i2c/address.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_assert + SOURCES + address.cc +) + +pw_add_library(pw_i2c.initiator INTERFACE + HEADERS + public/pw_i2c/initiator.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_bytes + pw_chrono.system_clock + pw_i2c.address + pw_status +) + +pw_add_library(pw_i2c.device INTERFACE + HEADERS + public/pw_i2c/device.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_bytes + pw_chrono.system_clock + pw_i2c.address + pw_i2c.initiator + pw_span + pw_status +) + +pw_add_library(pw_i2c.register_device STATIC + HEADERS + public/pw_i2c/register_device.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_bytes + pw_chrono.system_clock + pw_i2c.address + pw_i2c.device + pw_i2c.initiator + pw_result + pw_status + PRIVATE_DEPS + pw_assert + SOURCES + register_device.cc +) + +pw_proto_library(pw_i2c.protos + SOURCES + i2c.proto + INPUTS + i2c.options + PREFIX + pw_i2c +) + +pw_add_library(pw_i2c.i2c_service STATIC + HEADERS + public/pw_i2c/i2c_service.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_chrono.system_clock + pw_i2c.initiator + pw_i2c.protos.pwpb_rpc + PRIVATE_DEPS + pw_containers.vector + pw_i2c.address + pw_status + SOURCES + i2c_service.cc +) + +pw_add_library(pw_i2c.mock STATIC + HEADERS + public/pw_i2c/initiator_mock.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_bytes + pw_containers + pw_containers.to_array + pw_i2c.initiator + PRIVATE_DEPS + pw_assert + pw_unit_test + SOURCES + initiator_mock.cc +) + +pw_add_library(pw_i2c.gmock INTERFACE + HEADERS + public/pw_i2c/initiator_gmock.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_i2c.initiator + pw_third_party.googletest +) + +pw_add_test(pw_i2c.address_test + SOURCES + address_test.cc + PRIVATE_DEPS + pw_i2c.address + GROUPS + modules + pw_i2c +) + +if(NOT "${pw_chrono.system_clock_BACKEND}" STREQUAL "") +pw_add_test(pw_i2c.device_test + SOURCES + device_test.cc + PRIVATE_DEPS + pw_containers + pw_i2c.device + pw_i2c.mock + GROUPS + modules + pw_i2c +) + +pw_add_test(pw_i2c.register_device_test + SOURCES + register_device_test.cc + PRIVATE_DEPS + pw_assert + pw_i2c.register_device + GROUPS + modules + pw_i2c +) + +pw_add_test(pw_i2c.initiator_mock_test + SOURCES + initiator_mock_test.cc + PUBLIC_DEPS + pw_containers + pw_i2c.mock + GROUPS + modules + pw_i2c +) + +pw_add_test(pw_i2c.i2c_service_test + SOURCES + i2c_service_test.cc + PUBLIC_DEPS + pw_containers.vector + pw_i2c.i2c_service + pw_i2c.mock + pw_rpc.test_utils + pw_status + GROUPS + modules + pw_i2c +) +endif()