blob: 59883fc336f60442515bfc1edaea7a5a5dd3bbe2 [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
85pw_cc_test(
86 name = "argument_types_test",
87 srcs = [
88 "argument_types_test.c",
89 "argument_types_test.cc",
90 "pw_tokenizer_private/argument_types_test.h",
91 ],
92 deps = [
93 ":pw_tokenizer",
94 ],
95)
96
97pw_cc_test(
98 name = "decode_test",
99 srcs = [
100 "decode_test.cc",
101 "pw_tokenizer_private/tokenized_string_decoding_test_data.h",
102 "pw_tokenizer_private/varint_decoding_test_data.h",
103 ],
104 deps = [
105 ":decoder",
106 "//pw_varint",
107 ],
108)
109
110pw_cc_test(
111 name = "detokenize_test",
112 srcs = [
113 "detokenize_test.cc",
114 ],
115 deps = [
116 ":decoder",
117 ],
118)
119
120pw_cc_test(
121 name = "hash_test",
122 srcs = [
123 "hash_test.cc",
124 "pw_tokenizer_private/generated_hash_test_cases.h",
125 ],
126 deps = [
127 ":pw_tokenizer",
128 ],
129)
130
131pw_cc_test(
132 name = "token_database_test",
133 srcs = [
134 "token_database_test.cc",
135 ],
136 deps = [
137 ":decoder",
138 ],
139)
140
141pw_cc_test(
142 name = "tokenize_test",
143 srcs = [
144 "pw_tokenizer_private/tokenize_test.h",
145 "tokenize_test.c",
146 "tokenize_test.cc",
147 ],
148 deps = [
149 ":pw_tokenizer",
150 "//pw_varint",
151 ],
152)
153
154# Create a shared library for the tokenizer JNI wrapper. The include paths for
155# the JNI headers must be available in the system or provided with the
156# pw_java_native_interface_include_dirs variable.
157filegroup(
158 name = "detokenizer_jni",
159 srcs = [
160 "java/dev/pigweed/tokenizer/detokenizer.cc",
161 ],
162)