• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_fuzzer/fuzzer.gni")
21import("$dir_pw_thread/backend.gni")
22import("$dir_pw_toolchain/generate_toolchain.gni")
23import("$dir_pw_unit_test/test.gni")
24
25config("public_include_path") {
26  include_dirs = [ "public" ]
27  visibility = [ ":*" ]
28}
29
30pw_source_set("pw_stream") {
31  public_configs = [ ":public_include_path" ]
32  public = [
33    "public/pw_stream/memory_stream.h",
34    "public/pw_stream/null_stream.h",
35    "public/pw_stream/seek.h",
36    "public/pw_stream/stream.h",
37  ]
38  sources = [ "memory_stream.cc" ]
39  public_deps = [
40    "$dir_pw_toolchain:sibling_cast",
41    dir_pw_assert,
42    dir_pw_bytes,
43    dir_pw_polyfill,
44    dir_pw_result,
45    dir_pw_span,
46    dir_pw_status,
47  ]
48}
49
50pw_source_set("socket_stream") {
51  public_configs = [ ":public_include_path" ]
52  public_deps = [
53    ":pw_stream",
54    "$dir_pw_sync:mutex",
55  ]
56  deps = [
57    dir_pw_assert,
58    dir_pw_log,
59    dir_pw_string,
60  ]
61  sources = [ "socket_stream.cc" ]
62  public = [ "public/pw_stream/socket_stream.h" ]
63  if (current_os == "win") {
64    libs = [ "ws2_32" ]
65  }
66}
67
68pw_source_set("sys_io_stream") {
69  public_configs = [ ":public_include_path" ]
70  public_deps = [
71    "$dir_pw_stream",
72    "$dir_pw_sys_io",
73  ]
74  public = [ "public/pw_stream/sys_io_stream.h" ]
75}
76
77pw_source_set("std_file_stream") {
78  public_configs = [ ":public_include_path" ]
79  public_deps = [ ":pw_stream" ]
80  deps = [ "$dir_pw_assert" ]
81  public = [ "public/pw_stream/std_file_stream.h" ]
82  sources = [ "std_file_stream.cc" ]
83}
84
85pw_source_set("interval_reader") {
86  public_configs = [ ":public_include_path" ]
87  public_deps = [
88    ":pw_stream",
89    dir_pw_assert,
90    dir_pw_status,
91  ]
92  public = [ "public/pw_stream/interval_reader.h" ]
93  sources = [ "interval_reader.cc" ]
94}
95
96pw_source_set("mpsc_stream") {
97  public_configs = [ ":public_include_path" ]
98  public_deps = [
99    ":pw_stream",
100    "$dir_pw_chrono:system_clock",
101    "$dir_pw_containers:intrusive_list",
102    "$dir_pw_sync:lock_annotations",
103    "$dir_pw_sync:mutex",
104    "$dir_pw_sync:timed_thread_notification",
105    dir_pw_assert,
106    dir_pw_bytes,
107    dir_pw_function,
108    dir_pw_status,
109  ]
110  public = [ "public/pw_stream/mpsc_stream.h" ]
111  sources = [ "mpsc_stream.cc" ]
112}
113
114pw_doc_group("docs") {
115  sources = [
116    "backends.rst",
117    "docs.rst",
118  ]
119}
120
121pw_test_group("tests") {
122  tests = [
123    ":interval_reader_test",
124    ":memory_stream_test",
125    ":null_stream_test",
126    ":seek_test",
127    ":stream_test",
128    ":mpsc_stream_test",
129  ]
130
131  if (defined(pw_toolchain_SCOPE.is_host_toolchain) &&
132      pw_toolchain_SCOPE.is_host_toolchain) {
133    tests += [ ":std_file_stream_test" ]
134
135    # socket_stream_test doesn't compile on Windows.
136    if (host_os != "win") {
137      tests += [ ":socket_stream_test" ]
138    }
139  }
140}
141
142pw_test("memory_stream_test") {
143  sources = [ "memory_stream_test.cc" ]
144  deps = [ ":pw_stream" ]
145}
146
147pw_test("null_stream_test") {
148  sources = [ "null_stream_test.cc" ]
149  deps = [ ":pw_stream" ]
150}
151
152pw_test("std_file_stream_test") {
153  sources = [ "std_file_stream_test.cc" ]
154  deps = [
155    ":std_file_stream",
156    "$dir_pw_assert",
157    "$dir_pw_bytes",
158    "$dir_pw_containers",
159    "$dir_pw_random",
160    "$dir_pw_result",
161    "$dir_pw_status",
162    "$dir_pw_string",
163  ]
164}
165
166pw_test("seek_test") {
167  sources = [ "seek_test.cc" ]
168  deps = [ ":pw_stream" ]
169}
170
171pw_test("stream_test") {
172  sources = [ "stream_test.cc" ]
173  deps = [ ":pw_stream" ]
174}
175
176pw_test("interval_reader_test") {
177  sources = [ "interval_reader_test.cc" ]
178  deps = [ ":interval_reader" ]
179}
180
181pw_test("socket_stream_test") {
182  sources = [ "socket_stream_test.cc" ]
183  deps = [ ":socket_stream" ]
184}
185
186pw_test("mpsc_stream_test") {
187  sources = [ "mpsc_stream_test.cc" ]
188  deps = [
189    ":mpsc_stream",
190    "$dir_pw_containers:vector",
191    "$dir_pw_fuzzer:fuzztest",
192    "$dir_pw_thread:test_thread_context",
193    "$dir_pw_thread:thread",
194    dir_pw_random,
195  ]
196  enable_if =
197      pw_chrono_SYSTEM_CLOCK_BACKEND != "" && pw_thread_THREAD_BACKEND != "" &&
198      pw_thread_TEST_THREAD_CONTEXT_BACKEND != ""
199}
200