blob: 1f8d970a14aad877bb2ea18ea7465083d4c8e851 [file] [log] [blame]
Wyatt Hepler80c6ee52020-01-03 09:54:58 -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
Nathaniel Broughc2d57812021-04-18 22:52:00 +080015load("@rules_cc//cc:defs.bzl", "cc_binary")
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080016load(
17 "//pw_build:pigweed.bzl",
18 "pw_cc_binary",
19 "pw_cc_library",
20 "pw_cc_test",
21)
Nathaniel Broughb6b90d02021-05-11 11:32:17 +080022load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test")
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080023
24package(default_visibility = ["//visibility:public"])
25
Rob Mohr5fc25412021-06-23 09:35:23 -070026licenses(["notice"])
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080027
28pw_cc_library(
29 name = "pw_tokenizer",
30 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -070031 "encode_args.cc",
Wyatt Hepler656fac62020-10-28 14:30:59 -070032 "hash.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080033 "public/pw_tokenizer/config.h",
34 "public/pw_tokenizer/internal/argument_types.h",
35 "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
36 "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
37 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h",
Wyatt Hepler63c9bee2021-02-23 11:37:15 -080038 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_256_hash_macro.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080039 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
40 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
41 "public/pw_tokenizer/internal/tokenize_string.h",
42 "tokenize.cc",
43 ],
44 hdrs = [
Wyatt Hepler7c8b3392021-04-05 18:00:24 -070045 "public/pw_tokenizer/encode_args.h",
Wyatt Heplereb020a12020-10-28 14:01:51 -070046 "public/pw_tokenizer/hash.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080047 "public/pw_tokenizer/tokenize.h",
48 ],
49 includes = ["public"],
50 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070051 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080052 "//pw_preprocessor",
53 "//pw_span",
54 "//pw_varint",
55 ],
56)
57
Wyatt Hepler6639c452020-05-06 11:43:07 -070058pw_cc_library(
59 name = "test_backend",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080060 visibility = ["@pigweed_config//:__pkg__"],
Wyatt Hepler6639c452020-05-06 11:43:07 -070061)
62
63pw_cc_library(
64 name = "global_handler",
65 srcs = ["tokenize_to_global_handler.cc"],
66 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"],
67 deps = [
68 ":pw_tokenizer",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080069 "@pigweed_config//:pw_tokenizer_global_handler_backend",
Wyatt Hepler6639c452020-05-06 11:43:07 -070070 ],
71)
72
73pw_cc_library(
74 name = "global_handler_with_payload",
75 srcs = ["tokenize_to_global_handler_with_payload.cc"],
76 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"],
77 deps = [
78 ":pw_tokenizer",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080079 "@pigweed_config//:pw_tokenizer_global_handler_with_payload_backend",
Wyatt Hepler6639c452020-05-06 11:43:07 -070080 ],
81)
82
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080083pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080084 name = "base64",
85 srcs = [
86 "base64.cc",
87 ],
88 hdrs = [
89 "public/pw_tokenizer/base64.h",
90 ],
91 includes = ["public"],
92 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +080093 ":pw_tokenizer",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080094 "//pw_base64",
95 "//pw_preprocessor",
96 "//pw_span",
97 ],
98)
99
100pw_cc_library(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800101 name = "decoder",
102 srcs = [
103 "decode.cc",
104 "detokenize.cc",
105 "token_database.cc",
106 ],
107 hdrs = [
108 "public/pw_tokenizer/detokenize.h",
109 "public/pw_tokenizer/internal/decode.h",
110 "public/pw_tokenizer/token_database.h",
111 ],
112 includes = ["public"],
113 deps = [
114 "//pw_span",
115 "//pw_varint",
116 ],
117)
118
119# Executable for generating test data for the C++ and Python detokenizers. This
120# target should only be built for the host.
121pw_cc_binary(
122 name = "generate_decoding_test_data",
123 srcs = [
124 "generate_decoding_test_data.cc",
125 ],
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800126 target_compatible_with = select(
127 {
128 "@platforms//os:linux": [],
129 "@platforms//os:windows": [],
130 "@platforms//os:macos": [],
131 "//conditions:default": ["@platforms//:incompatible"],
132 },
133 ),
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800134 deps = [
135 ":decoder",
136 ":pw_tokenizer",
137 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -0700138 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800139 "//pw_varint",
140 ],
141)
142
Wyatt Heplerbc254972020-01-06 18:35:30 -0800143# Executable for generating a test ELF file for elf_reader_test.py. A host
144# version of this binary is checked in for use in elf_reader_test.py.
145cc_binary(
146 name = "elf_reader_test_binary",
147 srcs = [
148 "py/elf_reader_test_binary.c",
149 ],
150 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
151 deps = [
152 ":pw_tokenizer",
153 "//pw_varint",
154 ],
155)
156
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800157pw_cc_test(
158 name = "argument_types_test",
159 srcs = [
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800160 "argument_types_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700161 "argument_types_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800162 "pw_tokenizer_private/argument_types_test.h",
163 ],
164 deps = [
165 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700166 "//pw_preprocessor",
167 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800168 ],
169)
170
171pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800172 name = "base64_test",
173 srcs = [
174 "base64_test.cc",
175 ],
176 deps = [
177 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700178 "//pw_span",
179 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800180 ],
181)
182
183pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800184 name = "decode_test",
185 srcs = [
186 "decode_test.cc",
187 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
188 "pw_tokenizer_private/varint_decoding_test_data.h",
189 ],
190 deps = [
191 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700192 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800193 "//pw_varint",
194 ],
195)
196
197pw_cc_test(
198 name = "detokenize_test",
199 srcs = [
200 "detokenize_test.cc",
201 ],
202 deps = [
203 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700204 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800205 ],
206)
207
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800208pw_cc_fuzz_test(
209 name = "detokenize_fuzzer",
210 srcs = ["detokenize_fuzzer.cc"],
211 deps = [
212 ":decoder",
213 ":pw_tokenizer",
214 "//pw_fuzzer",
215 ],
216)
217
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800218pw_cc_test(
Wyatt Hepler6639c452020-05-06 11:43:07 -0700219 name = "global_handlers_test",
220 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -0700221 "global_handlers_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700222 "global_handlers_test_c.c",
Wyatt Hepler6639c452020-05-06 11:43:07 -0700223 "pw_tokenizer_private/tokenize_test.h",
224 ],
225 deps = [
226 ":global_handler",
227 ":global_handler_with_payload",
228 ],
229)
230
231pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800232 name = "hash_test",
233 srcs = [
234 "hash_test.cc",
235 "pw_tokenizer_private/generated_hash_test_cases.h",
236 ],
237 deps = [
238 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700239 "//pw_preprocessor",
240 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800241 ],
242)
243
244pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800245 name = "simple_tokenize_test",
246 srcs = [
247 "simple_tokenize_test.cc",
248 ],
249 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800250 ":global_handler",
251 ":global_handler_with_payload",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800252 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700253 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800254 ],
255)
256
257pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800258 name = "token_database_test",
259 srcs = [
260 "token_database_test.cc",
261 ],
262 deps = [
263 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700264 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800265 ],
266)
267
268pw_cc_test(
269 name = "tokenize_test",
270 srcs = [
271 "pw_tokenizer_private/tokenize_test.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800272 "tokenize_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700273 "tokenize_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800274 ],
275 deps = [
276 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700277 "//pw_preprocessor",
278 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800279 "//pw_varint",
280 ],
281)
282
283# Create a shared library for the tokenizer JNI wrapper. The include paths for
284# the JNI headers must be available in the system or provided with the
285# pw_java_native_interface_include_dirs variable.
286filegroup(
287 name = "detokenizer_jni",
288 srcs = [
289 "java/dev/pigweed/tokenizer/detokenizer.cc",
290 ],
291)