1# Copyright 2020 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/target_types.gni") 18import("$dir_pw_chrono/backend.gni") 19import("$dir_pw_docgen/docs.gni") 20import("$dir_pw_unit_test/test.gni") 21 22config("public_include_path") { 23 include_dirs = [ "public" ] 24} 25 26pw_source_set("address") { 27 public_configs = [ ":public_include_path" ] 28 public = [ "public/pw_i2c/address.h" ] 29 deps = [ "$dir_pw_assert" ] 30 sources = [ "address.cc" ] 31} 32 33pw_source_set("initiator") { 34 public_configs = [ ":public_include_path" ] 35 public = [ "public/pw_i2c/initiator.h" ] 36 public_deps = [ 37 ":address", 38 "$dir_pw_bytes", 39 "$dir_pw_chrono:system_clock", 40 "$dir_pw_status", 41 ] 42} 43 44pw_source_set("device") { 45 public_configs = [ ":public_include_path" ] 46 public = [ "public/pw_i2c/device.h" ] 47 public_deps = [ 48 ":address", 49 ":initiator", 50 "$dir_pw_bytes", 51 "$dir_pw_chrono:system_clock", 52 "$dir_pw_status", 53 dir_pw_span, 54 ] 55} 56 57pw_source_set("register_device") { 58 public_configs = [ ":public_include_path" ] 59 public = [ "public/pw_i2c/register_device.h" ] 60 public_deps = [ 61 ":address", 62 ":device", 63 ":initiator", 64 "$dir_pw_bytes", 65 "$dir_pw_chrono:system_clock", 66 "$dir_pw_result", 67 "$dir_pw_status", 68 ] 69 sources = [ "register_device.cc" ] 70 deps = [ "$dir_pw_assert" ] 71} 72 73pw_source_set("mock") { 74 public_configs = [ ":public_include_path" ] 75 public = [ "public/pw_i2c/initiator_mock.h" ] 76 sources = [ "initiator_mock.cc" ] 77 public_deps = [ 78 ":initiator", 79 "$dir_pw_bytes", 80 "$dir_pw_containers", 81 "$dir_pw_containers:to_array", 82 ] 83 deps = [ 84 "$dir_pw_assert", 85 "$dir_pw_unit_test", 86 ] 87} 88 89pw_source_set("gmock") { 90 public_configs = [ ":public_include_path" ] 91 public_deps = [ 92 ":initiator", 93 "$dir_pw_third_party/googletest", 94 ] 95 public = [ "public/pw_i2c/initiator_gmock.h" ] 96} 97 98# TODO: add mock_test here once chrono backend is supported for stm32f429i-disc1 99pw_test_group("tests") { 100 tests = [ 101 ":address_test", 102 ":device_test", 103 ":initiator_mock_test", 104 ":register_device_test", 105 ] 106} 107 108pw_test("address_test") { 109 sources = [ "address_test.cc" ] 110 deps = [ ":address" ] 111} 112 113pw_test("device_test") { 114 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 115 sources = [ "device_test.cc" ] 116 deps = [ 117 ":device", 118 ":mock", 119 "$dir_pw_containers", 120 ] 121} 122 123pw_test("register_device_test") { 124 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 125 sources = [ "register_device_test.cc" ] 126 deps = [ 127 ":register_device", 128 "$dir_pw_assert", 129 ] 130} 131 132pw_test("initiator_mock_test") { 133 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 134 sources = [ "initiator_mock_test.cc" ] 135 deps = [ 136 ":mock", 137 "$dir_pw_containers", 138 ] 139} 140 141pw_doc_group("docs") { 142 sources = [ "docs.rst" ] 143} 144