Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 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 = [ |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 29 | "encode_args.cc", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 30 | "public/pw_tokenizer/config.h", |
| 31 | "public/pw_tokenizer/internal/argument_types.h", |
| 32 | "public/pw_tokenizer/internal/argument_types_macro_4_byte.h", |
| 33 | "public/pw_tokenizer/internal/argument_types_macro_8_byte.h", |
| 34 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h", |
| 35 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h", |
| 36 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h", |
| 37 | "public/pw_tokenizer/internal/tokenize_string.h", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 38 | "pw_tokenizer_private/encode_args.h", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 39 | "tokenize.cc", |
| 40 | ], |
| 41 | hdrs = [ |
Wyatt Hepler | eb020a1 | 2020-10-28 14:01:51 -0700 | [diff] [blame] | 42 | "public/pw_tokenizer/hash.h", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 43 | "public/pw_tokenizer/tokenize.h", |
| 44 | ], |
| 45 | includes = ["public"], |
| 46 | deps = [ |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 47 | "//pw_polyfill", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 48 | "//pw_preprocessor", |
| 49 | "//pw_span", |
| 50 | "//pw_varint", |
| 51 | ], |
| 52 | ) |
| 53 | |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 54 | # TODO(pwbug/101): Need to add support for facades/backends to Bazel. |
| 55 | PW_TOKENIZER_GLOBAL_HANDLER_BACKEND = "//pw_tokenizer:test_backend" |
| 56 | |
| 57 | PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = "//pw_tokenizer:test_backend" |
| 58 | |
| 59 | pw_cc_library( |
| 60 | name = "test_backend", |
| 61 | visibility = ["//visibility:private"], |
| 62 | ) |
| 63 | |
| 64 | pw_cc_library( |
| 65 | name = "global_handler", |
| 66 | srcs = ["tokenize_to_global_handler.cc"], |
| 67 | hdrs = ["public/pw_tokenizer/tokenize_to_global_handler.h"], |
| 68 | deps = [ |
| 69 | ":pw_tokenizer", |
| 70 | PW_TOKENIZER_GLOBAL_HANDLER_BACKEND, |
| 71 | ], |
| 72 | ) |
| 73 | |
| 74 | pw_cc_library( |
| 75 | name = "global_handler_with_payload", |
| 76 | srcs = ["tokenize_to_global_handler_with_payload.cc"], |
| 77 | hdrs = ["public/pw_tokenizer/tokenize_to_global_handler_with_payload.h"], |
| 78 | deps = [ |
| 79 | ":pw_tokenizer", |
| 80 | PW_TOKENIZER_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND, |
| 81 | ], |
| 82 | ) |
| 83 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 84 | pw_cc_library( |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 85 | name = "base64", |
| 86 | srcs = [ |
| 87 | "base64.cc", |
| 88 | ], |
| 89 | hdrs = [ |
| 90 | "public/pw_tokenizer/base64.h", |
| 91 | ], |
| 92 | includes = ["public"], |
| 93 | deps = [ |
| 94 | "//pw_base64", |
| 95 | "//pw_preprocessor", |
| 96 | "//pw_span", |
| 97 | ], |
| 98 | ) |
| 99 | |
| 100 | pw_cc_library( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 101 | name = "decoder", |
| 102 | srcs = [ |
| 103 | "decode.cc", |
| 104 | "detokenize.cc", |
| 105 | "token_database.cc", |
| 106 | ], |
| 107 | hdrs = [ |
| 108 | "public/pw_tokenizer/detokenize.h", |
| 109 | "public/pw_tokenizer/internal/decode.h", |
| 110 | "public/pw_tokenizer/token_database.h", |
| 111 | ], |
| 112 | includes = ["public"], |
| 113 | deps = [ |
| 114 | "//pw_span", |
| 115 | "//pw_varint", |
| 116 | ], |
| 117 | ) |
| 118 | |
| 119 | # Executable for generating test data for the C++ and Python detokenizers. This |
| 120 | # target should only be built for the host. |
| 121 | pw_cc_binary( |
| 122 | name = "generate_decoding_test_data", |
| 123 | srcs = [ |
| 124 | "generate_decoding_test_data.cc", |
Aaron Green | b3ae1dc | 2020-04-13 11:37:05 -0700 | [diff] [blame] | 125 | "tokenize_test_fakes.cc", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 126 | ], |
| 127 | deps = [ |
| 128 | ":decoder", |
| 129 | ":pw_tokenizer", |
| 130 | "//pw_preprocessor", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 131 | "//pw_span", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 132 | "//pw_varint", |
| 133 | ], |
| 134 | ) |
| 135 | |
Wyatt Hepler | bc25497 | 2020-01-06 18:35:30 -0800 | [diff] [blame] | 136 | # Executable for generating a test ELF file for elf_reader_test.py. A host |
| 137 | # version of this binary is checked in for use in elf_reader_test.py. |
| 138 | cc_binary( |
| 139 | name = "elf_reader_test_binary", |
| 140 | srcs = [ |
| 141 | "py/elf_reader_test_binary.c", |
| 142 | ], |
| 143 | linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined |
| 144 | deps = [ |
| 145 | ":pw_tokenizer", |
| 146 | "//pw_varint", |
| 147 | ], |
| 148 | ) |
| 149 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 150 | pw_cc_test( |
| 151 | name = "argument_types_test", |
| 152 | srcs = [ |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 153 | "argument_types_test.cc", |
Wyatt Hepler | eb020a1 | 2020-10-28 14:01:51 -0700 | [diff] [blame] | 154 | "argument_types_test_c.c", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 155 | "pw_tokenizer_private/argument_types_test.h", |
Aaron Green | b3ae1dc | 2020-04-13 11:37:05 -0700 | [diff] [blame] | 156 | "tokenize_test_fakes.cc", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 157 | ], |
| 158 | deps = [ |
| 159 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 160 | "//pw_preprocessor", |
| 161 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 162 | ], |
| 163 | ) |
| 164 | |
| 165 | pw_cc_test( |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 166 | name = "base64_test", |
| 167 | srcs = [ |
| 168 | "base64_test.cc", |
| 169 | ], |
| 170 | deps = [ |
| 171 | ":base64", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 172 | "//pw_span", |
| 173 | "//pw_unit_test", |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 174 | ], |
| 175 | ) |
| 176 | |
| 177 | pw_cc_test( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 178 | name = "decode_test", |
| 179 | srcs = [ |
| 180 | "decode_test.cc", |
| 181 | "pw_tokenizer_private/tokenized_string_decoding_test_data.h", |
| 182 | "pw_tokenizer_private/varint_decoding_test_data.h", |
| 183 | ], |
| 184 | deps = [ |
| 185 | ":decoder", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 186 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 187 | "//pw_varint", |
| 188 | ], |
| 189 | ) |
| 190 | |
| 191 | pw_cc_test( |
| 192 | name = "detokenize_test", |
| 193 | srcs = [ |
| 194 | "detokenize_test.cc", |
| 195 | ], |
| 196 | deps = [ |
| 197 | ":decoder", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 198 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 199 | ], |
| 200 | ) |
| 201 | |
| 202 | pw_cc_test( |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 203 | name = "global_handlers_test", |
| 204 | srcs = [ |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 205 | "global_handlers_test.cc", |
Wyatt Hepler | eb020a1 | 2020-10-28 14:01:51 -0700 | [diff] [blame] | 206 | "global_handlers_test_c.c", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 207 | "pw_tokenizer_private/tokenize_test.h", |
| 208 | ], |
| 209 | deps = [ |
| 210 | ":global_handler", |
| 211 | ":global_handler_with_payload", |
| 212 | ], |
| 213 | ) |
| 214 | |
| 215 | pw_cc_test( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 216 | name = "hash_test", |
| 217 | srcs = [ |
| 218 | "hash_test.cc", |
| 219 | "pw_tokenizer_private/generated_hash_test_cases.h", |
Aaron Green | b3ae1dc | 2020-04-13 11:37:05 -0700 | [diff] [blame] | 220 | "tokenize_test_fakes.cc", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 221 | ], |
| 222 | deps = [ |
| 223 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 224 | "//pw_preprocessor", |
| 225 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 226 | ], |
| 227 | ) |
| 228 | |
| 229 | pw_cc_test( |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 230 | name = "simple_tokenize_test", |
| 231 | srcs = [ |
| 232 | "simple_tokenize_test.cc", |
| 233 | ], |
| 234 | deps = [ |
| 235 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 236 | "//pw_unit_test", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 237 | ], |
| 238 | ) |
| 239 | |
| 240 | pw_cc_test( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 241 | name = "token_database_test", |
| 242 | srcs = [ |
| 243 | "token_database_test.cc", |
| 244 | ], |
| 245 | deps = [ |
| 246 | ":decoder", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 247 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 248 | ], |
| 249 | ) |
| 250 | |
| 251 | pw_cc_test( |
| 252 | name = "tokenize_test", |
| 253 | srcs = [ |
| 254 | "pw_tokenizer_private/tokenize_test.h", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 255 | "tokenize_test.cc", |
Wyatt Hepler | eb020a1 | 2020-10-28 14:01:51 -0700 | [diff] [blame] | 256 | "tokenize_test_c.c", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 257 | ], |
| 258 | deps = [ |
| 259 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame] | 260 | "//pw_preprocessor", |
| 261 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 262 | "//pw_varint", |
| 263 | ], |
| 264 | ) |
| 265 | |
| 266 | # Create a shared library for the tokenizer JNI wrapper. The include paths for |
| 267 | # the JNI headers must be available in the system or provided with the |
| 268 | # pw_java_native_interface_include_dirs variable. |
| 269 | filegroup( |
| 270 | name = "detokenizer_jni", |
| 271 | srcs = [ |
| 272 | "java/dev/pigweed/tokenizer/detokenizer.cc", |
| 273 | ], |
| 274 | ) |