Ewout van Bekkum | d1669a8 | 2020-12-04 16:00:47 -0800 | [diff] [blame] | 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 | |
| 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/target_types.gni") |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 18 | import("$dir_pw_chrono/backend.gni") |
Ewout van Bekkum | d1669a8 | 2020-12-04 16:00:47 -0800 | [diff] [blame] | 19 | import("$dir_pw_docgen/docs.gni") |
Max Koopman | 84d599d | 2021-02-11 09:38:57 -0800 | [diff] [blame] | 20 | import("$dir_pw_unit_test/test.gni") |
Ewout van Bekkum | d1669a8 | 2020-12-04 16:00:47 -0800 | [diff] [blame] | 21 | |
| 22 | config("public_include_path") { |
| 23 | include_dirs = [ "public" ] |
| 24 | } |
| 25 | |
| 26 | pw_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 | |
| 33 | pw_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 | |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 44 | pw_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 | } |
Kevin Zeng | 58b43d3 | 2021-04-16 00:36:16 -0700 | [diff] [blame] | 55 | |
| 56 | pw_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 | |
Nathaniel Brough | 7c773ff | 2021-05-05 08:24:31 +0800 | [diff] [blame] | 72 | pw_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_assert", |
| 79 | ] |
| 80 | } |
| 81 | |
| 82 | # TODO: add mock_test here once chrono backend is supported for stm32f429i-disc1 |
Max Koopman | 84d599d | 2021-02-11 09:38:57 -0800 | [diff] [blame] | 83 | pw_test_group("tests") { |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 84 | tests = [ |
| 85 | ":address_test", |
| 86 | ":device_test", |
Kevin Zeng | 58b43d3 | 2021-04-16 00:36:16 -0700 | [diff] [blame] | 87 | ":register_device_test", |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 88 | ] |
Max Koopman | 84d599d | 2021-02-11 09:38:57 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | pw_test("address_test") { |
| 92 | sources = [ "address_test.cc" ] |
| 93 | deps = [ ":address" ] |
| 94 | } |
| 95 | |
Kevin Zeng | 6e15a13 | 2021-04-16 00:34:17 -0700 | [diff] [blame] | 96 | pw_test("device_test") { |
| 97 | enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" |
| 98 | sources = [ "device_test.cc" ] |
| 99 | deps = [ ":device" ] |
| 100 | } |
| 101 | |
Kevin Zeng | 58b43d3 | 2021-04-16 00:36:16 -0700 | [diff] [blame] | 102 | pw_test("register_device_test") { |
| 103 | enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" |
| 104 | sources = [ "register_device_test.cc" ] |
| 105 | deps = [ |
| 106 | ":register_device", |
| 107 | "$dir_pw_assert", |
| 108 | ] |
| 109 | } |
| 110 | |
Nathaniel Brough | 7c773ff | 2021-05-05 08:24:31 +0800 | [diff] [blame] | 111 | pw_test("initiator_mock_test") { |
| 112 | sources = [ "initiator_mock_test.cc" ] |
| 113 | deps = [ ":initiator_mock" ] |
| 114 | } |
| 115 | |
Ewout van Bekkum | d1669a8 | 2020-12-04 16:00:47 -0800 | [diff] [blame] | 116 | pw_doc_group("docs") { |
| 117 | sources = [ "docs.rst" ] |
| 118 | } |