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 = [ |
| 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 = [ |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 45 | "//pw_polyfill", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 46 | "//pw_preprocessor", |
| 47 | "//pw_span", |
| 48 | "//pw_varint", |
| 49 | ], |
| 50 | ) |
| 51 | |
| 52 | pw_cc_library( |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 53 | name = "base64", |
| 54 | srcs = [ |
| 55 | "base64.cc", |
| 56 | ], |
| 57 | hdrs = [ |
| 58 | "public/pw_tokenizer/base64.h", |
| 59 | ], |
| 60 | includes = ["public"], |
| 61 | deps = [ |
| 62 | "//pw_base64", |
| 63 | "//pw_preprocessor", |
| 64 | "//pw_span", |
| 65 | ], |
| 66 | ) |
| 67 | |
| 68 | pw_cc_library( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 69 | name = "decoder", |
| 70 | srcs = [ |
| 71 | "decode.cc", |
| 72 | "detokenize.cc", |
| 73 | "token_database.cc", |
| 74 | ], |
| 75 | hdrs = [ |
| 76 | "public/pw_tokenizer/detokenize.h", |
| 77 | "public/pw_tokenizer/internal/decode.h", |
| 78 | "public/pw_tokenizer/token_database.h", |
| 79 | ], |
| 80 | includes = ["public"], |
| 81 | deps = [ |
| 82 | "//pw_span", |
| 83 | "//pw_varint", |
| 84 | ], |
| 85 | ) |
| 86 | |
| 87 | # Executable for generating test data for the C++ and Python detokenizers. This |
| 88 | # target should only be built for the host. |
| 89 | pw_cc_binary( |
| 90 | name = "generate_decoding_test_data", |
| 91 | srcs = [ |
| 92 | "generate_decoding_test_data.cc", |
| 93 | ], |
| 94 | deps = [ |
| 95 | ":decoder", |
| 96 | ":pw_tokenizer", |
| 97 | "//pw_preprocessor", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 98 | "//pw_span", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 99 | "//pw_varint", |
| 100 | ], |
| 101 | ) |
| 102 | |
Wyatt Hepler | bc25497 | 2020-01-06 18:35:30 -0800 | [diff] [blame] | 103 | # Executable for generating a test ELF file for elf_reader_test.py. A host |
| 104 | # version of this binary is checked in for use in elf_reader_test.py. |
| 105 | cc_binary( |
| 106 | name = "elf_reader_test_binary", |
| 107 | srcs = [ |
| 108 | "py/elf_reader_test_binary.c", |
| 109 | ], |
| 110 | linkopts = ["-Wl,--unresolved-symbols=ignore-all"], # main is not defined |
| 111 | deps = [ |
| 112 | ":pw_tokenizer", |
| 113 | "//pw_varint", |
| 114 | ], |
| 115 | ) |
| 116 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 117 | pw_cc_test( |
| 118 | name = "argument_types_test", |
| 119 | srcs = [ |
| 120 | "argument_types_test.c", |
| 121 | "argument_types_test.cc", |
| 122 | "pw_tokenizer_private/argument_types_test.h", |
| 123 | ], |
| 124 | deps = [ |
| 125 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 126 | "//pw_preprocessor", |
| 127 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 128 | ], |
| 129 | ) |
| 130 | |
| 131 | pw_cc_test( |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 132 | name = "base64_test", |
| 133 | srcs = [ |
| 134 | "base64_test.cc", |
| 135 | ], |
| 136 | deps = [ |
| 137 | ":base64", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 138 | "//pw_span", |
| 139 | "//pw_unit_test", |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 140 | ], |
| 141 | ) |
| 142 | |
| 143 | pw_cc_test( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 144 | name = "decode_test", |
| 145 | srcs = [ |
| 146 | "decode_test.cc", |
| 147 | "pw_tokenizer_private/tokenized_string_decoding_test_data.h", |
| 148 | "pw_tokenizer_private/varint_decoding_test_data.h", |
| 149 | ], |
| 150 | deps = [ |
| 151 | ":decoder", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 152 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 153 | "//pw_varint", |
| 154 | ], |
| 155 | ) |
| 156 | |
| 157 | pw_cc_test( |
| 158 | name = "detokenize_test", |
| 159 | srcs = [ |
| 160 | "detokenize_test.cc", |
| 161 | ], |
| 162 | deps = [ |
| 163 | ":decoder", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 164 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 165 | ], |
| 166 | ) |
| 167 | |
| 168 | pw_cc_test( |
| 169 | name = "hash_test", |
| 170 | srcs = [ |
| 171 | "hash_test.cc", |
| 172 | "pw_tokenizer_private/generated_hash_test_cases.h", |
| 173 | ], |
| 174 | deps = [ |
| 175 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 176 | "//pw_preprocessor", |
| 177 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 178 | ], |
| 179 | ) |
| 180 | |
| 181 | pw_cc_test( |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 182 | name = "simple_tokenize_test", |
| 183 | srcs = [ |
| 184 | "simple_tokenize_test.cc", |
| 185 | ], |
| 186 | deps = [ |
| 187 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 188 | "//pw_unit_test", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 189 | ], |
| 190 | ) |
| 191 | |
| 192 | pw_cc_test( |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 193 | name = "token_database_test", |
| 194 | srcs = [ |
| 195 | "token_database_test.cc", |
| 196 | ], |
| 197 | deps = [ |
| 198 | ":decoder", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 199 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 200 | ], |
| 201 | ) |
| 202 | |
| 203 | pw_cc_test( |
| 204 | name = "tokenize_test", |
| 205 | srcs = [ |
| 206 | "pw_tokenizer_private/tokenize_test.h", |
| 207 | "tokenize_test.c", |
| 208 | "tokenize_test.cc", |
| 209 | ], |
| 210 | deps = [ |
| 211 | ":pw_tokenizer", |
Rob Mohr | 0681948 | 2020-04-06 13:25:43 -0700 | [diff] [blame^] | 212 | "//pw_preprocessor", |
| 213 | "//pw_unit_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 214 | "//pw_varint", |
| 215 | ], |
| 216 | ) |
| 217 | |
| 218 | # Create a shared library for the tokenizer JNI wrapper. The include paths for |
| 219 | # the JNI headers must be available in the system or provided with the |
| 220 | # pw_java_native_interface_include_dirs variable. |
| 221 | filegroup( |
| 222 | name = "detokenizer_jni", |
| 223 | srcs = [ |
| 224 | "java/dev/pigweed/tokenizer/detokenizer.cc", |
| 225 | ], |
| 226 | ) |