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