blob: d06d209fd30828c08ece997f442aa8bef2f15660 [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)
22
23package(default_visibility = ["//visibility:public"])
24
Rob Mohr5fc25412021-06-23 09:35:23 -070025licenses(["notice"])
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080026
27pw_cc_library(
28 name = "pw_tokenizer",
29 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -070030 "encode_args.cc",
Wyatt Hepler656fac62020-10-28 14:30:59 -070031 "hash.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080032 "public/pw_tokenizer/config.h",
33 "public/pw_tokenizer/internal/argument_types.h",
34 "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
35 "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
36 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h",
Wyatt Hepler63c9bee2021-02-23 11:37:15 -080037 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_256_hash_macro.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080038 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
39 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
40 "public/pw_tokenizer/internal/tokenize_string.h",
41 "tokenize.cc",
42 ],
43 hdrs = [
Wyatt Hepler7c8b3392021-04-05 18:00:24 -070044 "public/pw_tokenizer/encode_args.h",
Wyatt Heplereb020a12020-10-28 14:01:51 -070045 "public/pw_tokenizer/hash.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080046 "public/pw_tokenizer/tokenize.h",
47 ],
48 includes = ["public"],
49 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070050 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080051 "//pw_preprocessor",
52 "//pw_span",
53 "//pw_varint",
54 ],
55)
56
Wyatt Hepler6639c452020-05-06 11:43:07 -070057pw_cc_library(
58 name = "test_backend",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080059 visibility = ["@pigweed_config//:__pkg__"],
Wyatt Hepler6639c452020-05-06 11:43:07 -070060)
61
62pw_cc_library(
63 name = "global_handler",
64 srcs = ["tokenize_to_global_handler.cc"],
65 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"],
66 deps = [
67 ":pw_tokenizer",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080068 "@pigweed_config//:pw_tokenizer_global_handler_backend",
Wyatt Hepler6639c452020-05-06 11:43:07 -070069 ],
70)
71
72pw_cc_library(
73 name = "global_handler_with_payload",
74 srcs = ["tokenize_to_global_handler_with_payload.cc"],
75 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"],
76 deps = [
77 ":pw_tokenizer",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080078 "@pigweed_config//:pw_tokenizer_global_handler_with_payload_backend",
Wyatt Hepler6639c452020-05-06 11:43:07 -070079 ],
80)
81
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080082pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080083 name = "base64",
84 srcs = [
85 "base64.cc",
86 ],
87 hdrs = [
88 "public/pw_tokenizer/base64.h",
89 ],
90 includes = ["public"],
91 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +080092 ":pw_tokenizer",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080093 "//pw_base64",
94 "//pw_preprocessor",
95 "//pw_span",
96 ],
97)
98
99pw_cc_library(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800100 name = "decoder",
101 srcs = [
102 "decode.cc",
103 "detokenize.cc",
104 "token_database.cc",
105 ],
106 hdrs = [
107 "public/pw_tokenizer/detokenize.h",
108 "public/pw_tokenizer/internal/decode.h",
109 "public/pw_tokenizer/token_database.h",
110 ],
111 includes = ["public"],
112 deps = [
113 "//pw_span",
114 "//pw_varint",
115 ],
116)
117
118# Executable for generating test data for the C++ and Python detokenizers. This
119# target should only be built for the host.
120pw_cc_binary(
121 name = "generate_decoding_test_data",
122 srcs = [
123 "generate_decoding_test_data.cc",
124 ],
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800125 target_compatible_with = select(
126 {
127 "@platforms//os:linux": [],
128 "@platforms//os:windows": [],
129 "@platforms//os:macos": [],
130 "//conditions:default": ["@platforms//:incompatible"],
131 },
132 ),
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800133 deps = [
134 ":decoder",
135 ":pw_tokenizer",
136 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -0700137 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800138 "//pw_varint",
139 ],
140)
141
Wyatt Heplerbc254972020-01-06 18:35:30 -0800142# Executable for generating a test ELF file for elf_reader_test.py. A host
143# version of this binary is checked in for use in elf_reader_test.py.
144cc_binary(
145 name = "elf_reader_test_binary",
146 srcs = [
147 "py/elf_reader_test_binary.c",
148 ],
149 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
150 deps = [
151 ":pw_tokenizer",
152 "//pw_varint",
153 ],
154)
155
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800156pw_cc_test(
157 name = "argument_types_test",
158 srcs = [
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800159 "argument_types_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700160 "argument_types_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800161 "pw_tokenizer_private/argument_types_test.h",
162 ],
163 deps = [
164 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700165 "//pw_preprocessor",
166 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800167 ],
168)
169
170pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800171 name = "base64_test",
172 srcs = [
173 "base64_test.cc",
174 ],
175 deps = [
176 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700177 "//pw_span",
178 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800179 ],
180)
181
182pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800183 name = "decode_test",
184 srcs = [
185 "decode_test.cc",
186 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
187 "pw_tokenizer_private/varint_decoding_test_data.h",
188 ],
189 deps = [
190 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700191 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800192 "//pw_varint",
193 ],
194)
195
196pw_cc_test(
197 name = "detokenize_test",
198 srcs = [
199 "detokenize_test.cc",
200 ],
201 deps = [
202 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700203 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800204 ],
205)
206
207pw_cc_test(
Wyatt Hepler6639c452020-05-06 11:43:07 -0700208 name = "global_handlers_test",
209 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -0700210 "global_handlers_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700211 "global_handlers_test_c.c",
Wyatt Hepler6639c452020-05-06 11:43:07 -0700212 "pw_tokenizer_private/tokenize_test.h",
213 ],
214 deps = [
215 ":global_handler",
216 ":global_handler_with_payload",
217 ],
218)
219
220pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800221 name = "hash_test",
222 srcs = [
223 "hash_test.cc",
224 "pw_tokenizer_private/generated_hash_test_cases.h",
225 ],
226 deps = [
227 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700228 "//pw_preprocessor",
229 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800230 ],
231)
232
233pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800234 name = "simple_tokenize_test",
235 srcs = [
236 "simple_tokenize_test.cc",
237 ],
238 deps = [
Nathaniel Broughc2d57812021-04-18 22:52:00 +0800239 ":global_handler",
240 ":global_handler_with_payload",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800241 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700242 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800243 ],
244)
245
246pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800247 name = "token_database_test",
248 srcs = [
249 "token_database_test.cc",
250 ],
251 deps = [
252 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700253 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800254 ],
255)
256
257pw_cc_test(
258 name = "tokenize_test",
259 srcs = [
260 "pw_tokenizer_private/tokenize_test.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800261 "tokenize_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700262 "tokenize_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800263 ],
264 deps = [
265 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700266 "//pw_preprocessor",
267 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800268 "//pw_varint",
269 ],
270)
271
272# Create a shared library for the tokenizer JNI wrapper. The include paths for
273# the JNI headers must be available in the system or provided with the
274# pw_java_native_interface_include_dirs variable.
275filegroup(
276 name = "detokenizer_jni",
277 srcs = [
278 "java/dev/pigweed/tokenizer/detokenizer.cc",
279 ],
280)