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
15load(
16    "//pw_build:pigweed.bzl",
17    "pw_cc_binary",
18    "pw_cc_library",
19    "pw_cc_test",
20)
21
22package(default_visibility = ["//visibility:public"])
23
24licenses(["notice"])  # Apache License 2.0
25
26# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
27
28pw_cc_library(
29    name = "headers",
30    hdrs = [
31        "public/pw_trace_tokenized/config.h",
32        "public/pw_trace_tokenized/internal/trace_tokenized_internal.h",
33        "public/pw_trace_tokenized/trace_callback.h",
34        "public/pw_trace_tokenized/trace_tokenized.h",
35        "public_overrides/pw_trace_backend/trace_backend.h",
36    ],
37    includes = [
38        "public",
39        "public_overrides",
40    ],
41    deps = [
42        "//pw_preprocessor",
43        "//pw_tokenizer",
44    ],
45)
46
47pw_cc_library(
48    name = "pw_trace_tokenized",
49    srcs = [
50        "trace.cc",
51    ],
52    deps = [
53        ":headers",
54        "//pw_assert",
55        "//pw_log",
56        "//pw_status",
57        "//pw_tokenizer",
58        "//pw_trace:facade",
59        "//pw_varint",
60    ],
61)
62
63pw_cc_library(
64    name = "trace_rpc_service",
65    hdrs = [
66        "public/pw_trace_tokenized/trace_rpc_service_nanopb.h",
67    ],
68    includes = [
69        "public",
70    ],
71    srcs = [
72        "trace_rpc_service_nanopb.cc",
73    ],
74    deps = [
75        "//pw_log",
76        "//pw_trace",
77        "//pw_trace_tokenized_buffer",
78    ],
79)
80
81pw_cc_library(
82    name = "trace_buffer_headers",
83    hdrs = [
84        "public/pw_trace_tokenized/trace_buffer.h",
85    ],
86    includes = [
87        "public",
88    ],
89    deps = [
90        "//pw_ring_buffer",
91        "//pw_status",
92        "//pw_trace_tokenized",
93    ],
94)
95
96pw_cc_library(
97    name = "pw_trace_tokenized_buffer",
98    srcs = [
99        "trace_buffer.cc",
100    ],
101    deps = [
102        ":trace_buffer_headers",
103        "//pw_ring_buffer",
104        "//pw_status",
105    ],
106)
107
108pw_cc_library(
109    name = "pw_trace_tokenized_buffer_log",
110    hdrs = [
111        "public/pw_trace_tokenized/trace_buffer_log.h",
112    ],
113    srcs = [
114        "trace_buffer_log.cc",
115    ],
116    deps = [
117        ":trace_buffer_headers",
118	"//pw_base64",
119	"//pw_log",
120	"//pw_string",
121    ],
122)
123
124pw_cc_library(
125    name = "pw_trace_tokenized_fake_time",
126    srcs = [
127        "fake_trace_time.cc",
128    ],
129    deps = [
130        "//pw_trace",
131    ],
132)
133
134pw_cc_test(
135    name = "trace_tokenized_test",
136    srcs = [
137        "trace_test.cc",
138    ],
139    includes = [
140        "pw_trace_test",
141        "pw_trace_test/public_overrides"
142    ],
143    deps = [
144        ":backend",
145        ":facade",
146        ":pw_trace",
147        "//pw_preprocessor",
148        "//pw_unit_test",
149    ],
150)
151
152pw_cc_test(
153    name = "trace_tokenized_buffer_test",
154    srcs = [
155        "trace_buffer_test.cc",
156    ],
157    deps = [
158        ":backend",
159        ":facade",
160        ":pw_trace",
161        "//pw_preprocessor",
162        "//pw_unit_test",
163    ],
164)
165
166pw_cc_test(
167    name = "trace_tokenized_buffer_log_test",
168    srcs = [
169        "trace_buffer_log_test.cc",
170    ],
171    deps = [
172        ":backend",
173        ":facade",
174        ":pw_trace_log",
175        "//pw_preprocessor",
176        "//pw_unit_test",
177    ],
178)
179
180pw_cc_library(
181    name = "pw_trace_host_trace_time",
182    includes = [ "example/public" ],
183    deps = [ "//pw_trace" ],
184    srcs = [ "host_trace_time.cc" ]
185)
186
187pw_cc_library(
188    name = "pw_trace_example_to_file",
189    includes = [ "example/public" ],
190    deps = [ "//pw_trace" ],
191    hdrs = [ "example/public/pw_trace_tokenized/example/trace_to_file.h" ]
192)
193
194pw_cc_binary(
195    name = "trace_tokenized_example_basic",
196    deps = [
197        ":pw_trace_example_to_file",
198        "//pw_log",
199        "//dir_pw_trace",
200        "//dir_pw_trace:pw_trace_sample_app",
201    ],
202    srcs = [ "example/basic.cc" ]
203)
204
205pw_cc_binary(
206    name = "trace_tokenized_example_trigger",
207    deps = [
208        ":pw_trace_example_to_file",
209        "//pw_log",
210        "//dir_pw_trace",
211        "//dir_pw_trace:pw_trace_sample_app",
212    ],
213    srcs = [ "example/trigger.cc" ]
214)
215
216pw_cc_binary(
217    name = "trace_tokenized_example_filter",
218    deps = [
219        ":pw_trace_example_to_file",
220        "//pw_log",
221        "//dir_pw_trace",
222        "//dir_pw_trace:pw_trace_sample_app",
223    ],
224    srcs = [ "example/filter.cc" ]
225)
226
227pw_cc_library(
228    name = "trace_tokenized_example_rpc",
229    deps = [
230        ":pw_trace_rpc_service",
231        "//dir_pw_rpc:server",
232        "//dir_pw_rpc:system_server",
233        "//pw_log",
234        "//pw_hdlc",
235        "//dir_pw_trace",
236        "//dir_pw_trace:pw_trace_sample_app",
237    ],
238    srcs = [ "example/rpc.cc" ]
239)