Chromium Code Reviews| Index: chrome/tools/build/win/syzygy/BUILD.gn |
| diff --git a/chrome/tools/build/win/syzygy/BUILD.gn b/chrome/tools/build/win/syzygy/BUILD.gn |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ae92f56ae7487f0aaff9cce72ef5a6493518c4c8 |
| --- /dev/null |
| +++ b/chrome/tools/build/win/syzygy/BUILD.gn |
| @@ -0,0 +1,220 @@ |
| +# Copyright 2015 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/config/chrome_build.gni") |
| +import("//build/config/sanitizers/sanitizers.gni") |
| + |
| +declare_args() { |
| + # Generate Syzygy optimized binaries. |
|
Dirk Pranke
2015/07/20 19:29:41
it would be nice if there was some documentation s
brettw
2015/07/20 22:21:55
I added one more sentence in each of these places
|
| + syzygy_optimize = |
| + is_win && is_official_build && !is_clang && symbol_level == 2 |
| +} |
| + |
| +assert(!syzygy_optimize || !is_syzyasan, |
| + "Don't do both syzygy_optimize and is_syzyasan") |
| + |
| +# Where the output binaries will be placed. |
| +syzygy_dest_dir = "$root_out_dir/syzygy" |
| + |
| +if (syzygy_optimize) { |
| + # Generates a Syzygy optimize target. |
| + # |
| + # dll_name (required) |
| + # Name of the DLL to be instrumented, with no extension or path. This |
| + # ${dll_name}.dll is assumed to be in the output directory and must be |
| + # generated by a dependency of this target. |
| + # |
| + # deps (required) |
| + # Normal meaning. |
| + template("syzygy_optimize") { |
| + action(target_name) { |
| + if (defined(invoker.visibility)) { |
| + visibility = invoker.visibility |
| + } |
| + script = "//chrome/tools/build/win/syzygy/reorder.py" |
| + |
| + dll_name = invoker.dll_name |
| + input_dll = "$root_out_dir/$dll_name.dll" |
| + input_pdb = "$root_out_dir/$dll_name.dll.pdb" |
| + |
| + inputs = [ |
| + input_dll, |
| + #input_pdb, |
| + ] |
| + |
| + outputs = [ |
| + "$syzygy_dest_dir/$dll_name.dll", |
| + "$syzygy_dest_dir/$dll_name.dll.pdb", |
| + ] |
| + |
| + args = [ |
| + "--input_executable", |
| + rebase_path(input_dll, root_build_dir), |
| + "--input_symbol", |
| + rebase_path(input_pdb, root_build_dir), |
| + "--destination_dir", |
| + rebase_path(syzygy_dest_dir, root_build_dir), |
| + ] |
| + |
| + if (defined(invoker.deps)) { |
| + deps = invoker.deps |
| + } |
| + } |
| + } |
| + |
| + syzygy_optimize("chrome_dll_syzygy") { |
| + dll_name = "chrome" |
| + deps = [ |
| + "//chrome:main_dll", |
| + ] |
| + } |
| + if (is_multi_dll_chrome) { |
| + # Also instrument chrome_child.dll. |
| + syzygy_optimize("chrome_child_dll_syzygy") { |
| + dll_name = "chrome_child" |
| + deps = [ |
| + "//chrome:chrome_child", |
| + ] |
| + } |
| + } |
| +} else if (is_syzyasan) { |
| + # Instruments a binary with SyzyAsan. |
| + # |
| + # dll_name (required) |
| + # Name of the DLL to be instrumented, with no extension or path. This |
| + # ${dll_name}.dll is assumed to be in the output directory and must be |
| + # generated by a dependency of this target. |
| + # |
| + # deps (required) |
| + # Normal meaning. |
| + template("syzygy_asan") { |
| + action(target_name) { |
| + if (defined(invoker.visibility)) { |
| + visibility = invoker.visibility |
| + } |
| + script = "//chrome/tools/build/win/syzygy/instrument.py" |
| + |
| + filter = "syzyasan-instrumentation-filter.txt" |
| + input_dll = "$root_out_dir/$dll_name.dll" |
| + input_pdb = "$root_out_dir/$dll_name.dll.pdb" |
| + |
| + inputs = [ |
| + filter, |
| + input_dll, |
| + |
| + #input_pdb, |
| + ] |
| + |
| + output_filter = "$syzygy_dest_dir/win-syzyasan-filter-$dll_name.txt.json" |
| + |
| + outputs = [ |
| + "$syzygy_dest_dir/$dll_name.dll", |
| + "$syzygy_dest_dir/$dll_name.dll.pdb", |
| + output_filter, |
| + ] |
| + |
| + args = [ |
| + "--mode", |
| + "asan", |
| + "--input_executable", |
| + rebase_path(input_dll, root_build_dir), |
| + "--input_symbol", |
| + rebase_path(input_pdb, root_build_dir), |
| + "--filter", |
| + rebase_path(filter, root_build_dir), |
| + "--output-filter-file", |
| + rebase_path(output_filter, root_build_dir), |
| + "--destination_dir", |
| + rebase_path(syzygy_dest_dir, root_build_dir), |
| + ] |
| + |
| + deps = [ |
| + "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries", |
| + ] |
| + if (defined(invoker.deps)) { |
| + deps += invoker.deps |
| + } |
| + if (defined(invoker.public_deps)) { |
| + public_deps = invoker.public_deps |
| + } |
| + } |
| + } |
| + |
| + syzygy_asan("chrome_dll_syzygy") { |
| + dll_name = "chrome" |
| + deps = [ |
| + "//chrome:main_dll", |
| + ] |
| + } |
| + |
| + if (is_multi_dll_chrome) { |
| + # Also instrument chrome_child.dll. |
| + # |
| + # For official builds, the instrumented version will be put into an |
| + # "instrumented" subdirectory and the regular output will be |
| + # uninstrumented. Otherwise, chrome_child is also instrumented to the |
| + # normal place. |
| + syzygy_asan("chrome_child_dll_syzygy") { |
| + dll_name = "chrome_child" |
| + deps = [ |
| + "//chrome:chrome_child", |
| + ] |
| + |
| + if (is_official_build) { |
| + dest_dir = "$syzygy_dest_dir/instrumented" |
| + deps += [ ":chrome_child_dll_syzygy_copy" ] |
| + } else { |
| + dest_dir = syzygy_dest_dir |
| + } |
| + } |
| + |
| + if (is_official_build) { |
| + # Copies the uninstrumented chrome_child.dll. |
| + # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy |
| + copy("chrome_child_dll_syzygy_copy") { |
| + sources = [ |
| + "$root_out_dir/chrome_child.dll", |
| + "$root_out_dir/chrome_child.dll.pdb", |
| + ] |
| + outputs = [ |
| + "$syzygy_dest_dir/{{source_file_part}}", |
| + ] |
| + deps = [ |
| + "//chrome:chrome_child", |
| + ] |
| + } |
| + } |
| + } |
| +} else { |
| + # No syzygy. Generate dummy targets so other targets can unconditionally |
| + # depend on these without having to duplicate our conditions. |
| + group("chrome_dll_syzygy") { |
| + } |
| + if (is_multi_dll_chrome) { |
| + group("chrome_child_dll_syzygy") { |
| + } |
| + } |
| +} |
| + |
| +if (is_syzyasan || syzygy_optimize) { |
| + copy("copy_syzyasan_binaries") { |
| + visibility = [ "//chrome/*" ] |
| + |
| + source_dir = "//third_party/syzygy/binaries/exe" |
| + |
| + sources = [ |
| + "$source_dir/agent_logger.exe", |
| + "$source_dir/minidump_symbolizer.py", |
| + "$source_dir/syzyasan_rtl.dll", |
| + "$source_dir/syzyasan_rtl.dll.pdb", |
| + ] |
| + |
| + outputs = [ |
| + "$syzygy_dest_dir/{{source_file_part}}", |
| + ] |
| + } |
| +} |
| + |
| +# Prevent unused variable warning for code paths where this is unused. |
| +assert(syzygy_dest_dir != "") |