blob: a83c6cea750f1023d38bec78dc12eed8880abb0d [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 = [
29 "public/pw_tokenizer/config.h",
30 "public/pw_tokenizer/internal/argument_types.h",
31 "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
32 "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
33 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h",
34 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
35 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
36 "public/pw_tokenizer/internal/tokenize_string.h",
37 "tokenize.cc",
38 ],
39 hdrs = [
40 "public/pw_tokenizer/pw_tokenizer_65599_fixed_length_hash.h",
41 "public/pw_tokenizer/tokenize.h",
42 ],
43 includes = ["public"],
44 deps = [
Rob Mohr06819482020-04-06 13:25:43 -070045 "//pw_polyfill",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080046 "//pw_preprocessor",
47 "//pw_span",
48 "//pw_varint",
49 ],
50)
51
52pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080053 name = "base64",
54 srcs = [
55 "base64.cc",
56 ],
57 hdrs = [
58 "public/pw_tokenizer/base64.h",
59 ],
60 includes = ["public"],
61 deps = [
62 "//pw_base64",
63 "//pw_preprocessor",
64 "//pw_span",
65 ],
66)
67
68pw_cc_library(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080069 name = "decoder",
70 srcs = [
71 "decode.cc",
72 "detokenize.cc",
73 "token_database.cc",
74 ],
75 hdrs = [
76 "public/pw_tokenizer/detokenize.h",
77 "public/pw_tokenizer/internal/decode.h",
78 "public/pw_tokenizer/token_database.h",
79 ],
80 includes = ["public"],
81 deps = [
82 "//pw_span",
83 "//pw_varint",
84 ],
85)
86
87# Executable for generating test data for the C++ and Python detokenizers. This
88# target should only be built for the host.
89pw_cc_binary(
90 name = "generate_decoding_test_data",
91 srcs = [
92 "generate_decoding_test_data.cc",
93 ],
94 deps = [
95 ":decoder",
96 ":pw_tokenizer",
97 "//pw_preprocessor",
Rob Mohr06819482020-04-06 13:25:43 -070098 "//pw_span",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080099 "//pw_varint",
100 ],
101)
102
Wyatt Heplerbc254972020-01-06 18:35:30 -0800103# Executable for generating a test ELF file for elf_reader_test.py. A host
104# version of this binary is checked in for use in elf_reader_test.py.
105cc_binary(
106 name = "elf_reader_test_binary",
107 srcs = [
108 "py/elf_reader_test_binary.c",
109 ],
110 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
111 deps = [
112 ":pw_tokenizer",
113 "//pw_varint",
114 ],
115)
116
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800117pw_cc_test(
118 name = "argument_types_test",
119 srcs = [
120 "argument_types_test.c",
121 "argument_types_test.cc",
122 "pw_tokenizer_private/argument_types_test.h",
123 ],
124 deps = [
125 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700126 "//pw_preprocessor",
127 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800128 ],
129)
130
131pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800132 name = "base64_test",
133 srcs = [
134 "base64_test.cc",
135 ],
136 deps = [
137 ":base64",
Rob Mohr06819482020-04-06 13:25:43 -0700138 "//pw_span",
139 "//pw_unit_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800140 ],
141)
142
143pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800144 name = "decode_test",
145 srcs = [
146 "decode_test.cc",
147 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
148 "pw_tokenizer_private/varint_decoding_test_data.h",
149 ],
150 deps = [
151 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700152 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800153 "//pw_varint",
154 ],
155)
156
157pw_cc_test(
158 name = "detokenize_test",
159 srcs = [
160 "detokenize_test.cc",
161 ],
162 deps = [
163 ":decoder",
Rob Mohr06819482020-04-06 13:25:43 -0700164 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800165 ],
166)
167
168pw_cc_test(
169 name = "hash_test",
170 srcs = [
171 "hash_test.cc",
172 "pw_tokenizer_private/generated_hash_test_cases.h",
173 ],
174 deps = [
175 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700176 "//pw_preprocessor",
177 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800178 ],
179)
180
181pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800182 name = "simple_tokenize_test",
183 srcs = [
184 "simple_tokenize_test.cc",
185 ],
186 deps = [
187 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700188 "//pw_unit_test",
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800189 ],
190)
191
192pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800193 name = "token_database_test",
194 srcs = [
195 "token_database_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(
204 name = "tokenize_test",
205 srcs = [
206 "pw_tokenizer_private/tokenize_test.h",
207 "tokenize_test.c",
208 "tokenize_test.cc",
209 ],
210 deps = [
211 ":pw_tokenizer",
Rob Mohr06819482020-04-06 13:25:43 -0700212 "//pw_preprocessor",
213 "//pw_unit_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800214 "//pw_varint",
215 ],
216)
217
218# Create a shared library for the tokenizer JNI wrapper. The include paths for
219# the JNI headers must be available in the system or provided with the
220# pw_java_native_interface_include_dirs variable.
221filegroup(
222 name = "detokenizer_jni",
223 srcs = [
224 "java/dev/pigweed/tokenizer/detokenizer.cc",
225 ],
226)