From 9c89cd99f3357f194f0b2bf873e46bf8b59e1c77 Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Wed, 21 Mar 2018 19:18:07 -0700 Subject: [PATCH] gn: add templates for executables and loadable_modules When building in chromium, executables and loadable_modules should depend on: //build/config:exe_and_shlib_deps which, among other things, may be needed to introduce a dependency on a custom libc++. Bug: crashpad:30 Change-Id: Ic46a3cf5b46bdac09cca22950f9236e0776ba44a Reviewed-on: https://chromium-review.googlesource.com/974713 Reviewed-by: Mark Mentovai --- build/crashpad_buildconfig.gni | 42 ++++++++++++++++++++++++++++++++++ handler/BUILD.gn | 30 ++++++++++++------------ snapshot/BUILD.gn | 24 +++++++++---------- test/BUILD.gn | 2 +- tools/BUILD.gn | 14 ++++++------ util/BUILD.gn | 4 ++-- 6 files changed, 79 insertions(+), 37 deletions(-) diff --git a/build/crashpad_buildconfig.gni b/build/crashpad_buildconfig.gni index e9ac5713..c10ad30e 100644 --- a/build/crashpad_buildconfig.gni +++ b/build/crashpad_buildconfig.gni @@ -60,3 +60,45 @@ if (crashpad_is_in_chromium) { crashpad_is_clang = mini_chromium_is_clang } + +template("crashpad_executable") { + executable(target_name) { + forward_variables_from(invoker, "*", [ "configs", "remove_configs" ]) + if (defined(invoker.remove_configs)) { + configs -= invoker.remove_configs + } + + if (defined(invoker.configs)) { + configs += invoker.configs + } + + if (!defined(deps)) { + deps = [] + } + + if (crashpad_is_in_chromium) { + deps += [ "//build/config:exe_and_shlib_deps" ] + } + } +} + +template("crashpad_loadable_module") { + loadable_module(target_name) { + forward_variables_from(invoker, "*", [ "configs", "remove_configs" ]) + if (defined(invoker.remove_configs)) { + configs -= invoker.remove_configs + } + + if (defined(invoker.configs)) { + configs += invoker.configs + } + + if (!defined(deps)) { + deps = [] + } + + if (crashpad_is_in_chromium) { + deps += [ "//build/config:exe_and_shlib_deps" ] + } + } +} diff --git a/handler/BUILD.gn b/handler/BUILD.gn index b3370fca..ccbb0b55 100644 --- a/handler/BUILD.gn +++ b/handler/BUILD.gn @@ -115,7 +115,7 @@ source_set("handler_test") { } } -executable("crashpad_handler") { +crashpad_executable("crashpad_handler") { sources = [ "main.cc", ] @@ -147,18 +147,18 @@ executable("crashpad_handler") { if (crashpad_is_win) { if (crashpad_is_in_chromium) { - configs -= [ "//build/config/win:console" ] - configs += [ "//build/config/win:windowed" ] + remove_configs = [ "//build/config/win:console" ] + configs = [ "//build/config/win:windowed" ] } else { - configs -= + remove_configs = [ "//third_party/mini_chromium/mini_chromium/build:win_console" ] - configs += + configs = [ "//third_party/mini_chromium/mini_chromium/build:win_windowed" ] } } } -executable("crashpad_handler_test_extended_handler") { +crashpad_executable("crashpad_handler_test_extended_handler") { testonly = true sources = [ @@ -176,7 +176,7 @@ executable("crashpad_handler_test_extended_handler") { } if (crashpad_is_win) { - executable("crashpad_handler_com") { + crashpad_executable("crashpad_handler_com") { sources = [ "main.cc", ] @@ -206,7 +206,7 @@ if (crashpad_is_win) { ] } - executable("crash_other_program") { + crashpad_executable("crash_other_program") { testonly = true sources = [ @@ -221,7 +221,7 @@ if (crashpad_is_win) { ] } - executable("crashy_program") { + crashpad_executable("crashy_program") { testonly = true sources = [ @@ -234,7 +234,7 @@ if (crashpad_is_win) { ] } - executable("crashy_signal") { + crashpad_executable("crashy_signal") { testonly = true sources = [ @@ -249,7 +249,7 @@ if (crashpad_is_win) { ] } - executable("fake_handler_that_crashes_at_startup") { + crashpad_executable("fake_handler_that_crashes_at_startup") { testonly = true sources = [ @@ -257,7 +257,7 @@ if (crashpad_is_win) { ] } - executable("hanging_program") { + crashpad_executable("hanging_program") { testonly = true sources = [ @@ -270,7 +270,7 @@ if (crashpad_is_win) { ] } - loadable_module("loader_lock_dll") { + crashpad_loadable_module("loader_lock_dll") { testonly = true sources = [ @@ -278,7 +278,7 @@ if (crashpad_is_win) { ] } - executable("self_destroying_program") { + crashpad_executable("self_destroying_program") { testonly = true sources = [ @@ -295,7 +295,7 @@ if (crashpad_is_win) { if (current_cpu == "x86") { # Cannot create an x64 DLL with embedded debug info. - executable("crashy_z7_loader") { + crashpad_executable("crashy_z7_loader") { testonly = true sources = [ diff --git a/snapshot/BUILD.gn b/snapshot/BUILD.gn index 5ccc735e..e12cc6d6 100644 --- a/snapshot/BUILD.gn +++ b/snapshot/BUILD.gn @@ -401,7 +401,7 @@ source_set("snapshot_test") { } } -loadable_module("crashpad_snapshot_test_module") { +crashpad_loadable_module("crashpad_snapshot_test_module") { testonly = true sources = [ "crashpad_info_client_options_test_module.cc", @@ -412,7 +412,7 @@ loadable_module("crashpad_snapshot_test_module") { ] } -loadable_module("crashpad_snapshot_test_module_large") { +crashpad_loadable_module("crashpad_snapshot_test_module_large") { testonly = true sources = [ "crashpad_info_size_test_module.cc", @@ -428,7 +428,7 @@ loadable_module("crashpad_snapshot_test_module_large") { deps += [ "../third_party/mini_chromium:base" ] } -loadable_module("crashpad_snapshot_test_module_small") { +crashpad_loadable_module("crashpad_snapshot_test_module_small") { testonly = true sources = [ "crashpad_info_size_test_module.cc", @@ -445,7 +445,7 @@ loadable_module("crashpad_snapshot_test_module_small") { } if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) { - loadable_module("crashpad_snapshot_test_both_dt_hash_styles") { + crashpad_loadable_module("crashpad_snapshot_test_both_dt_hash_styles") { testonly = true sources = [ "hash_types_test.cc", @@ -457,14 +457,14 @@ if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) { } if (crashpad_is_mac) { - loadable_module("crashpad_snapshot_test_module_crashy_initializer") { + crashpad_loadable_module("crashpad_snapshot_test_module_crashy_initializer") { testonly = true sources = [ "mac/mach_o_image_annotations_reader_test_module_crashy_initializer.cc", ] } - executable("crashpad_snapshot_test_no_op") { + crashpad_executable("crashpad_snapshot_test_no_op") { testonly = true sources = [ "mac/mach_o_image_annotations_reader_test_no_op.cc", @@ -473,7 +473,7 @@ if (crashpad_is_mac) { } if (crashpad_is_win) { - executable("crashpad_snapshot_test_annotations") { + crashpad_executable("crashpad_snapshot_test_annotations") { testonly = true sources = [ "win/crashpad_snapshot_test_annotations.cc", @@ -485,7 +485,7 @@ if (crashpad_is_win) { ] } - executable("crashpad_snapshot_test_crashing_child") { + crashpad_executable("crashpad_snapshot_test_crashing_child") { testonly = true sources = [ "win/crashpad_snapshot_test_crashing_child.cc", @@ -498,7 +498,7 @@ if (crashpad_is_win) { ] } - executable("crashpad_snapshot_test_dump_without_crashing") { + crashpad_executable("crashpad_snapshot_test_dump_without_crashing") { testonly = true sources = [ "win/crashpad_snapshot_test_dump_without_crashing.cc", @@ -511,7 +511,7 @@ if (crashpad_is_win) { ] } - executable("crashpad_snapshot_test_extra_memory_ranges") { + crashpad_executable("crashpad_snapshot_test_extra_memory_ranges") { testonly = true sources = [ "win/crashpad_snapshot_test_extra_memory_ranges.cc", @@ -523,7 +523,7 @@ if (crashpad_is_win) { ] } - executable("crashpad_snapshot_test_image_reader") { + crashpad_executable("crashpad_snapshot_test_image_reader") { testonly = true sources = [ "win/crashpad_snapshot_test_image_reader.cc", @@ -544,7 +544,7 @@ if (crashpad_is_win) { } } - loadable_module("crashpad_snapshot_test_image_reader_module") { + crashpad_loadable_module("crashpad_snapshot_test_image_reader_module") { testonly = true sources = [ "win/crashpad_snapshot_test_image_reader_module.cc", diff --git a/test/BUILD.gn b/test/BUILD.gn index 0808096e..2c894603 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -171,7 +171,7 @@ source_set("test_test") { ] } -executable("crashpad_test_test_multiprocess_exec_test_child") { +crashpad_executable("crashpad_test_test_multiprocess_exec_test_child") { sources = [ "multiprocess_exec_test_child.cc", ] diff --git a/tools/BUILD.gn b/tools/BUILD.gn index 54188198..a711bdf7 100644 --- a/tools/BUILD.gn +++ b/tools/BUILD.gn @@ -27,7 +27,7 @@ source_set("tool_support") { ] } -executable("crashpad_database_util") { +crashpad_executable("crashpad_database_util") { sources = [ "crashpad_database_util.cc", ] @@ -42,7 +42,7 @@ executable("crashpad_database_util") { ] } -executable("crashpad_http_upload") { +crashpad_executable("crashpad_http_upload") { sources = [ "crashpad_http_upload.cc", ] @@ -56,7 +56,7 @@ executable("crashpad_http_upload") { ] } -executable("generate_dump") { +crashpad_executable("generate_dump") { sources = [ "generate_dump.cc", ] @@ -92,7 +92,7 @@ executable("generate_dump") { } if (crashpad_is_mac) { - executable("catch_exception_tool") { + crashpad_executable("catch_exception_tool") { sources = [ "mac/catch_exception_tool.cc", ] @@ -105,7 +105,7 @@ if (crashpad_is_mac) { ] } - executable("exception_port_tool") { + crashpad_executable("exception_port_tool") { sources = [ "mac/exception_port_tool.cc", ] @@ -130,7 +130,7 @@ if (crashpad_is_mac) { ] } - executable("on_demand_service_tool") { + crashpad_executable("on_demand_service_tool") { sources = [ "mac/on_demand_service_tool.mm", ] @@ -148,7 +148,7 @@ if (crashpad_is_mac) { ] } - executable("run_with_crashpad") { + crashpad_executable("run_with_crashpad") { sources = [ "mac/run_with_crashpad.cc", ] diff --git a/util/BUILD.gn b/util/BUILD.gn index 4c90785f..ea071afd 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -617,14 +617,14 @@ source_set("util_test") { } if (crashpad_is_win) { - executable("crashpad_util_test_process_info_test_child") { + crashpad_executable("crashpad_util_test_process_info_test_child") { testonly = true sources = [ "win/process_info_test_child.cc", ] } - executable("crashpad_util_test_safe_terminate_process_test_child") { + crashpad_executable("crashpad_util_test_safe_terminate_process_test_child") { testonly = true sources = [ "win/safe_terminate_process_test_child.cc",