blob: 350d4635abee61375380e22e8de1908448b45153 [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",
36 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
37 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
38 "public/pw_tokenizer/internal/tokenize_string.h",
Wyatt Hepler6639c452020-05-06 11:43:07 -070039 "pw_tokenizer_private/encode_args.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080040 "tokenize.cc",
41 ],
42 hdrs = [
Wyatt Heplereb020a12020-10-28 14:01:51 -070043 "public/pw_tokenizer/hash.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080044 "public/pw_tokenizer/tokenize.h",
45 ],
46 includes = ["public"],
47 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070048 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080049 "//pw_preprocessor",
50 "//pw_span",
51 "//pw_varint",
52 ],
53)
54
Wyatt Hepler6639c452020-05-06 11:43:07 -070055# TODO(pwbug/101): Need to add support for facades/backends to Bazel.
56PW_TOKENIZER_GLOBAL_HANDLER_BACKEND = "//pw_tokenizer:test_backend"
57
58PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = "//pw_tokenizer:test_backend"
59
60pw_cc_library(
61 name = "test_backend",
62 visibility = ["//visibility:private"],
63)
64
65pw_cc_library(
66 name = "global_handler",
67 srcs = ["tokenize_to_global_handler.cc"],
68 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"],
69 deps = [
70 ":pw_tokenizer",
71 PW_TOKENIZER_GLOBAL_HANDLER_BACKEND,
72 ],
73)
74
75pw_cc_library(
76 name = "global_handler_with_payload",
77 srcs = ["tokenize_to_global_handler_with_payload.cc"],
78 hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"],
79 deps = [
80 ":pw_tokenizer",
81 PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND,
82 ],
83)
84
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080085pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080086 name = "base64",
87 srcs = [
88 "base64.cc",
89 ],
90 hdrs = [
91 "public/pw_tokenizer/base64.h",
92 ],
93 includes = ["public"],
94 deps = [
95 "//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
120# Executable for generating test data for the C++ and Python detokenizers. This
121# target should only be built for the host.
122pw_cc_binary(
123 name = "generate_decoding_test_data",
124 srcs = [
125 "generate_decoding_test_data.cc",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700126 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800127 ],
128 deps = [
129 ":decoder",
130 ":pw_tokenizer",
131 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -0700132 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800133 "//pw_varint",
134 ],
135)
136
Wyatt Heplerbc254972020-01-06 18:35:30 -0800137# Executable for generating a test ELF file for elf_reader_test.py. A host
138# version of this binary is checked in for use in elf_reader_test.py.
139cc_binary(
140 name = "elf_reader_test_binary",
141 srcs = [
142 "py/elf_reader_test_binary.c",
143 ],
144 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
145 deps = [
146 ":pw_tokenizer",
147 "//pw_varint",
148 ],
149)
150
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800151pw_cc_test(
152 name = "argument_types_test",
153 srcs = [
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800154 "argument_types_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700155 "argument_types_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800156 "pw_tokenizer_private/argument_types_test.h",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700157 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800158 ],
159 deps = [
160 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700161 "//pw_preprocessor",
162 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800163 ],
164)
165
166pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800167 name = "base64_test",
168 srcs = [
169 "base64_test.cc",
170 ],
171 deps = [
172 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700173 "//pw_span",
174 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800175 ],
176)
177
178pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800179 name = "decode_test",
180 srcs = [
181 "decode_test.cc",
182 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
183 "pw_tokenizer_private/varint_decoding_test_data.h",
184 ],
185 deps = [
186 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700187 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800188 "//pw_varint",
189 ],
190)
191
192pw_cc_test(
193 name = "detokenize_test",
194 srcs = [
195 "detokenize_test.cc",
196 ],
197 deps = [
198 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700199 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800200 ],
201)
202
203pw_cc_test(
Wyatt Hepler6639c452020-05-06 11:43:07 -0700204 name = "global_handlers_test",
205 srcs = [
Wyatt Hepler6639c452020-05-06 11:43:07 -0700206 "global_handlers_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700207 "global_handlers_test_c.c",
Wyatt Hepler6639c452020-05-06 11:43:07 -0700208 "pw_tokenizer_private/tokenize_test.h",
209 ],
210 deps = [
211 ":global_handler",
212 ":global_handler_with_payload",
213 ],
214)
215
216pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800217 name = "hash_test",
218 srcs = [
219 "hash_test.cc",
220 "pw_tokenizer_private/generated_hash_test_cases.h",
Aaron Greenb3ae1dc2020-04-13 11:37:05 -0700221 "tokenize_test_fakes.cc",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800222 ],
223 deps = [
224 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700225 "//pw_preprocessor",
226 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800227 ],
228)
229
230pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800231 name = "simple_tokenize_test",
232 srcs = [
233 "simple_tokenize_test.cc",
234 ],
235 deps = [
236 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700237 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800238 ],
239)
240
241pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800242 name = "token_database_test",
243 srcs = [
244 "token_database_test.cc",
245 ],
246 deps = [
247 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700248 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800249 ],
250)
251
252pw_cc_test(
253 name = "tokenize_test",
254 srcs = [
255 "pw_tokenizer_private/tokenize_test.h",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800256 "tokenize_test.cc",
Wyatt Heplereb020a12020-10-28 14:01:51 -0700257 "tokenize_test_c.c",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800258 ],
259 deps = [
260 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700261 "//pw_preprocessor",
262 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800263 "//pw_varint",
264 ],
265)
266
267# Create a shared library for the tokenizer JNI wrapper. The include paths for
268# the JNI headers must be available in the system or provided with the
269# pw_java_native_interface_include_dirs variable.
270filegroup(
271 name = "detokenizer_jni",
272 srcs = [
273 "java/dev/pigweed/tokenizer/detokenizer.cc",
274 ],
275)