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 | |
Armando Montanez | fb3d3fb | 2020-06-09 18:12:12 -0700 | [diff] [blame] | 15 | import("//build_overrides/pigweed.gni") |
| 16 | |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 17 | import("$dir_pw_arduino_build/arduino.gni") |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 18 | import("$dir_pw_build/facade.gni") |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 19 | import("$dir_pw_build/module_config.gni") |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 20 | import("$dir_pw_build/target_types.gni") |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 21 | import("$dir_pw_docgen/docs.gni") |
karthik bharadwaj | eabe9a2 | 2020-04-14 09:28:28 -0700 | [diff] [blame] | 22 | import("$dir_pw_fuzzer/fuzzer.gni") |
Wyatt Hepler | de20d74 | 2021-06-02 23:34:14 -0700 | [diff] [blame] | 23 | import("$dir_pw_protobuf_compiler/proto.gni") |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 24 | import("$dir_pw_unit_test/test.gni") |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 25 | import("backend.gni") |
Wyatt Hepler | d49f8fe | 2020-10-15 10:13:47 -0700 | [diff] [blame] | 26 | |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 27 | declare_args() { |
| 28 | # The build target that overrides the default configuration options for this |
| 29 | # module. This should point to a source set that provides defines through a |
| 30 | # public config (which may -include a file or add defines directly). |
| 31 | pw_tokenizer_CONFIG = pw_build_DEFAULT_MODULE_CONFIG |
| 32 | } |
| 33 | |
| 34 | config("public_include_path") { |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 35 | include_dirs = [ "public" ] |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 36 | visibility = [ ":*" ] |
| 37 | } |
| 38 | |
Wyatt Hepler | 3a8df98 | 2020-11-03 14:06:28 -0800 | [diff] [blame] | 39 | config("linker_script") { |
| 40 | inputs = [ "pw_tokenizer_linker_sections.ld" ] |
| 41 | |
| 42 | # Automatically add the tokenizer linker sections when cross-compiling or |
| 43 | # building for Linux. macOS and Windows executables are not supported. |
| 44 | if (current_os == "") { |
| 45 | ldflags = [ |
| 46 | "-T", |
Michael Spang | c8b9390 | 2021-05-30 15:53:56 -0400 | [diff] [blame] | 47 | rebase_path("pw_tokenizer_linker_sections.ld", root_build_dir), |
Wyatt Hepler | 3a8df98 | 2020-11-03 14:06:28 -0800 | [diff] [blame] | 48 | ] |
Wyatt Hepler | 1df2e5b | 2021-01-28 12:39:22 -0800 | [diff] [blame] | 49 | } else if (current_os == "linux" && !pw_toolchain_OSS_FUZZ_ENABLED) { |
Wyatt Hepler | 3a8df98 | 2020-11-03 14:06:28 -0800 | [diff] [blame] | 50 | # When building for Linux, the linker provides a default linker script. |
| 51 | # The add_tokenizer_sections_to_default_script.ld wrapper includes the |
| 52 | # pw_tokenizer_linker_sections.ld script in a way that appends to the the |
| 53 | # default linker script instead of overriding it. |
| 54 | ldflags = [ |
| 55 | "-T", |
Michael Spang | c8b9390 | 2021-05-30 15:53:56 -0400 | [diff] [blame] | 56 | rebase_path("add_tokenizer_sections_to_default_script.ld", |
| 57 | root_build_dir), |
Wyatt Hepler | 3a8df98 | 2020-11-03 14:06:28 -0800 | [diff] [blame] | 58 | ] |
Michael Spang | c8b9390 | 2021-05-30 15:53:56 -0400 | [diff] [blame] | 59 | lib_dirs = [ "." ] |
| 60 | |
Wyatt Hepler | 3a8df98 | 2020-11-03 14:06:28 -0800 | [diff] [blame] | 61 | inputs += [ "add_tokenizer_sections_to_default_script.ld" ] |
| 62 | } |
| 63 | visibility = [ ":*" ] |
| 64 | } |
| 65 | |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 66 | pw_source_set("config") { |
| 67 | public = [ "public/pw_tokenizer/config.h" ] |
| 68 | public_configs = [ ":public_include_path" ] |
| 69 | public_deps = [ pw_tokenizer_CONFIG ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 70 | } |
| 71 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 72 | pw_source_set("pw_tokenizer") { |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 73 | public_configs = [ ":public_include_path" ] |
Wyatt Hepler | 3a8df98 | 2020-11-03 14:06:28 -0800 | [diff] [blame] | 74 | all_dependent_configs = [ ":linker_script" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 75 | public_deps = [ |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 76 | ":config", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 77 | dir_pw_preprocessor, |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 78 | ] |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 79 | deps = [ dir_pw_varint ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 80 | public = [ |
Wyatt Hepler | 7c8b339 | 2021-04-05 18:00:24 -0700 | [diff] [blame] | 81 | "public/pw_tokenizer/encode_args.h", |
Wyatt Hepler | eb020a1 | 2020-10-28 14:01:51 -0700 | [diff] [blame] | 82 | "public/pw_tokenizer/hash.h", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 83 | "public/pw_tokenizer/tokenize.h", |
| 84 | ] |
| 85 | sources = [ |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 86 | "encode_args.cc", |
Wyatt Hepler | 656fac6 | 2020-10-28 14:30:59 -0700 | [diff] [blame] | 87 | "hash.cc", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 88 | "public/pw_tokenizer/internal/argument_types.h", |
| 89 | "public/pw_tokenizer/internal/argument_types_macro_4_byte.h", |
| 90 | "public/pw_tokenizer/internal/argument_types_macro_8_byte.h", |
| 91 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h", |
Wyatt Hepler | 63c9bee | 2021-02-23 11:37:15 -0800 | [diff] [blame] | 92 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_256_hash_macro.h", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 93 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h", |
| 94 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h", |
| 95 | "public/pw_tokenizer/internal/tokenize_string.h", |
| 96 | "tokenize.cc", |
| 97 | ] |
Wyatt Hepler | a8557ef | 2020-05-04 16:29:23 -0700 | [diff] [blame] | 98 | friend = [ ":*" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 101 | # As a temporary workaround, if no backend is set, use an empty test backend so |
| 102 | # that the test can define the handler function. |
| 103 | # TODO(hepler): Switch this to a facade test when available. |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 104 | if (pw_tokenizer_GLOBAL_HANDLER_BACKEND == "" && |
| 105 | pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND == "") { |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 106 | # This is an empty library to use as the backend for global_handler and |
| 107 | # global_handler_with_payload tests. |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 108 | pw_source_set("test_backend") { |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 109 | visibility = [ ":*" ] |
| 110 | } |
| 111 | |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 112 | pw_tokenizer_GLOBAL_HANDLER_BACKEND = ":test_backend" |
| 113 | pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND = ":test_backend" |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 114 | |
| 115 | enable_global_handler_test = true |
| 116 | } else { |
| 117 | enable_global_handler_test = false |
| 118 | } |
| 119 | |
| 120 | pw_facade("global_handler") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 121 | backend = pw_tokenizer_GLOBAL_HANDLER_BACKEND |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 122 | |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 123 | public_configs = [ ":public_include_path" ] |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 124 | public = [ "public/pw_tokenizer/tokenize_to_global_handler.h" ] |
| 125 | sources = [ "tokenize_to_global_handler.cc" ] |
| 126 | public_deps = [ ":pw_tokenizer" ] |
| 127 | } |
| 128 | |
| 129 | pw_facade("global_handler_with_payload") { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 130 | backend = pw_tokenizer_GLOBAL_HANDLER_WITH_PAYLOAD_BACKEND |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 131 | |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 132 | public_configs = [ ":public_include_path" ] |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 133 | public = [ "public/pw_tokenizer/tokenize_to_global_handler_with_payload.h" ] |
| 134 | sources = [ "tokenize_to_global_handler_with_payload.cc" ] |
| 135 | public_deps = [ ":pw_tokenizer" ] |
| 136 | } |
| 137 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 138 | pw_source_set("base64") { |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 139 | public_configs = [ ":public_include_path" ] |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 140 | public = [ "public/pw_tokenizer/base64.h" ] |
Wyatt Hepler | a8557ef | 2020-05-04 16:29:23 -0700 | [diff] [blame] | 141 | sources = [ "base64.cc" ] |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 142 | public_deps = [ |
Wyatt Hepler | cdafbb4 | 2020-10-05 11:51:05 -0700 | [diff] [blame] | 143 | ":pw_tokenizer", |
| 144 | dir_pw_base64, |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 145 | dir_pw_preprocessor, |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 146 | ] |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 147 | } |
| 148 | |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 149 | pw_source_set("decoder") { |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 150 | public_configs = [ ":public_include_path" ] |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 151 | deps = [ dir_pw_varint ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 152 | public = [ |
| 153 | "public/pw_tokenizer/detokenize.h", |
| 154 | "public/pw_tokenizer/token_database.h", |
| 155 | ] |
| 156 | sources = [ |
| 157 | "decode.cc", |
| 158 | "detokenize.cc", |
| 159 | "public/pw_tokenizer/internal/decode.h", |
| 160 | "token_database.cc", |
| 161 | ] |
Wyatt Hepler | a8557ef | 2020-05-04 16:29:23 -0700 | [diff] [blame] | 162 | friend = [ ":*" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | # Executable for generating test data for the C++ and Python detokenizers. This |
| 166 | # target should only be built for the host. |
Alexei Frolov | 2e55ee2 | 2020-06-17 17:00:10 -0700 | [diff] [blame] | 167 | pw_executable("generate_decoding_test_data") { |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 168 | deps = [ |
| 169 | ":decoder", |
| 170 | ":pw_tokenizer", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 171 | dir_pw_varint, |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 172 | ] |
Ewout van Bekkum | e4d7b69 | 2020-10-15 13:12:30 -0700 | [diff] [blame] | 173 | sources = [ "generate_decoding_test_data.cc" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 174 | } |
| 175 | |
Wyatt Hepler | bc25497 | 2020-01-06 18:35:30 -0800 | [diff] [blame] | 176 | # Executable for generating a test ELF file for elf_reader_test.py. A host |
| 177 | # version of this binary is checked in for use in elf_reader_test.py. |
Alexei Frolov | 2e55ee2 | 2020-06-17 17:00:10 -0700 | [diff] [blame] | 178 | pw_executable("elf_reader_test_binary") { |
Wyatt Hepler | bc25497 | 2020-01-06 18:35:30 -0800 | [diff] [blame] | 179 | deps = [ |
| 180 | ":pw_tokenizer", |
| 181 | "$dir_pw_varint", |
| 182 | ] |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 183 | sources = [ "py/elf_reader_test_binary.c" ] |
Wyatt Hepler | bc25497 | 2020-01-06 18:35:30 -0800 | [diff] [blame] | 184 | ldflags = [ "-Wl,--unresolved-symbols=ignore-all" ] # main is not defined |
| 185 | } |
| 186 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 187 | pw_test_group("tests") { |
| 188 | tests = [ |
| 189 | ":argument_types_test", |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 190 | ":base64_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 191 | ":decode_test", |
karthik bharadwaj | eabe9a2 | 2020-04-14 09:28:28 -0700 | [diff] [blame] | 192 | ":detokenize_fuzzer", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 193 | ":detokenize_test", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 194 | ":global_handlers_test", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 195 | ":hash_test", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 196 | ":simple_tokenize_test_cpp11", |
| 197 | ":simple_tokenize_test_cpp14", |
| 198 | ":simple_tokenize_test_cpp17", |
karthik bharadwaj | 2ee244b | 2020-04-16 14:08:22 -0700 | [diff] [blame] | 199 | ":token_database_fuzzer", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 200 | ":token_database_test", |
| 201 | ":tokenize_test", |
| 202 | ] |
Wyatt Hepler | 7abd8cc | 2021-01-19 16:49:33 -0800 | [diff] [blame] | 203 | group_deps = [ "$dir_pw_preprocessor:tests" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | pw_test("argument_types_test") { |
| 207 | sources = [ |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 208 | "argument_types_test.cc", |
Michael Spang | a99220e | 2020-06-11 20:07:16 -0400 | [diff] [blame] | 209 | "argument_types_test_c.c", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 210 | "pw_tokenizer_private/argument_types_test.h", |
| 211 | ] |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 212 | deps = [ ":pw_tokenizer" ] |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 213 | |
Anthony DiGirolamo | 383be05 | 2020-11-26 12:06:41 -0800 | [diff] [blame] | 214 | if (pw_arduino_build_CORE_PATH != "") { |
Anthony DiGirolamo | eea0d77 | 2020-08-06 12:00:36 -0700 | [diff] [blame] | 215 | remove_configs = [ "$dir_pw_build:strict_warnings" ] |
| 216 | } |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 219 | pw_test("base64_test") { |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 220 | sources = [ "base64_test.cc" ] |
| 221 | deps = [ ":base64" ] |
Wyatt Hepler | 3c2e952 | 2020-01-09 16:08:54 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 224 | pw_test("decode_test") { |
| 225 | sources = [ |
| 226 | "decode_test.cc", |
| 227 | "pw_tokenizer_private/tokenized_string_decoding_test_data.h", |
| 228 | "pw_tokenizer_private/varint_decoding_test_data.h", |
| 229 | ] |
| 230 | deps = [ |
| 231 | ":decoder", |
| 232 | "$dir_pw_varint", |
| 233 | ] |
Anthony DiGirolamo | b507917 | 2020-11-05 12:59:50 -0800 | [diff] [blame] | 234 | |
| 235 | # TODO(tonymd): This fails on Teensyduino 1.54 beta core. It may be related to |
| 236 | # linking in stl functions. Will debug when 1.54 is released. |
| 237 | enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "arduino_executable" |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | pw_test("detokenize_test") { |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 241 | sources = [ "detokenize_test.cc" ] |
| 242 | deps = [ ":decoder" ] |
Anthony DiGirolamo | b507917 | 2020-11-05 12:59:50 -0800 | [diff] [blame] | 243 | |
| 244 | # TODO(tonymd): This fails on Teensyduino 1.54 beta core. It may be related to |
| 245 | # linking in stl functions. Will debug when 1.54 is released. |
| 246 | enable_if = pw_build_EXECUTABLE_TARGET_TYPE != "arduino_executable" |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 247 | } |
| 248 | |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 249 | pw_test("global_handlers_test") { |
| 250 | sources = [ |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 251 | "global_handlers_test.cc", |
Michael Spang | a99220e | 2020-06-11 20:07:16 -0400 | [diff] [blame] | 252 | "global_handlers_test_c.c", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 253 | "pw_tokenizer_private/tokenize_test.h", |
| 254 | ] |
| 255 | deps = [ |
| 256 | ":global_handler", |
| 257 | ":global_handler_with_payload", |
| 258 | ] |
| 259 | |
| 260 | # TODO(hepler): Switch this to a facade test when available. |
| 261 | enable_if = enable_global_handler_test |
| 262 | } |
| 263 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 264 | pw_test("hash_test") { |
| 265 | sources = [ |
| 266 | "hash_test.cc", |
| 267 | "pw_tokenizer_private/generated_hash_test_cases.h", |
| 268 | ] |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 269 | deps = [ ":pw_tokenizer" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 270 | } |
| 271 | |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 272 | # Fully test C++11 and C++14 compatibility by compiling all sources as C++11 or |
| 273 | # C++14. |
| 274 | _simple_tokenize_test_sources = [ |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 275 | "$dir_pw_varint/public/pw_varint/varint.h", |
| 276 | "$dir_pw_varint/varint.cc", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 277 | "encode_args.cc", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 278 | "public/pw_tokenizer/config.h", |
Wyatt Hepler | 7c8b339 | 2021-04-05 18:00:24 -0700 | [diff] [blame] | 279 | "public/pw_tokenizer/encode_args.h", |
Wyatt Hepler | eb020a1 | 2020-10-28 14:01:51 -0700 | [diff] [blame] | 280 | "public/pw_tokenizer/hash.h", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 281 | "public/pw_tokenizer/internal/argument_types.h", |
| 282 | "public/pw_tokenizer/internal/argument_types_macro_4_byte.h", |
| 283 | "public/pw_tokenizer/internal/argument_types_macro_8_byte.h", |
| 284 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_128_hash_macro.h", |
| 285 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_80_hash_macro.h", |
| 286 | "public/pw_tokenizer/internal/pw_tokenizer_65599_fixed_length_96_hash_macro.h", |
| 287 | "public/pw_tokenizer/internal/tokenize_string.h", |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 288 | "public/pw_tokenizer/tokenize.h", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 289 | "public/pw_tokenizer/tokenize_to_global_handler.h", |
| 290 | "public/pw_tokenizer/tokenize_to_global_handler_with_payload.h", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 291 | "simple_tokenize_test.cc", |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 292 | "tokenize.cc", |
Wyatt Hepler | 6639c45 | 2020-05-06 11:43:07 -0700 | [diff] [blame] | 293 | "tokenize_to_global_handler.cc", |
| 294 | "tokenize_to_global_handler_with_payload.cc", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 295 | ] |
| 296 | _simple_tokenize_test_configs = [ |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 297 | ":public_include_path", |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 298 | "$dir_pw_varint:default_config", |
| 299 | ] |
| 300 | |
| 301 | pw_test("simple_tokenize_test_cpp11") { |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 302 | remove_configs = [ "$dir_pw_build:cpp17" ] |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 303 | configs = [ "$dir_pw_build:cpp11" ] + _simple_tokenize_test_configs |
| 304 | sources = _simple_tokenize_test_sources |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 305 | deps = [ dir_pw_preprocessor ] |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | pw_test("simple_tokenize_test_cpp14") { |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 309 | remove_configs = [ "$dir_pw_build:cpp17" ] |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 310 | configs = [ "$dir_pw_build:cpp14" ] + _simple_tokenize_test_configs |
| 311 | sources = _simple_tokenize_test_sources |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 312 | deps = [ dir_pw_preprocessor ] |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | pw_test("simple_tokenize_test_cpp17") { |
Alexei Frolov | 844ff0f | 2020-05-06 12:15:29 -0700 | [diff] [blame] | 316 | configs = _simple_tokenize_test_configs |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 317 | sources = _simple_tokenize_test_sources |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 318 | deps = [ dir_pw_preprocessor ] |
Wyatt Hepler | a6d5cc6 | 2020-01-17 14:15:40 -0800 | [diff] [blame] | 319 | } |
| 320 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 321 | pw_test("token_database_test") { |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 322 | sources = [ "token_database_test.cc" ] |
| 323 | deps = [ ":decoder" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | pw_test("tokenize_test") { |
| 327 | sources = [ |
| 328 | "pw_tokenizer_private/tokenize_test.h", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 329 | "tokenize_test.cc", |
Michael Spang | a99220e | 2020-06-11 20:07:16 -0400 | [diff] [blame] | 330 | "tokenize_test_c.c", |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 331 | ] |
| 332 | deps = [ |
| 333 | ":pw_tokenizer", |
| 334 | "$dir_pw_varint", |
| 335 | ] |
| 336 | } |
| 337 | |
karthik bharadwaj | 2ee244b | 2020-04-16 14:08:22 -0700 | [diff] [blame] | 338 | pw_fuzzer("token_database_fuzzer") { |
| 339 | sources = [ "token_database_fuzzer.cc" ] |
| 340 | deps = [ |
| 341 | ":decoder", |
| 342 | "$dir_pw_fuzzer", |
| 343 | "$dir_pw_preprocessor", |
karthik bharadwaj | 2ee244b | 2020-04-16 14:08:22 -0700 | [diff] [blame] | 344 | ] |
| 345 | } |
| 346 | |
karthik bharadwaj | eabe9a2 | 2020-04-14 09:28:28 -0700 | [diff] [blame] | 347 | pw_fuzzer("detokenize_fuzzer") { |
| 348 | sources = [ "detokenize_fuzzer.cc" ] |
| 349 | deps = [ |
| 350 | ":decoder", |
| 351 | "$dir_pw_fuzzer", |
| 352 | "$dir_pw_preprocessor", |
| 353 | ] |
| 354 | } |
| 355 | |
Wyatt Hepler | de20d74 | 2021-06-02 23:34:14 -0700 | [diff] [blame] | 356 | pw_proto_library("proto") { |
| 357 | sources = [ "options.proto" ] |
| 358 | prefix = "pw_tokenizer/proto" |
| 359 | python_package = "py" |
| 360 | } |
| 361 | |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 362 | declare_args() { |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 363 | # pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS specifies the paths to use for |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 364 | # building Java Native Interface libraries. If no paths are provided, targets |
| 365 | # that require JNI may not build correctly. |
| 366 | # |
| 367 | # Example JNI include paths for a Linux system: |
| 368 | # |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 369 | # pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS = [ |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 370 | # "/usr/local/buildtools/java/jdk/include/", |
| 371 | # "/usr/local/buildtools/java/jdk/include/linux", |
| 372 | # ] |
| 373 | # |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 374 | pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS = [] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | # Create a shared library for the tokenizer JNI wrapper. The include paths for |
| 378 | # the JNI headers must be available in the system or provided with the |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 379 | # pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS variable. |
Alexei Frolov | edd2f14 | 2020-06-09 19:11:27 -0700 | [diff] [blame] | 380 | pw_shared_library("detokenizer_jni") { |
Wyatt Hepler | 86632c7 | 2020-10-15 08:45:50 -0700 | [diff] [blame] | 381 | public_configs = [ ":public_include_path" ] |
Alexei Frolov | 4c0428a | 2020-06-10 10:46:04 -0700 | [diff] [blame] | 382 | include_dirs = pw_JAVA_NATIVE_INTERFACE_INCLUDE_DIRS |
Rob Mohr | a0ba54f | 2020-02-27 11:43:49 -0800 | [diff] [blame] | 383 | sources = [ "java/dev/pigweed/tokenizer/detokenizer.cc" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 384 | public_deps = [ |
| 385 | ":decoder", |
| 386 | "$dir_pw_preprocessor", |
| 387 | ] |
| 388 | } |
| 389 | |
| 390 | pw_doc_group("docs") { |
Wyatt Hepler | de20d74 | 2021-06-02 23:34:14 -0700 | [diff] [blame] | 391 | sources = [ |
| 392 | "docs.rst", |
| 393 | "proto.rst", |
| 394 | ] |
Wyatt Hepler | f5e984a | 2020-04-15 18:15:09 -0700 | [diff] [blame] | 395 | inputs = [ "py/pw_tokenizer/encode.py" ] |
Wyatt Hepler | 80c6ee5 | 2020-01-03 09:54:58 -0800 | [diff] [blame] | 396 | } |