blob: 99ba0c3b732357f8906cdc726fa7980fa804ba4a [file] [log] [blame]
Ewout van Bekkumd1669a82020-12-04 16:00:47 -08001# 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")
Kevin Zeng6e15a132021-04-16 00:34:17 -070018import("$dir_pw_chrono/backend.gni")
Ewout van Bekkumd1669a82020-12-04 16:00:47 -080019import("$dir_pw_docgen/docs.gni")
Max Koopman84d599d2021-02-11 09:38:57 -080020import("$dir_pw_unit_test/test.gni")
Ewout van Bekkumd1669a82020-12-04 16:00:47 -080021
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
Kevin Zeng6e15a132021-04-16 00:34:17 -070044pw_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 Zeng58b43d32021-04-16 00:36:16 -070055
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
Nathaniel Brough7c773ff2021-05-05 08:24:31 +080072pw_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 Koopman84d599d2021-02-11 09:38:57 -080083pw_test_group("tests") {
Kevin Zeng6e15a132021-04-16 00:34:17 -070084 tests = [
85 ":address_test",
86 ":device_test",
Kevin Zeng58b43d32021-04-16 00:36:16 -070087 ":register_device_test",
Kevin Zeng6e15a132021-04-16 00:34:17 -070088 ]
Max Koopman84d599d2021-02-11 09:38:57 -080089}
90
91pw_test("address_test") {
92 sources = [ "address_test.cc" ]
93 deps = [ ":address" ]
94}
95
Kevin Zeng6e15a132021-04-16 00:34:17 -070096pw_test("device_test") {
97 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
98 sources = [ "device_test.cc" ]
99 deps = [ ":device" ]
100}
101
Kevin Zeng58b43d32021-04-16 00:36:16 -0700102pw_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 Brough7c773ff2021-05-05 08:24:31 +0800111pw_test("initiator_mock_test") {
112 sources = [ "initiator_mock_test.cc" ]
113 deps = [ ":initiator_mock" ]
114}
115
Ewout van Bekkumd1669a82020-12-04 16:00:47 -0800116pw_doc_group("docs") {
117 sources = [ "docs.rst" ]
118}