blob: 431aa4bc0fab369d2f601923b0ac3f6bf6399b71 [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 Hepler80c6ee52020-01-03 09:54:58 -080030 "public/pw_tokenizer/config.h",
31 "public/pw_tokenizer/internal/argument_types.h",
32 "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
33 "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
34 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h",
35 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
36 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
37 "public/pw_tokenizer/internal/tokenize_string.h",
Wyatt Hepler6639c452020-05-06 11:43:07 -070038 "pw_tokenizer_private/encode_args.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080039 "tokenize.cc",
40 ],
41 hdrs = [
Wyatt Heplereb020a12020-10-28 14:01:51 -070042 "public/pw_tokenizer/hash.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080043 "public/pw_tokenizer/tokenize.h",
44 ],
45 includes = ["public"],
46 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070047 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080048 "//pw_preprocessor",
49 "//pw_span",
50 "//pw_varint",
51 ],
52)
53
Wyatt Hepler6639c452020-05-06 11:43:07 -070054# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
55PW_TOKENIZER_GLOBAL_HANDLER_BACKEND = "//pw_tokenizer:test_backend"
56
57PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = "//pw_tokenizer:test_backend"
58
59pw_cc_library(
60 name = "test_backend",
61 visibility = ["//visibility:private"],
62)
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",
70 PW_TOKENIZER_GLOBAL_HANDLER_BACKEND,
71 ],
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",
80 PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND,
81 ],
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 = [
94 "//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",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700125 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800126 ],
127 deps = [
128 ":decoder",
129 ":pw_tokenizer",
130 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -0700131 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800132 "//pw_varint",
133 ],
134)
135
Wyatt Heplerbc254972020-01-06 18:35:30 -0800136# Executable for generating a test ELF file for elf_reader_test.py. A host
137# version of this binary is checked in for use in elf_reader_test.py.
138cc_binary(
139 name = "elf_reader_test_binary",
140 srcs = [
141 "py/elf_reader_test_binary.c",
142 ],
143 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
144 deps = [
145 ":pw_tokenizer",
146 "//pw_varint",
147 ],
148)
149
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800150pw_cc_test(
151 name = "argument_types_test",
152 srcs = [
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800153 "argument_types_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700154 "argument_types_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800155 "pw_tokenizer_private/argument_types_test.h",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700156 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800157 ],
158 deps = [
159 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700160 "//pw_preprocessor",
161 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800162 ],
163)
164
165pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800166 name = "base64_test",
167 srcs = [
168 "base64_test.cc",
169 ],
170 deps = [
171 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700172 "//pw_span",
173 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800174 ],
175)
176
177pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800178 name = "decode_test",
179 srcs = [
180 "decode_test.cc",
181 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
182 "pw_tokenizer_private/varint_decoding_test_data.h",
183 ],
184 deps = [
185 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700186 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800187 "//pw_varint",
188 ],
189)
190
191pw_cc_test(
192 name = "detokenize_test",
193 srcs = [
194 "detokenize_test.cc",
195 ],
196 deps = [
197 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700198 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800199 ],
200)
201
202pw_cc_test(
Wyatt Hepler6639c452020-05-06 11:43:07 -0700203 name = "global_handlers_test",
204 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -0700205 "global_handlers_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700206 "global_handlers_test_c.c",
Wyatt Hepler6639c452020-05-06 11:43:07 -0700207 "pw_tokenizer_private/tokenize_test.h",
208 ],
209 deps = [
210 ":global_handler",
211 ":global_handler_with_payload",
212 ],
213)
214
215pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800216 name = "hash_test",
217 srcs = [
218 "hash_test.cc",
219 "pw_tokenizer_private/generated_hash_test_cases.h",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700220 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800221 ],
222 deps = [
223 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700224 "//pw_preprocessor",
225 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800226 ],
227)
228
229pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800230 name = "simple_tokenize_test",
231 srcs = [
232 "simple_tokenize_test.cc",
233 ],
234 deps = [
235 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700236 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800237 ],
238)
239
240pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800241 name = "token_database_test",
242 srcs = [
243 "token_database_test.cc",
244 ],
245 deps = [
246 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700247 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800248 ],
249)
250
251pw_cc_test(
252 name = "tokenize_test",
253 srcs = [
254 "pw_tokenizer_private/tokenize_test.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800255 "tokenize_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700256 "tokenize_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800257 ],
258 deps = [
259 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700260 "//pw_preprocessor",
261 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800262 "//pw_varint",
263 ],
264)
265
266# Create a shared library for the tokenizer JNI wrapper. The include paths for
267# the JNI headers must be available in the system or provided with the
268# pw_java_native_interface_include_dirs variable.
269filegroup(
270 name = "detokenizer_jni",
271 srcs = [
272 "java/dev/pigweed/tokenizer/detokenizer.cc",
273 ],
274)