blob: e03fdee58b17280c10b2b0543c4da7a993b5b07b [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 = [
45 "//pw_preprocessor",
46 "//pw_span",
47 "//pw_varint",
48 ],
49)
50
51pw_cc_library(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080052 name = "base64",
53 srcs = [
54 "base64.cc",
55 ],
56 hdrs = [
57 "public/pw_tokenizer/base64.h",
58 ],
59 includes = ["public"],
60 deps = [
61 "//pw_base64",
62 "//pw_preprocessor",
63 "//pw_span",
64 ],
65)
66
67pw_cc_library(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080068 name = "decoder",
69 srcs = [
70 "decode.cc",
71 "detokenize.cc",
72 "token_database.cc",
73 ],
74 hdrs = [
75 "public/pw_tokenizer/detokenize.h",
76 "public/pw_tokenizer/internal/decode.h",
77 "public/pw_tokenizer/token_database.h",
78 ],
79 includes = ["public"],
80 deps = [
81 "//pw_span",
82 "//pw_varint",
83 ],
84)
85
86# Executable for generating test data for the C++ and Python detokenizers. This
87# target should only be built for the host.
88pw_cc_binary(
89 name = "generate_decoding_test_data",
90 srcs = [
91 "generate_decoding_test_data.cc",
92 ],
93 deps = [
94 ":decoder",
95 ":pw_tokenizer",
96 "//pw_preprocessor",
97 "//pw_varint",
98 ],
99)
100
Wyatt Heplerbc254972020-01-06 18:35:30 -0800101# Executable for generating a test ELF file for elf_reader_test.py. A host
102# version of this binary is checked in for use in elf_reader_test.py.
103cc_binary(
104 name = "elf_reader_test_binary",
105 srcs = [
106 "py/elf_reader_test_binary.c",
107 ],
108 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
109 deps = [
110 ":pw_tokenizer",
111 "//pw_varint",
112 ],
113)
114
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800115pw_cc_test(
116 name = "argument_types_test",
117 srcs = [
118 "argument_types_test.c",
119 "argument_types_test.cc",
120 "pw_tokenizer_private/argument_types_test.h",
121 ],
122 deps = [
123 ":pw_tokenizer",
124 ],
125)
126
127pw_cc_test(
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800128 name = "base64_test",
129 srcs = [
130 "base64_test.cc",
131 ],
132 deps = [
133 ":base64",
134 ],
135)
136
137pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800138 name = "decode_test",
139 srcs = [
140 "decode_test.cc",
141 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
142 "pw_tokenizer_private/varint_decoding_test_data.h",
143 ],
144 deps = [
145 ":decoder",
146 "//pw_varint",
147 ],
148)
149
150pw_cc_test(
151 name = "detokenize_test",
152 srcs = [
153 "detokenize_test.cc",
154 ],
155 deps = [
156 ":decoder",
157 ],
158)
159
160pw_cc_test(
161 name = "hash_test",
162 srcs = [
163 "hash_test.cc",
164 "pw_tokenizer_private/generated_hash_test_cases.h",
165 ],
166 deps = [
167 ":pw_tokenizer",
168 ],
169)
170
171pw_cc_test(
Wyatt Heplera6d5cc62020-01-17 14:15:40 -0800172 name = "simple_tokenize_test",
173 srcs = [
174 "simple_tokenize_test.cc",
175 ],
176 deps = [
177 ":pw_tokenizer",
178 ],
179)
180
181pw_cc_test(
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800182 name = "token_database_test",
183 srcs = [
184 "token_database_test.cc",
185 ],
186 deps = [
187 ":decoder",
188 ],
189)
190
191pw_cc_test(
192 name = "tokenize_test",
193 srcs = [
194 "pw_tokenizer_private/tokenize_test.h",
195 "tokenize_test.c",
196 "tokenize_test.cc",
197 ],
198 deps = [
199 ":pw_tokenizer",
200 "//pw_varint",
201 ],
202)
203
204# Create a shared library for the tokenizer JNI wrapper. The include paths for
205# the JNI headers must be available in the system or provided with the
206# pw_java_native_interface_include_dirs variable.
207filegroup(
208 name = "detokenizer_jni",
209 srcs = [
210 "java/dev/pigweed/tokenizer/detokenizer.cc",
211 ],
212)