blob: f05d088d2f518d21475707b7b4fc69370953ed04 [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
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
26pw_cc_library(
27 name = "pw_tokenizer",
28 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -070029 "encode_args.cc",
Wyatt Hepler656fac62020-10-28 14:30:59 -070030 "hash.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080031 "public/pw_tokenizer/config.h",
32 "public/pw_tokenizer/internal/argument_types.h",
33 "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
34 "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
35 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h",
Wyatt Hepler63c9bee2021-02-23 11:37:15 -080036 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_256_hash_macro.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080037 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
38 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
39 "public/pw_tokenizer/internal/tokenize_string.h",
Wyatt Hepler6639c452020-05-06 11:43:07 -070040 "pw_tokenizer_private/encode_args.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080041 "tokenize.cc",
42 ],
43 hdrs = [
Wyatt Heplereb020a12020-10-28 14:01:51 -070044 "public/pw_tokenizer/hash.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080045 "public/pw_tokenizer/tokenize.h",
46 ],
47 includes = ["public"],
48 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070049 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080050 "//pw_preprocessor",
51 "//pw_span",
52 "//pw_varint",
53 ],
54)
55
Wyatt Hepler6639c452020-05-06 11:43:07 -070056# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
57PW_TOKENIZER_GLOBAL_HANDLER_BACKEND = "//pw_tokenizer:test_backend"
58
59PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = "//pw_tokenizer:test_backend"
60
61pw_cc_library(
62 name = "test_backend",
63 visibility = ["//visibility:private"],
64)
65
66pw_cc_library(
67 name = "global_handler",
68 srcs = ["tokenize_to_global_handler.cc"],
69 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"],
70 deps = [
71 ":pw_tokenizer",
72 PW_TOKENIZER_GLOBAL_HANDLER_BACKEND,
73 ],
74)
75
76pw_cc_library(
77 name = "global_handler_with_payload",
78 srcs = ["tokenize_to_global_handler_with_payload.cc"],
79 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"],
80 deps = [
81 ":pw_tokenizer",
82 PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND,
83 ],
84)
85
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080086pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080087 name = "base64",
88 srcs = [
89 "base64.cc",
90 ],
91 hdrs = [
92 "public/pw_tokenizer/base64.h",
93 ],
94 includes = ["public"],
95 deps = [
96 "//pw_base64",
97 "//pw_preprocessor",
98 "//pw_span",
99 ],
100)
101
102pw_cc_library(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800103 name = "decoder",
104 srcs = [
105 "decode.cc",
106 "detokenize.cc",
107 "token_database.cc",
108 ],
109 hdrs = [
110 "public/pw_tokenizer/detokenize.h",
111 "public/pw_tokenizer/internal/decode.h",
112 "public/pw_tokenizer/token_database.h",
113 ],
114 includes = ["public"],
115 deps = [
116 "//pw_span",
117 "//pw_varint",
118 ],
119)
120
121# Executable for generating test data for the C++ and Python detokenizers. This
122# target should only be built for the host.
123pw_cc_binary(
124 name = "generate_decoding_test_data",
125 srcs = [
126 "generate_decoding_test_data.cc",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700127 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800128 ],
129 deps = [
130 ":decoder",
131 ":pw_tokenizer",
132 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -0700133 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800134 "//pw_varint",
135 ],
136)
137
Wyatt Heplerbc254972020-01-06 18:35:30 -0800138# Executable for generating a test ELF file for elf_reader_test.py. A host
139# version of this binary is checked in for use in elf_reader_test.py.
140cc_binary(
141 name = "elf_reader_test_binary",
142 srcs = [
143 "py/elf_reader_test_binary.c",
144 ],
145 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
146 deps = [
147 ":pw_tokenizer",
148 "//pw_varint",
149 ],
150)
151
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800152pw_cc_test(
153 name = "argument_types_test",
154 srcs = [
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800155 "argument_types_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700156 "argument_types_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800157 "pw_tokenizer_private/argument_types_test.h",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700158 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800159 ],
160 deps = [
161 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700162 "//pw_preprocessor",
163 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800164 ],
165)
166
167pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800168 name = "base64_test",
169 srcs = [
170 "base64_test.cc",
171 ],
172 deps = [
173 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700174 "//pw_span",
175 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800176 ],
177)
178
179pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800180 name = "decode_test",
181 srcs = [
182 "decode_test.cc",
183 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
184 "pw_tokenizer_private/varint_decoding_test_data.h",
185 ],
186 deps = [
187 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700188 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800189 "//pw_varint",
190 ],
191)
192
193pw_cc_test(
194 name = "detokenize_test",
195 srcs = [
196 "detokenize_test.cc",
197 ],
198 deps = [
199 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700200 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800201 ],
202)
203
204pw_cc_test(
Wyatt Hepler6639c452020-05-06 11:43:07 -0700205 name = "global_handlers_test",
206 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -0700207 "global_handlers_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700208 "global_handlers_test_c.c",
Wyatt Hepler6639c452020-05-06 11:43:07 -0700209 "pw_tokenizer_private/tokenize_test.h",
210 ],
211 deps = [
212 ":global_handler",
213 ":global_handler_with_payload",
214 ],
215)
216
217pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800218 name = "hash_test",
219 srcs = [
220 "hash_test.cc",
221 "pw_tokenizer_private/generated_hash_test_cases.h",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700222 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800223 ],
224 deps = [
225 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700226 "//pw_preprocessor",
227 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800228 ],
229)
230
231pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800232 name = "simple_tokenize_test",
233 srcs = [
234 "simple_tokenize_test.cc",
235 ],
236 deps = [
237 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700238 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800239 ],
240)
241
242pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800243 name = "token_database_test",
244 srcs = [
245 "token_database_test.cc",
246 ],
247 deps = [
248 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700249 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800250 ],
251)
252
253pw_cc_test(
254 name = "tokenize_test",
255 srcs = [
256 "pw_tokenizer_private/tokenize_test.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800257 "tokenize_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700258 "tokenize_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800259 ],
260 deps = [
261 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700262 "//pw_preprocessor",
263 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800264 "//pw_varint",
265 ],
266)
267
268# Create a shared library for the tokenizer JNI wrapper. The include paths for
269# the JNI headers must be available in the system or provided with the
270# pw_java_native_interface_include_dirs variable.
271filegroup(
272 name = "detokenizer_jni",
273 srcs = [
274 "java/dev/pigweed/tokenizer/detokenizer.cc",
275 ],
276)