# Copyright 2020 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. load("@rules_proto//proto:defs.bzl", "proto_library") load( "//pw_build:pigweed.bzl", "pw_cc_test", ) load("//pw_build:selects.bzl", "TARGET_COMPATIBLE_WITH_HOST_SELECT") load( "//pw_protobuf_compiler:pw_proto_library.bzl", "pw_proto_filegroup", "pw_proto_library", ) package(default_visibility = ["//visibility:public"]) licenses(["notice"]) cc_library( name = "address", srcs = [ "address.cc", ], hdrs = [ "public/pw_i2c/address.h", ], includes = ["public"], deps = [ "//pw_assert", ], ) cc_library( name = "initiator", hdrs = [ "public/pw_i2c/initiator.h", ], includes = ["public"], deps = [ ":address", "//pw_bytes", "//pw_chrono:system_clock", "//pw_status", ], ) cc_library( name = "device", hdrs = [ "public/pw_i2c/device.h", ], includes = ["public"], deps = [ ":address", ":initiator", "//pw_bytes", "//pw_chrono:system_clock", "//pw_status", ], ) cc_library( name = "register_device", srcs = ["register_device.cc"], hdrs = [ "public/pw_i2c/register_device.h", ], includes = ["public"], deps = [ ":address", ":device", ":initiator", "//pw_bytes", "//pw_chrono:system_clock", "//pw_result", "//pw_status", ], ) pw_cc_test( name = "address_test", srcs = [ "address_test.cc", ], deps = [ ":address", "//pw_unit_test", ], ) cc_library( name = "initiator_mock", testonly = True, srcs = ["initiator_mock.cc"], hdrs = ["public/pw_i2c/initiator_mock.h"], includes = ["public"], deps = [ ":address", ":initiator", "//pw_assert", "//pw_containers", "//pw_containers:to_array", "//pw_unit_test", ], ) cc_library( name = "initiator_gmock", testonly = True, hdrs = [ "public/pw_i2c/initiator_gmock.h", ], includes = ["public"], # TODO: b/310957361 - gtest not supported on device target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), deps = [ ":initiator", "@com_google_googletest//:gtest", ], ) pw_cc_test( name = "initiator_mock_test", srcs = [ "initiator_mock_test.cc", ], deps = [ ":initiator_mock", "//pw_bytes", "//pw_containers", "//pw_unit_test", ], ) pw_cc_test( name = "device_test", srcs = [ "device_test.cc", ], deps = [ ":device", ":initiator_mock", "//pw_containers", "//pw_unit_test", ], ) pw_cc_test( name = "register_device_test", srcs = [ "register_device_test.cc", ], deps = [ ":register_device", "//pw_unit_test", ], ) pw_proto_filegroup( name = "i2c_proto_and_options", srcs = ["i2c.proto"], options_files = ["i2c.options"], ) proto_library( name = "i2c_proto", srcs = [":i2c_proto_and_options"], ) pw_proto_library( name = "i2c_cc", deps = [":i2c_proto"], ) cc_library( name = "i2c_service", srcs = ["i2c_service.cc"], hdrs = ["public/pw_i2c/i2c_service.h"], includes = ["public"], deps = [ ":address", ":i2c_cc.pwpb_rpc", ":initiator", "//pw_chrono:system_clock", "//pw_containers:vector", "//pw_status", ], ) pw_cc_test( name = "i2c_service_test", srcs = ["i2c_service_test.cc"], deps = [ ":i2c_service", ":initiator_mock", "//pw_containers:vector", "//pw_rpc/pwpb:test_method_context", "//pw_status", ], )