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 ] 54} 55 56pw_source_set("register_device") { 57 public_configs = [ ":public_include_path" ] 58 public = [ "public/pw_i2c/register_device.h" ] 59 public_deps = [ 60 ":address", 61 ":device", 62 ":initiator", 63 "$dir_pw_bytes", 64 "$dir_pw_chrono:system_clock", 65 "$dir_pw_result", 66 "$dir_pw_status", 67 ] 68 sources = [ "register_device.cc" ] 69 deps = [ "$dir_pw_assert" ] 70} 71 72pw_source_set("mock") { 73 public_configs = [ ":public_include_path" ] 74 public = [ "public/pw_i2c/initiator_mock.h" ] 75 sources = [ "initiator_mock.cc" ] 76 public_deps = [ 77 ":initiator", 78 "$dir_pw_bytes", 79 "$dir_pw_containers:to_array", 80 ] 81 deps = [ 82 "$dir_pw_assert", 83 "$dir_pw_unit_test", 84 ] 85} 86 87pw_source_set("gmock") { 88 public_configs = [ ":public_include_path" ] 89 public_deps = [ 90 ":initiator", 91 "$dir_pw_third_party/googletest", 92 ] 93 public = [ "public/pw_i2c/initiator_gmock.h" ] 94} 95 96# TODO: add mock_test here once chrono backend is supported for stm32f429i-disc1 97pw_test_group("tests") { 98 tests = [ 99 ":address_test", 100 ":device_test", 101 ":initiator_mock_test", 102 ":register_device_test", 103 ] 104} 105 106pw_test("address_test") { 107 sources = [ "address_test.cc" ] 108 deps = [ ":address" ] 109} 110 111pw_test("device_test") { 112 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 113 sources = [ "device_test.cc" ] 114 deps = [ ":device" ] 115} 116 117pw_test("register_device_test") { 118 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 119 sources = [ "register_device_test.cc" ] 120 deps = [ 121 ":register_device", 122 "$dir_pw_assert", 123 ] 124} 125 126pw_test("initiator_mock_test") { 127 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 128 sources = [ "initiator_mock_test.cc" ] 129 deps = [ ":mock" ] 130} 131 132pw_doc_group("docs") { 133 sources = [ "docs.rst" ] 134} 135