Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 1 | # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 5 | import("//build/buildflag_header.gni") |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 6 | import("//chrome/process_version_rc_template.gni") |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 7 | import("//testing/test.gni") |
| 8 | |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 9 | buildflag_header("buildflags") { |
| 10 | header = "buildflags.h" |
| 11 | |
| 12 | # Disable DEX on Windows Official Builds. |
| 13 | _enable_dex = !(is_win && is_official_build) |
Etienne Pierre-doray | e57c4e6 | 2018-08-10 17:44:37 +0000 | [diff] [blame] | 14 | _enable_elf = true |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 15 | _enable_win = true |
Calder Kitagawa | 0d7a251 | 2018-05-23 17:30:51 +0000 | [diff] [blame] | 16 | |
| 17 | # Disable ZTF (Zucchini Text Format) on official builds it is for testing only. |
| 18 | _enable_ztf = !is_official_build |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 19 | flags = [ |
| 20 | "ENABLE_DEX=$_enable_dex", |
Etienne Pierre-doray | e57c4e6 | 2018-08-10 17:44:37 +0000 | [diff] [blame] | 21 | "ENABLE_ELF=$_enable_elf", |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 22 | "ENABLE_WIN=$_enable_win", |
Calder Kitagawa | 0d7a251 | 2018-05-23 17:30:51 +0000 | [diff] [blame] | 23 | "ENABLE_ZTF=$_enable_ztf", |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 24 | ] |
| 25 | } |
| 26 | |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 27 | static_library("zucchini_lib") { |
| 28 | sources = [ |
| 29 | "abs32_utils.cc", |
| 30 | "abs32_utils.h", |
| 31 | "address_translator.cc", |
| 32 | "address_translator.h", |
| 33 | "algorithm.h", |
Samuel Huang | 65b242d | 2019-01-11 20:00:13 +0000 | [diff] [blame] | 34 | "arm_utils.cc", |
| 35 | "arm_utils.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 36 | "binary_data_histogram.cc", |
| 37 | "binary_data_histogram.h", |
| 38 | "buffer_sink.cc", |
| 39 | "buffer_sink.h", |
| 40 | "buffer_source.cc", |
| 41 | "buffer_source.h", |
| 42 | "buffer_view.h", |
| 43 | "crc32.cc", |
| 44 | "crc32.h", |
| 45 | "disassembler.cc", |
| 46 | "disassembler.h", |
Etienne Pierre-Doray | fff1ca3 | 2018-03-29 13:33:46 +0000 | [diff] [blame] | 47 | "disassembler_dex.cc", |
| 48 | "disassembler_dex.h", |
Etienne Pierre-doray | e57c4e6 | 2018-08-10 17:44:37 +0000 | [diff] [blame] | 49 | "disassembler_elf.cc", |
| 50 | "disassembler_elf.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 51 | "disassembler_no_op.cc", |
| 52 | "disassembler_no_op.h", |
| 53 | "disassembler_win32.cc", |
| 54 | "disassembler_win32.h", |
Calder Kitagawa | 0d7a251 | 2018-05-23 17:30:51 +0000 | [diff] [blame] | 55 | "disassembler_ztf.cc", |
| 56 | "disassembler_ztf.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 57 | "element_detection.cc", |
| 58 | "element_detection.h", |
| 59 | "encoded_view.cc", |
| 60 | "encoded_view.h", |
| 61 | "ensemble_matcher.cc", |
| 62 | "ensemble_matcher.h", |
| 63 | "equivalence_map.cc", |
| 64 | "equivalence_map.h", |
| 65 | "heuristic_ensemble_matcher.cc", |
| 66 | "heuristic_ensemble_matcher.h", |
| 67 | "image_index.cc", |
| 68 | "image_index.h", |
| 69 | "image_utils.h", |
Samuel Huang | 6951a28 | 2018-04-30 22:47:52 +0000 | [diff] [blame] | 70 | "imposed_ensemble_matcher.cc", |
| 71 | "imposed_ensemble_matcher.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 72 | "io_utils.cc", |
| 73 | "io_utils.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 74 | "patch_reader.cc", |
| 75 | "patch_reader.h", |
| 76 | "patch_utils.h", |
| 77 | "patch_writer.cc", |
| 78 | "patch_writer.h", |
Samuel Huang | 451ff5d | 2018-04-20 17:40:00 +0000 | [diff] [blame] | 79 | "reference_bytes_mixer.cc", |
| 80 | "reference_bytes_mixer.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 81 | "reference_set.cc", |
| 82 | "reference_set.h", |
| 83 | "rel32_finder.cc", |
| 84 | "rel32_finder.h", |
| 85 | "rel32_utils.cc", |
| 86 | "rel32_utils.h", |
Etienne Pierre-Doray | a88cad0 | 2018-07-25 20:16:02 +0000 | [diff] [blame] | 87 | "reloc_elf.cc", |
| 88 | "reloc_elf.h", |
Etienne Pierre-doray | ae27d8e | 2018-07-24 15:42:33 +0000 | [diff] [blame] | 89 | "reloc_win32.cc", |
| 90 | "reloc_win32.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 91 | "suffix_array.h", |
| 92 | "target_pool.cc", |
| 93 | "target_pool.h", |
| 94 | "targets_affinity.cc", |
| 95 | "targets_affinity.h", |
Etienne Pierre-Doray | fff1ca3 | 2018-03-29 13:33:46 +0000 | [diff] [blame] | 96 | "type_dex.h", |
Etienne Pierre-Doray | a88cad0 | 2018-07-25 20:16:02 +0000 | [diff] [blame] | 97 | "type_elf.h", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 98 | "type_win_pe.h", |
| 99 | "typed_value.h", |
| 100 | "zucchini.h", |
| 101 | "zucchini_apply.cc", |
| 102 | "zucchini_apply.h", |
| 103 | "zucchini_gen.cc", |
| 104 | "zucchini_gen.h", |
| 105 | "zucchini_tools.cc", |
| 106 | "zucchini_tools.h", |
| 107 | ] |
| 108 | |
| 109 | deps = [ |
Calder Kitagawa | f1724dd | 2018-05-08 15:08:31 +0000 | [diff] [blame] | 110 | ":buildflags", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 111 | "//base", |
| 112 | ] |
| 113 | } |
| 114 | |
| 115 | static_library("zucchini_io") { |
| 116 | sources = [ |
| 117 | "mapped_file.cc", |
| 118 | "mapped_file.h", |
| 119 | "zucchini_integration.cc", |
| 120 | "zucchini_integration.h", |
| 121 | ] |
| 122 | |
| 123 | deps = [ |
| 124 | ":zucchini_lib", |
| 125 | "//base", |
| 126 | ] |
| 127 | } |
| 128 | |
| 129 | executable("zucchini") { |
| 130 | sources = [ |
| 131 | "main_utils.cc", |
| 132 | "main_utils.h", |
| 133 | "zucchini_commands.cc", |
| 134 | "zucchini_commands.h", |
| 135 | "zucchini_main.cc", |
| 136 | ] |
| 137 | |
| 138 | deps = [ |
| 139 | ":zucchini_io", |
| 140 | ":zucchini_lib", |
| 141 | "//base", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 142 | ] |
| 143 | |
| 144 | if (is_win) { |
| 145 | deps += [ ":zucchini_exe_version" ] |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | if (is_win) { |
| 150 | process_version_rc_template("zucchini_exe_version") { |
| 151 | template_file = "zucchini_exe_version.rc.version" |
| 152 | output = "$target_gen_dir/zucchini_exe_version.rc" |
| 153 | } |
| 154 | } |
| 155 | |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 156 | test("zucchini_unittests") { |
| 157 | sources = [ |
| 158 | "abs32_utils_unittest.cc", |
| 159 | "address_translator_unittest.cc", |
| 160 | "algorithm_unittest.cc", |
Samuel Huang | 65b242d | 2019-01-11 20:00:13 +0000 | [diff] [blame] | 161 | "arm_utils_unittest.cc", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 162 | "binary_data_histogram_unittest.cc", |
| 163 | "buffer_sink_unittest.cc", |
| 164 | "buffer_source_unittest.cc", |
| 165 | "buffer_view_unittest.cc", |
| 166 | "crc32_unittest.cc", |
Samuel Huang | a8a2a94 | 2018-04-09 15:18:17 +0000 | [diff] [blame] | 167 | "disassembler_dex_unittest.cc", |
Etienne Pierre-doray | e57c4e6 | 2018-08-10 17:44:37 +0000 | [diff] [blame] | 168 | "disassembler_elf_unittest.cc", |
Calder Kitagawa | 0d7a251 | 2018-05-23 17:30:51 +0000 | [diff] [blame] | 169 | "disassembler_ztf_unittest.cc", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 170 | "element_detection_unittest.cc", |
| 171 | "encoded_view_unittest.cc", |
| 172 | "equivalence_map_unittest.cc", |
| 173 | "image_index_unittest.cc", |
| 174 | "image_utils_unittest.cc", |
Samuel Huang | 6951a28 | 2018-04-30 22:47:52 +0000 | [diff] [blame] | 175 | "imposed_ensemble_matcher_unittest.cc", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 176 | "io_utils_unittest.cc", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 177 | "mapped_file_unittest.cc", |
| 178 | "patch_read_write_unittest.cc", |
| 179 | "patch_utils_unittest.cc", |
| 180 | "reference_set_unittest.cc", |
| 181 | "rel32_finder_unittest.cc", |
| 182 | "rel32_utils_unittest.cc", |
Etienne Pierre-Doray | a88cad0 | 2018-07-25 20:16:02 +0000 | [diff] [blame] | 183 | "reloc_elf_unittest.cc", |
Etienne Pierre-doray | ae27d8e | 2018-07-24 15:42:33 +0000 | [diff] [blame] | 184 | "reloc_win32_unittest.cc", |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 185 | "suffix_array_unittest.cc", |
| 186 | "target_pool_unittest.cc", |
| 187 | "targets_affinity_unittest.cc", |
| 188 | "test_disassembler.cc", |
| 189 | "test_disassembler.h", |
| 190 | "test_reference_reader.cc", |
| 191 | "test_reference_reader.h", |
| 192 | "test_utils.cc", |
| 193 | "test_utils.h", |
| 194 | "typed_value_unittest.cc", |
| 195 | "zucchini_apply_unittest.cc", |
| 196 | "zucchini_gen_unittest.cc", |
| 197 | ] |
| 198 | |
| 199 | deps = [ |
| 200 | ":zucchini_io", |
| 201 | ":zucchini_lib", |
| 202 | "//base", |
| 203 | "//base/test:run_all_unittests", |
| 204 | "//base/test:test_support", |
| 205 | "//testing/gtest", |
| 206 | ] |
| 207 | } |
| 208 | |
| 209 | test("zucchini_integration_test") { |
Nico Weber | 1940ec9 | 2020-01-13 18:48:21 +0000 | [diff] [blame] | 210 | sources = [ "integration_test.cc" ] |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 211 | |
| 212 | deps = [ |
| 213 | ":zucchini_lib", |
| 214 | "//base", |
| 215 | "//base/test:run_all_unittests", |
| 216 | "//base/test:test_support", |
| 217 | "//testing/gtest", |
| 218 | ] |
Richard Townsend | 80851dc | 2020-03-18 20:12:36 +0000 | [diff] [blame] | 219 | |
| 220 | data = [ "testdata" ] |
Samuel Huang | 06f1ae9 | 2018-03-13 18:19:34 +0000 | [diff] [blame] | 221 | } |
Calder Kitagawa | a401b7e | 2018-04-24 20:35:27 +0000 | [diff] [blame] | 222 | |
| 223 | # Group to build and depend on all the Zucchini related fuzzers. |
| 224 | group("zucchini_fuzzers") { |
| 225 | testonly = true |
| 226 | deps = [ |
Calder Kitagawa | 9ee7e43 | 2018-07-03 14:30:05 +0000 | [diff] [blame] | 227 | "//components/zucchini/fuzzers:zucchini_disassembler_dex_fuzzer", |
Calder Kitagawa | a401b7e | 2018-04-24 20:35:27 +0000 | [diff] [blame] | 228 | "//components/zucchini/fuzzers:zucchini_disassembler_win32_fuzzer", |
| 229 | "//components/zucchini/fuzzers:zucchini_patch_fuzzer", |
| 230 | ] |
Calder Kitagawa | 11c1b2a | 2018-05-09 19:51:14 +0000 | [diff] [blame] | 231 | |
| 232 | # Ensure protoc is available. |
Calder Kitagawa | c4290b5 | 2018-05-24 21:36:47 +0000 | [diff] [blame] | 233 | # Disabled on Windows due to crbug/844826. |
| 234 | if (current_toolchain == host_toolchain && !is_win) { |
Calder Kitagawa | 1bed19c | 2018-05-17 21:07:49 +0000 | [diff] [blame] | 235 | deps += [ |
Calder Kitagawa | 806fa63 | 2018-05-28 14:30:21 +0000 | [diff] [blame] | 236 | "//components/zucchini/fuzzers:zucchini_apply_fuzzer", |
Calder Kitagawa | 6178480 | 2018-07-03 14:25:19 +0000 | [diff] [blame] | 237 | "//components/zucchini/fuzzers:zucchini_imposed_ensemble_matcher_fuzzer", |
Calder Kitagawa | 1bed19c | 2018-05-17 21:07:49 +0000 | [diff] [blame] | 238 | "//components/zucchini/fuzzers:zucchini_raw_gen_fuzzer", |
Calder Kitagawa | 75569ad | 2018-05-25 19:49:43 +0000 | [diff] [blame] | 239 | "//components/zucchini/fuzzers:zucchini_ztf_gen_fuzzer", |
Calder Kitagawa | 1bed19c | 2018-05-17 21:07:49 +0000 | [diff] [blame] | 240 | ] |
Calder Kitagawa | 11c1b2a | 2018-05-09 19:51:14 +0000 | [diff] [blame] | 241 | } |
Calder Kitagawa | a401b7e | 2018-04-24 20:35:27 +0000 | [diff] [blame] | 242 | } |