blob: 897692f4b35111c1f80b77d6aa378f2068bf7373 [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
15import("$dir_pw_docgen/docs.gni")
16import("$dir_pw_unit_test/test.gni")
17
18config("default_config") {
19 include_dirs = [ "public" ]
20}
21
22source_set("pw_tokenizer") {
23 public_configs = [
24 "$dir_pw_build:pw_default_cpp",
25 ":default_config",
26 ]
27 public_deps = [
28 "$dir_pw_preprocessor",
29 "$dir_pw_span",
30 ]
31 deps = [
32 "$dir_pw_varint",
33 ]
34 public = [
35 "public/pw_tokenizer/pw_tokenizer_65599_fixed_length_hash.h",
36 "public/pw_tokenizer/tokenize.h",
37 ]
38 sources = [
39 "public/pw_tokenizer/config.h",
40 "public/pw_tokenizer/internal/argument_types.h",
41 "public/pw_tokenizer/internal/argument_types_macro_4_byte.h",
42 "public/pw_tokenizer/internal/argument_types_macro_8_byte.h",
43 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h",
44 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h",
45 "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h",
46 "public/pw_tokenizer/internal/tokenize_string.h",
47 "tokenize.cc",
48 ]
49 sources += public
50 friend = [
51 ":argument_types_test",
52 ":hash_test",
53 ]
54}
55
Wyatt Hepler3c2e9522020-01-09 16:08:54 -080056source_set("base64") {
57 public_configs = [
58 "$dir_pw_build:pw_default_cpp",
59 ":default_config",
60 ]
61 public = [
62 "public/pw_tokenizer/base64.h",
63 ]
64 sources = [ "base64.cc" ] + public
65 public_deps = [
66 "$dir_pw_preprocessor",
67 "$dir_pw_span",
68 ]
69 deps = [
70 "$dir_pw_base64",
71 ]
72}
73
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080074source_set("decoder") {
75 public_configs = [
76 "$dir_pw_build:pw_default_cpp",
77 ":default_config",
78 ]
79 public_deps = [
80 "$dir_pw_span",
81 ]
82 deps = [
83 "$dir_pw_varint",
84 ]
85 public = [
86 "public/pw_tokenizer/detokenize.h",
87 "public/pw_tokenizer/token_database.h",
88 ]
89 sources = [
90 "decode.cc",
91 "detokenize.cc",
92 "public/pw_tokenizer/internal/decode.h",
93 "token_database.cc",
94 ]
95 sources += public
96 friend = [
97 ":decode_test",
98 ":generate_decoding_test_data",
99 ]
100}
101
102# Executable for generating test data for the C++ and Python detokenizers. This
103# target should only be built for the host.
104executable("generate_decoding_test_data") {
105 deps = [
106 ":decoder",
107 ":pw_tokenizer",
108 "$dir_pw_varint",
109 ]
110 sources = [
111 "generate_decoding_test_data.cc",
112 ]
113}
114
Wyatt Heplerbc254972020-01-06 18:35:30 -0800115# Executable for generating a test ELF file for elf_reader_test.py. A host
116# version of this binary is checked in for use in elf_reader_test.py.
117executable("elf_reader_test_binary") {
118 deps = [
119 ":pw_tokenizer",
120 "$dir_pw_varint",
121 ]
122 sources = [
123 "py/elf_reader_test_binary.c",
124 ]
125 ldflags = [ "-Wl,--unresolved-symbols=ignore-all" ] # main is not defined
126}
127
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800128pw_test_group("tests") {
129 tests = [
130 ":argument_types_test",
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800131 ":base64_test",
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800132 ":decode_test",
133 ":detokenize_test",
134 ":hash_test",
135 ":token_database_test",
136 ":tokenize_test",
137 ]
138 group_deps = [
139 "$dir_pw_preprocessor:tests",
140 "$dir_pw_span:tests",
141 "$dir_pw_status:tests",
142 ]
143}
144
145pw_test("argument_types_test") {
146 sources = [
147 "argument_types_test.c",
148 "argument_types_test.cc",
149 "pw_tokenizer_private/argument_types_test.h",
150 ]
151 deps = [
152 ":pw_tokenizer",
153 ]
154}
155
Wyatt Hepler3c2e9522020-01-09 16:08:54 -0800156pw_test("base64_test") {
157 sources = [
158 "base64_test.cc",
159 ]
160 deps = [
161 ":base64",
162 ]
163}
164
Wyatt Hepler80c6ee52020-01-03 09:54:58 -0800165pw_test("decode_test") {
166 sources = [
167 "decode_test.cc",
168 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
169 "pw_tokenizer_private/varint_decoding_test_data.h",
170 ]
171 deps = [
172 ":decoder",
173 "$dir_pw_varint",
174 ]
175}
176
177pw_test("detokenize_test") {
178 sources = [
179 "detokenize_test.cc",
180 ]
181 deps = [
182 ":decoder",
183 ]
184}
185
186pw_test("hash_test") {
187 sources = [
188 "hash_test.cc",
189 "pw_tokenizer_private/generated_hash_test_cases.h",
190 ]
191 deps = [
192 ":pw_tokenizer",
193 ]
194}
195
196pw_test("token_database_test") {
197 sources = [
198 "token_database_test.cc",
199 ]
200 deps = [
201 ":decoder",
202 ]
203}
204
205pw_test("tokenize_test") {
206 sources = [
207 "pw_tokenizer_private/tokenize_test.h",
208 "tokenize_test.c",
209 "tokenize_test.cc",
210 ]
211 deps = [
212 ":pw_tokenizer",
213 "$dir_pw_varint",
214 ]
215}
216
217declare_args() {
218 # pw_java_native_interface_include_dirs specifies the paths to use for
219 # building Java Native Interface libraries. If no paths are provided, targets
220 # that require JNI may not build correctly.
221 #
222 # Example JNI include paths for a Linux system:
223 #
224 # pw_java_native_interface_include_dirs = [
225 # "/usr/local/buildtools/java/jdk/include/",
226 # "/usr/local/buildtools/java/jdk/include/linux",
227 # ]
228 #
229 pw_java_native_interface_include_dirs = []
230}
231
232# Create a shared library for the tokenizer JNI wrapper. The include paths for
233# the JNI headers must be available in the system or provided with the
234# pw_java_native_interface_include_dirs variable.
235shared_library("detokenizer_jni") {
236 public_configs = [
237 "$dir_pw_build:pw_default_cpp",
238 ":default_config",
239 ]
240 include_dirs = pw_java_native_interface_include_dirs
241 sources = [
242 "java/dev/pigweed/tokenizer/detokenizer.cc",
243 ]
244 public_deps = [
245 ":decoder",
246 "$dir_pw_preprocessor",
247 ]
248}
249
250pw_doc_group("docs") {
251 sources = [
252 "docs.rst",
253 ]
254}