blob: cafab2c0941b999406ce9722bc202499205e76ac [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 = [
Ted Pudlik64110f52022-01-14 21:09:44 +000051 "//pw_containers:to_array",
Rob Mohr06819482020-04-06 13:25:43 -070052 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080053 "//pw_preprocessor",
54 "//pw_span",
55 "//pw_varint",
56 ],
57)
58
Wyatt Hepler6639c452020-05-06 11:43:07 -070059pw_cc_library(
60 name = "test_backend",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080061 visibility = ["@pigweed_config//:__pkg__"],
Wyatt Hepler6639c452020-05-06 11:43:07 -070062)
63
64pw_cc_library(
65 name = "global_handler",
66 srcs = ["tokenize_to_global_handler.cc"],
67 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"],
68 deps = [
69 ":pw_tokenizer",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080070 "@pigweed_config//:pw_tokenizer_global_handler_backend",
Wyatt Hepler6639c452020-05-06 11:43:07 -070071 ],
72)
73
74pw_cc_library(
75 name = "global_handler_with_payload",
76 srcs = ["tokenize_to_global_handler_with_payload.cc"],
77 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"],
78 deps = [
79 ":pw_tokenizer",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080080 "@pigweed_config//:pw_tokenizer_global_handler_with_payload_backend",
Wyatt Hepler6639c452020-05-06 11:43:07 -070081 ],
82)
83
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080084pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080085 name = "base64",
86 srcs = [
87 "base64.cc",
88 ],
89 hdrs = [
90 "public/pw_tokenizer/base64.h",
91 ],
92 includes = ["public"],
93 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +080094 ":pw_tokenizer",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080095 "//pw_base64",
96 "//pw_preprocessor",
97 "//pw_span",
98 ],
99)
100
101pw_cc_library(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800102 name = "decoder",
103 srcs = [
104 "decode.cc",
105 "detokenize.cc",
106 "token_database.cc",
107 ],
108 hdrs = [
109 "public/pw_tokenizer/detokenize.h",
110 "public/pw_tokenizer/internal/decode.h",
111 "public/pw_tokenizer/token_database.h",
112 ],
113 includes = ["public"],
114 deps = [
115 "//pw_span",
116 "//pw_varint",
117 ],
118)
119
Armando Montanez559dd972021-10-06 17:32:43 -0700120proto_library(
121 name = "tokenizer_proto",
122 srcs = [
123 "options.proto",
124 ],
125 import_prefix = "pw_tokenizer/proto",
126 strip_import_prefix = "//pw_tokenizer",
127 deps = [
128 "@com_google_protobuf//:descriptor_proto",
129 ],
130)
131
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800132# Executable for generating test data for the C++ and Python detokenizers. This
133# target should only be built for the host.
134pw_cc_binary(
135 name = "generate_decoding_test_data",
136 srcs = [
137 "generate_decoding_test_data.cc",
138 ],
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800139 target_compatible_with = select(
140 {
141 "@platforms//os:linux": [],
142 "@platforms//os:windows": [],
143 "@platforms//os:macos": [],
144 "//conditions:default": ["@platforms//:incompatible"],
145 },
146 ),
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800147 deps = [
148 ":decoder",
149 ":pw_tokenizer",
150 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -0700151 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800152 "//pw_varint",
153 ],
154)
155
Wyatt Heplerbc254972020-01-06 18:35:30 -0800156# Executable for generating a test ELF file for elf_reader_test.py. A host
157# version of this binary is checked in for use in elf_reader_test.py.
158cc_binary(
159 name = "elf_reader_test_binary",
160 srcs = [
161 "py/elf_reader_test_binary.c",
162 ],
163 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
164 deps = [
165 ":pw_tokenizer",
166 "//pw_varint",
167 ],
168)
169
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800170pw_cc_test(
171 name = "argument_types_test",
172 srcs = [
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800173 "argument_types_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700174 "argument_types_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800175 "pw_tokenizer_private/argument_types_test.h",
176 ],
177 deps = [
178 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700179 "//pw_preprocessor",
180 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800181 ],
182)
183
184pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800185 name = "base64_test",
186 srcs = [
187 "base64_test.cc",
188 ],
189 deps = [
190 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700191 "//pw_span",
192 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800193 ],
194)
195
196pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800197 name = "decode_test",
198 srcs = [
199 "decode_test.cc",
200 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
201 "pw_tokenizer_private/varint_decoding_test_data.h",
202 ],
203 deps = [
204 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700205 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800206 "//pw_varint",
207 ],
208)
209
210pw_cc_test(
211 name = "detokenize_test",
212 srcs = [
213 "detokenize_test.cc",
214 ],
215 deps = [
216 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700217 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800218 ],
219)
220
Nathaniel Broughb6b90d02021-05-11 11:32:17 +0800221pw_cc_fuzz_test(
222 name = "detokenize_fuzzer",
223 srcs = ["detokenize_fuzzer.cc"],
224 deps = [
225 ":decoder",
226 ":pw_tokenizer",
227 "//pw_fuzzer",
228 ],
229)
230
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800231pw_cc_test(
Wyatt Hepler6639c452020-05-06 11:43:07 -0700232 name = "global_handlers_test",
233 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -0700234 "global_handlers_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700235 "global_handlers_test_c.c",
Wyatt Hepler6639c452020-05-06 11:43:07 -0700236 "pw_tokenizer_private/tokenize_test.h",
237 ],
238 deps = [
239 ":global_handler",
240 ":global_handler_with_payload",
241 ],
242)
243
244pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800245 name = "hash_test",
246 srcs = [
247 "hash_test.cc",
248 "pw_tokenizer_private/generated_hash_test_cases.h",
249 ],
250 deps = [
251 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700252 "//pw_preprocessor",
253 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800254 ],
255)
256
257pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800258 name = "simple_tokenize_test",
259 srcs = [
260 "simple_tokenize_test.cc",
261 ],
262 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800263 ":global_handler",
264 ":global_handler_with_payload",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800265 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700266 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800267 ],
268)
269
270pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800271 name = "token_database_test",
272 srcs = [
273 "token_database_test.cc",
274 ],
275 deps = [
276 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700277 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800278 ],
279)
280
281pw_cc_test(
282 name = "tokenize_test",
283 srcs = [
284 "pw_tokenizer_private/tokenize_test.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800285 "tokenize_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700286 "tokenize_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800287 ],
288 deps = [
289 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700290 "//pw_preprocessor",
291 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800292 "//pw_varint",
293 ],
294)
295
296# Create a shared library for the tokenizer JNI wrapper. The include paths for
297# the JNI headers must be available in the system or provided with the
298# pw_java_native_interface_include_dirs variable.
299filegroup(
300 name = "detokenizer_jni",
301 srcs = [
302 "java/dev/pigweed/tokenizer/detokenizer.cc",
303 ],
304)