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 | import("$dir_pw_docgen/docs.gni") |
| 16 | import("$dir_pw_unit_test/test.gni") |
| 17 | |
| 18 | config("default_config") { |
| 19 | include_dirs = [ "public" ] |
| 20 | } |
| 21 | |
| 22 | source_set("pw_tokenizer") { |
Wyatt Hepler | 2119240 | 2020-01-15 15:40:51 -0800 | [diff] [blame] | 23 | public_configs = [ ":default_config" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 24 | public_deps = [ |
| 25 | "$dir_pw_preprocessor", |
| 26 | "$dir_pw_span", |
| 27 | ] |
| 28 | deps = [ |
| 29 | "$dir_pw_varint", |
| 30 | ] |
| 31 | public = [ |
| 32 | "public/pw_tokenizer/pw_tokenizer_65599_fixed_length_hash.h", |
| 33 | "public/pw_tokenizer/tokenize.h", |
| 34 | ] |
| 35 | sources = [ |
| 36 | "public/pw_tokenizer/config.h", |
| 37 | "public/pw_tokenizer/internal/argument_types.h", |
| 38 | "public/pw_tokenizer/internal/argument_types_macro_4_byte.h", |
| 39 | "public/pw_tokenizer/internal/argument_types_macro_8_byte.h", |
| 40 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h", |
| 41 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h", |
| 42 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h", |
| 43 | "public/pw_tokenizer/internal/tokenize_string.h", |
| 44 | "tokenize.cc", |
| 45 | ] |
| 46 | sources += public |
| 47 | friend = [ |
| 48 | ":argument_types_test", |
| 49 | ":hash_test", |
| 50 | ] |
| 51 | } |
| 52 | |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 53 | source_set("base64") { |
Wyatt Hepler | 2119240 | 2020-01-15 15:40:51 -0800 | [diff] [blame] | 54 | public_configs = [ ":default_config" ] |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 55 | public = [ |
| 56 | "public/pw_tokenizer/base64.h", |
| 57 | ] |
| 58 | sources = [ "base64.cc" ] + public |
| 59 | public_deps = [ |
| 60 | "$dir_pw_preprocessor", |
| 61 | "$dir_pw_span", |
| 62 | ] |
| 63 | deps = [ |
| 64 | "$dir_pw_base64", |
| 65 | ] |
| 66 | } |
| 67 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 68 | source_set("decoder") { |
Wyatt Hepler | 2119240 | 2020-01-15 15:40:51 -0800 | [diff] [blame] | 69 | public_configs = [ ":default_config" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 70 | public_deps = [ |
| 71 | "$dir_pw_span", |
| 72 | ] |
| 73 | deps = [ |
| 74 | "$dir_pw_varint", |
| 75 | ] |
| 76 | public = [ |
| 77 | "public/pw_tokenizer/detokenize.h", |
| 78 | "public/pw_tokenizer/token_database.h", |
| 79 | ] |
| 80 | sources = [ |
| 81 | "decode.cc", |
| 82 | "detokenize.cc", |
| 83 | "public/pw_tokenizer/internal/decode.h", |
| 84 | "token_database.cc", |
| 85 | ] |
| 86 | sources += public |
| 87 | friend = [ |
| 88 | ":decode_test", |
| 89 | ":generate_decoding_test_data", |
| 90 | ] |
| 91 | } |
| 92 | |
| 93 | # Executable for generating test data for the C++ and Python detokenizers. This |
| 94 | # target should only be built for the host. |
| 95 | executable("generate_decoding_test_data") { |
| 96 | deps = [ |
| 97 | ":decoder", |
| 98 | ":pw_tokenizer", |
| 99 | "$dir_pw_varint", |
| 100 | ] |
| 101 | sources = [ |
| 102 | "generate_decoding_test_data.cc", |
| 103 | ] |
| 104 | } |
| 105 | |
Wyatt Hepler | bc25497 | 2020-01-06 18:35:30 -0800 | [diff] [blame] | 106 | # Executable for generating a test ELF file for elf_reader_test.py. A host |
| 107 | # version of this binary is checked in for use in elf_reader_test.py. |
| 108 | executable("elf_reader_test_binary") { |
| 109 | deps = [ |
| 110 | ":pw_tokenizer", |
| 111 | "$dir_pw_varint", |
| 112 | ] |
| 113 | sources = [ |
| 114 | "py/elf_reader_test_binary.c", |
| 115 | ] |
| 116 | ldflags = [ "-Wl,--unresolved-symbols=ignore-all" ] # main is not defined |
| 117 | } |
| 118 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 119 | pw_test_group("tests") { |
| 120 | tests = [ |
| 121 | ":argument_types_test", |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 122 | ":base64_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 123 | ":decode_test", |
| 124 | ":detokenize_test", |
| 125 | ":hash_test", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame^] | 126 | ":simple_tokenize_test_cpp11", |
| 127 | ":simple_tokenize_test_cpp14", |
| 128 | ":simple_tokenize_test_cpp17", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 129 | ":token_database_test", |
| 130 | ":tokenize_test", |
| 131 | ] |
| 132 | group_deps = [ |
| 133 | "$dir_pw_preprocessor:tests", |
| 134 | "$dir_pw_span:tests", |
| 135 | "$dir_pw_status:tests", |
| 136 | ] |
| 137 | } |
| 138 | |
| 139 | pw_test("argument_types_test") { |
| 140 | sources = [ |
| 141 | "argument_types_test.c", |
| 142 | "argument_types_test.cc", |
| 143 | "pw_tokenizer_private/argument_types_test.h", |
| 144 | ] |
| 145 | deps = [ |
| 146 | ":pw_tokenizer", |
| 147 | ] |
| 148 | } |
| 149 | |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 150 | pw_test("base64_test") { |
| 151 | sources = [ |
| 152 | "base64_test.cc", |
| 153 | ] |
| 154 | deps = [ |
| 155 | ":base64", |
| 156 | ] |
| 157 | } |
| 158 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 159 | pw_test("decode_test") { |
| 160 | sources = [ |
| 161 | "decode_test.cc", |
| 162 | "pw_tokenizer_private/tokenized_string_decoding_test_data.h", |
| 163 | "pw_tokenizer_private/varint_decoding_test_data.h", |
| 164 | ] |
| 165 | deps = [ |
| 166 | ":decoder", |
| 167 | "$dir_pw_varint", |
| 168 | ] |
| 169 | } |
| 170 | |
| 171 | pw_test("detokenize_test") { |
| 172 | sources = [ |
| 173 | "detokenize_test.cc", |
| 174 | ] |
| 175 | deps = [ |
| 176 | ":decoder", |
| 177 | ] |
| 178 | } |
| 179 | |
| 180 | pw_test("hash_test") { |
| 181 | sources = [ |
| 182 | "hash_test.cc", |
| 183 | "pw_tokenizer_private/generated_hash_test_cases.h", |
| 184 | ] |
| 185 | deps = [ |
| 186 | ":pw_tokenizer", |
| 187 | ] |
| 188 | } |
| 189 | |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame^] | 190 | # Fully test C++11 and C++14 compatibility by compiling all sources as C++11 or |
| 191 | # C++14. |
| 192 | _simple_tokenize_test_sources = [ |
| 193 | "public/pw_tokenizer/pw_tokenizer_65599_fixed_length_hash.h", |
| 194 | "public/pw_tokenizer/tokenize.h", |
| 195 | "public/pw_tokenizer/config.h", |
| 196 | "public/pw_tokenizer/internal/argument_types.h", |
| 197 | "public/pw_tokenizer/internal/argument_types_macro_4_byte.h", |
| 198 | "public/pw_tokenizer/internal/argument_types_macro_8_byte.h", |
| 199 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h", |
| 200 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h", |
| 201 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h", |
| 202 | "public/pw_tokenizer/internal/tokenize_string.h", |
| 203 | "tokenize.cc", |
| 204 | "simple_tokenize_test.cc", |
| 205 | "$dir_pw_varint/public/pw_varint/varint.h", |
| 206 | "$dir_pw_varint/varint.cc", |
| 207 | ] |
| 208 | _simple_tokenize_test_configs = [ |
| 209 | ":default_config", |
| 210 | "$dir_pw_varint:default_config", |
| 211 | ] |
| 212 | |
| 213 | pw_test("simple_tokenize_test_cpp11") { |
| 214 | configs = [ "$dir_pw_build:cpp11" ] + _simple_tokenize_test_configs |
| 215 | sources = _simple_tokenize_test_sources |
| 216 | deps = [ |
| 217 | dir_pw_preprocessor, |
| 218 | ] |
| 219 | } |
| 220 | |
| 221 | pw_test("simple_tokenize_test_cpp14") { |
| 222 | configs = [ "$dir_pw_build:cpp14" ] + _simple_tokenize_test_configs |
| 223 | sources = _simple_tokenize_test_sources |
| 224 | deps = [ |
| 225 | dir_pw_preprocessor, |
| 226 | ] |
| 227 | } |
| 228 | |
| 229 | pw_test("simple_tokenize_test_cpp17") { |
| 230 | configs = [ "$dir_pw_build:cpp17" ] + _simple_tokenize_test_configs |
| 231 | sources = _simple_tokenize_test_sources |
| 232 | deps = [ |
| 233 | dir_pw_preprocessor, |
| 234 | ] |
| 235 | } |
| 236 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 237 | pw_test("token_database_test") { |
| 238 | sources = [ |
| 239 | "token_database_test.cc", |
| 240 | ] |
| 241 | deps = [ |
| 242 | ":decoder", |
| 243 | ] |
| 244 | } |
| 245 | |
| 246 | pw_test("tokenize_test") { |
| 247 | sources = [ |
| 248 | "pw_tokenizer_private/tokenize_test.h", |
| 249 | "tokenize_test.c", |
| 250 | "tokenize_test.cc", |
| 251 | ] |
| 252 | deps = [ |
| 253 | ":pw_tokenizer", |
| 254 | "$dir_pw_varint", |
| 255 | ] |
| 256 | } |
| 257 | |
| 258 | declare_args() { |
| 259 | # pw_java_native_interface_include_dirs specifies the paths to use for |
| 260 | # building Java Native Interface libraries. If no paths are provided, targets |
| 261 | # that require JNI may not build correctly. |
| 262 | # |
| 263 | # Example JNI include paths for a Linux system: |
| 264 | # |
| 265 | # pw_java_native_interface_include_dirs = [ |
| 266 | # "/usr/local/buildtools/java/jdk/include/", |
| 267 | # "/usr/local/buildtools/java/jdk/include/linux", |
| 268 | # ] |
| 269 | # |
| 270 | pw_java_native_interface_include_dirs = [] |
| 271 | } |
| 272 | |
| 273 | # Create a shared library for the tokenizer JNI wrapper. The include paths for |
| 274 | # the JNI headers must be available in the system or provided with the |
| 275 | # pw_java_native_interface_include_dirs variable. |
| 276 | shared_library("detokenizer_jni") { |
Wyatt Hepler | 2119240 | 2020-01-15 15:40:51 -0800 | [diff] [blame] | 277 | public_configs = [ ":default_config" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 278 | include_dirs = pw_java_native_interface_include_dirs |
| 279 | sources = [ |
| 280 | "java/dev/pigweed/tokenizer/detokenizer.cc", |
| 281 | ] |
| 282 | public_deps = [ |
| 283 | ":decoder", |
| 284 | "$dir_pw_preprocessor", |
| 285 | ] |
| 286 | } |
| 287 | |
| 288 | pw_doc_group("docs") { |
| 289 | sources = [ |
| 290 | "docs.rst", |
| 291 | ] |
| 292 | } |