| # Copyright 2017 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/buildflag_header.gni") |
| import("//chrome/process_version_rc_template.gni") |
| import("//testing/test.gni") |
| |
| buildflag_header("buildflags") { |
| header = "buildflags.h" |
| |
| # Disable DEX on Windows Official Builds. |
| _enable_dex = !(is_win && is_official_build) |
| _enable_win = true |
| |
| # Disable ZTF (Zucchini Text Format) on official builds it is for testing only. |
| _enable_ztf = !is_official_build |
| flags = [ |
| "ENABLE_DEX=$_enable_dex", |
| "ENABLE_WIN=$_enable_win", |
| "ENABLE_ZTF=$_enable_ztf", |
| ] |
| } |
| |
| static_library("zucchini_lib") { |
| sources = [ |
| "abs32_utils.cc", |
| "abs32_utils.h", |
| "address_translator.cc", |
| "address_translator.h", |
| "algorithm.h", |
| "binary_data_histogram.cc", |
| "binary_data_histogram.h", |
| "buffer_sink.cc", |
| "buffer_sink.h", |
| "buffer_source.cc", |
| "buffer_source.h", |
| "buffer_view.h", |
| "crc32.cc", |
| "crc32.h", |
| "disassembler.cc", |
| "disassembler.h", |
| "disassembler_dex.cc", |
| "disassembler_dex.h", |
| "disassembler_no_op.cc", |
| "disassembler_no_op.h", |
| "disassembler_win32.cc", |
| "disassembler_win32.h", |
| "disassembler_ztf.cc", |
| "disassembler_ztf.h", |
| "element_detection.cc", |
| "element_detection.h", |
| "encoded_view.cc", |
| "encoded_view.h", |
| "ensemble_matcher.cc", |
| "ensemble_matcher.h", |
| "equivalence_map.cc", |
| "equivalence_map.h", |
| "heuristic_ensemble_matcher.cc", |
| "heuristic_ensemble_matcher.h", |
| "image_index.cc", |
| "image_index.h", |
| "image_utils.h", |
| "imposed_ensemble_matcher.cc", |
| "imposed_ensemble_matcher.h", |
| "io_utils.cc", |
| "io_utils.h", |
| "patch_reader.cc", |
| "patch_reader.h", |
| "patch_utils.h", |
| "patch_writer.cc", |
| "patch_writer.h", |
| "reference_bytes_mixer.cc", |
| "reference_bytes_mixer.h", |
| "reference_set.cc", |
| "reference_set.h", |
| "rel32_finder.cc", |
| "rel32_finder.h", |
| "rel32_utils.cc", |
| "rel32_utils.h", |
| "reloc_utils.cc", |
| "reloc_utils.h", |
| "suffix_array.h", |
| "target_pool.cc", |
| "target_pool.h", |
| "targets_affinity.cc", |
| "targets_affinity.h", |
| "type_dex.h", |
| "type_win_pe.h", |
| "typed_value.h", |
| "zucchini.h", |
| "zucchini_apply.cc", |
| "zucchini_apply.h", |
| "zucchini_gen.cc", |
| "zucchini_gen.h", |
| "zucchini_tools.cc", |
| "zucchini_tools.h", |
| ] |
| |
| deps = [ |
| ":buildflags", |
| "//base", |
| ] |
| } |
| |
| static_library("zucchini_io") { |
| sources = [ |
| "mapped_file.cc", |
| "mapped_file.h", |
| "zucchini_integration.cc", |
| "zucchini_integration.h", |
| ] |
| |
| deps = [ |
| ":zucchini_lib", |
| "//base", |
| ] |
| } |
| |
| executable("zucchini") { |
| sources = [ |
| "main_utils.cc", |
| "main_utils.h", |
| "zucchini_commands.cc", |
| "zucchini_commands.h", |
| "zucchini_main.cc", |
| ] |
| |
| deps = [ |
| ":zucchini_io", |
| ":zucchini_lib", |
| "//base", |
| "//build/config:exe_and_shlib_deps", |
| ] |
| |
| if (is_win) { |
| deps += [ ":zucchini_exe_version" ] |
| } |
| } |
| |
| if (is_win) { |
| process_version_rc_template("zucchini_exe_version") { |
| template_file = "zucchini_exe_version.rc.version" |
| output = "$target_gen_dir/zucchini_exe_version.rc" |
| } |
| } |
| |
| test("zucchini_unittests") { |
| sources = [ |
| "abs32_utils_unittest.cc", |
| "address_translator_unittest.cc", |
| "algorithm_unittest.cc", |
| "binary_data_histogram_unittest.cc", |
| "buffer_sink_unittest.cc", |
| "buffer_source_unittest.cc", |
| "buffer_view_unittest.cc", |
| "crc32_unittest.cc", |
| "disassembler_dex_unittest.cc", |
| "disassembler_ztf_unittest.cc", |
| "element_detection_unittest.cc", |
| "encoded_view_unittest.cc", |
| "equivalence_map_unittest.cc", |
| "image_index_unittest.cc", |
| "image_utils_unittest.cc", |
| "imposed_ensemble_matcher_unittest.cc", |
| "io_utils_unittest.cc", |
| "mapped_file_unittest.cc", |
| "patch_read_write_unittest.cc", |
| "patch_utils_unittest.cc", |
| "reference_set_unittest.cc", |
| "rel32_finder_unittest.cc", |
| "rel32_utils_unittest.cc", |
| "reloc_utils_unittest.cc", |
| "suffix_array_unittest.cc", |
| "target_pool_unittest.cc", |
| "targets_affinity_unittest.cc", |
| "test_disassembler.cc", |
| "test_disassembler.h", |
| "test_reference_reader.cc", |
| "test_reference_reader.h", |
| "test_utils.cc", |
| "test_utils.h", |
| "typed_value_unittest.cc", |
| "zucchini_apply_unittest.cc", |
| "zucchini_gen_unittest.cc", |
| ] |
| |
| deps = [ |
| ":zucchini_io", |
| ":zucchini_lib", |
| "//base", |
| "//base/test:run_all_unittests", |
| "//base/test:test_support", |
| "//testing/gtest", |
| ] |
| } |
| |
| test("zucchini_integration_test") { |
| sources = [ |
| "integration_test.cc", |
| ] |
| |
| deps = [ |
| ":zucchini_lib", |
| "//base", |
| "//base/test:run_all_unittests", |
| "//base/test:test_support", |
| "//testing/gtest", |
| ] |
| } |
| |
| # Group to build and depend on all the Zucchini related fuzzers. |
| group("zucchini_fuzzers") { |
| testonly = true |
| deps = [ |
| "//components/zucchini/fuzzers:zucchini_disassembler_win32_fuzzer", |
| "//components/zucchini/fuzzers:zucchini_patch_fuzzer", |
| ] |
| |
| # Ensure protoc is available. |
| # Disabled on Windows due to crbug/844826. |
| if (current_toolchain == host_toolchain && !is_win) { |
| deps += [ |
| "//components/zucchini/fuzzers:zucchini_raw_apply_fuzzer", |
| "//components/zucchini/fuzzers:zucchini_raw_gen_fuzzer", |
| ] |
| } |
| } |