blob: 7fe7aa1bbfb5be309dc1a87f582cc8da9f081a76 [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(
52 name = "decoder",
53 srcs = [
54 "decode.cc",
55 "detokenize.cc",
56 "token_database.cc",
57 ],
58 hdrs = [
59 "public/pw_tokenizer/detokenize.h",
60 "public/pw_tokenizer/internal/decode.h",
61 "public/pw_tokenizer/token_database.h",
62 ],
63 includes = ["public"],
64 deps = [
65 "//pw_span",
66 "//pw_varint",
67 ],
68)
69
70# Executable for generating test data for the C++ and Python detokenizers. This
71# target should only be built for the host.
72pw_cc_binary(
73 name = "generate_decoding_test_data",
74 srcs = [
75 "generate_decoding_test_data.cc",
76 ],
77 deps = [
78 ":decoder",
79 ":pw_tokenizer",
80 "//pw_preprocessor",
81 "//pw_varint",
82 ],
83)
84
Wyatt Heplerbc254972020-01-06 18:35:30 -080085# Executable for generating a test ELF file for elf_reader_test.py. A host
86# version of this binary is checked in for use in elf_reader_test.py.
87cc_binary(
88 name = "elf_reader_test_binary",
89 srcs = [
90 "py/elf_reader_test_binary.c",
91 ],
92 linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined
93 deps = [
94 ":pw_tokenizer",
95 "//pw_varint",
96 ],
97)
98
Wyatt Hepler80c6ee52020-01-03 09:54:58 -080099pw_cc_test(
100 name = "argument_types_test",
101 srcs = [
102 "argument_types_test.c",
103 "argument_types_test.cc",
104 "pw_tokenizer_private/argument_types_test.h",
105 ],
106 deps = [
107 ":pw_tokenizer",
108 ],
109)
110
111pw_cc_test(
112 name = "decode_test",
113 srcs = [
114 "decode_test.cc",
115 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
116 "pw_tokenizer_private/varint_decoding_test_data.h",
117 ],
118 deps = [
119 ":decoder",
120 "//pw_varint",
121 ],
122)
123
124pw_cc_test(
125 name = "detokenize_test",
126 srcs = [
127 "detokenize_test.cc",
128 ],
129 deps = [
130 ":decoder",
131 ],
132)
133
134pw_cc_test(
135 name = "hash_test",
136 srcs = [
137 "hash_test.cc",
138 "pw_tokenizer_private/generated_hash_test_cases.h",
139 ],
140 deps = [
141 ":pw_tokenizer",
142 ],
143)
144
145pw_cc_test(
146 name = "token_database_test",
147 srcs = [
148 "token_database_test.cc",
149 ],
150 deps = [
151 ":decoder",
152 ],
153)
154
155pw_cc_test(
156 name = "tokenize_test",
157 srcs = [
158 "pw_tokenizer_private/tokenize_test.h",
159 "tokenize_test.c",
160 "tokenize_test.cc",
161 ],
162 deps = [
163 ":pw_tokenizer",
164 "//pw_varint",
165 ],
166)
167
168# Create a shared library for the tokenizer JNI wrapper. The include paths for
169# the JNI headers must be available in the system or provided with the
170# pw_java_native_interface_include_dirs variable.
171filegroup(
172 name = "detokenizer_jni",
173 srcs = [
174 "java/dev/pigweed/tokenizer/detokenizer.cc",
175 ],
176)