Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_tokenizer / BUILD
1 # 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
15 load(
16     "//pw_build:pigweed.bzl",
17     "pw_cc_binary",
18     "pw_cc_library",
19     "pw_cc_test",
20 )
21
22 package(default_visibility = ["//visibility:public"])
23
24 licenses(["notice"])  # Apache License 2.0
25
26 pw_cc_library(
27     name = "pw_tokenizer",
28     srcs = [
29         "encode_args.cc",
30         "hash.cc",
31         "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",
39         "pw_tokenizer_private/encode_args.h",
40         "tokenize.cc",
41     ],
42     hdrs = [
43         "public/pw_tokenizer/hash.h",
44         "public/pw_tokenizer/tokenize.h",
45     ],
46     includes = ["public"],
47     deps = [
48         "//pw_polyfill",
49         "//pw_preprocessor",
50         "//pw_span",
51         "//pw_varint",
52     ],
53 )
54
55 # TODO(pwbug/101): Need to add support for facades/backends to Bazel.
56 PW_TOKENIZER_GLOBAL_HANDLER_BACKEND = "//pw_tokenizer:test_backend"
57
58 PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = "//pw_tokenizer:test_backend"
59
60 pw_cc_library(
61     name = "test_backend",
62     visibility = ["//visibility:private"],
63 )
64
65 pw_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
75 pw_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
85 pw_cc_library(
86     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
101 pw_cc_library(
102     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.
122 pw_cc_binary(
123     name = "generate_decoding_test_data",
124     srcs = [
125         "generate_decoding_test_data.cc",
126         "tokenize_test_fakes.cc",
127     ],
128     deps = [
129         ":decoder",
130         ":pw_tokenizer",
131         "//pw_preprocessor",
132         "//pw_span",
133         "//pw_varint",
134     ],
135 )
136
137 # 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.
139 cc_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
151 pw_cc_test(
152     name = "argument_types_test",
153     srcs = [
154         "argument_types_test.cc",
155         "argument_types_test_c.c",
156         "pw_tokenizer_private/argument_types_test.h",
157         "tokenize_test_fakes.cc",
158     ],
159     deps = [
160         ":pw_tokenizer",
161         "//pw_preprocessor",
162         "//pw_unit_test",
163     ],
164 )
165
166 pw_cc_test(
167     name = "base64_test",
168     srcs = [
169         "base64_test.cc",
170     ],
171     deps = [
172         ":base64",
173         "//pw_span",
174         "//pw_unit_test",
175     ],
176 )
177
178 pw_cc_test(
179     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",
187         "//pw_unit_test",
188         "//pw_varint",
189     ],
190 )
191
192 pw_cc_test(
193     name = "detokenize_test",
194     srcs = [
195         "detokenize_test.cc",
196     ],
197     deps = [
198         ":decoder",
199         "//pw_unit_test",
200     ],
201 )
202
203 pw_cc_test(
204     name = "global_handlers_test",
205     srcs = [
206         "global_handlers_test.cc",
207         "global_handlers_test_c.c",
208         "pw_tokenizer_private/tokenize_test.h",
209     ],
210     deps = [
211         ":global_handler",
212         ":global_handler_with_payload",
213     ],
214 )
215
216 pw_cc_test(
217     name = "hash_test",
218     srcs = [
219         "hash_test.cc",
220         "pw_tokenizer_private/generated_hash_test_cases.h",
221         "tokenize_test_fakes.cc",
222     ],
223     deps = [
224         ":pw_tokenizer",
225         "//pw_preprocessor",
226         "//pw_unit_test",
227     ],
228 )
229
230 pw_cc_test(
231     name = "simple_tokenize_test",
232     srcs = [
233         "simple_tokenize_test.cc",
234     ],
235     deps = [
236         ":pw_tokenizer",
237         "//pw_unit_test",
238     ],
239 )
240
241 pw_cc_test(
242     name = "token_database_test",
243     srcs = [
244         "token_database_test.cc",
245     ],
246     deps = [
247         ":decoder",
248         "//pw_unit_test",
249     ],
250 )
251
252 pw_cc_test(
253     name = "tokenize_test",
254     srcs = [
255         "pw_tokenizer_private/tokenize_test.h",
256         "tokenize_test.cc",
257         "tokenize_test_c.c",
258     ],
259     deps = [
260         ":pw_tokenizer",
261         "//pw_preprocessor",
262         "//pw_unit_test",
263         "//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.
270 filegroup(
271     name = "detokenizer_jni",
272     srcs = [
273         "java/dev/pigweed/tokenizer/detokenizer.cc",
274     ],
275 )