From 502a83e013988cb8202844650e0e423ec2d8ee78 Mon Sep 17 00:00:00 2001 From: pmonette Date: Thu, 7 Jan 2016 16:21:16 -0800 Subject: Switched Kasko to use the new buildflag system. Moved gyp build to third_party/kasko Also fixed some build issues that came with rebasing to tip of tree. Review URL: https://codereview.chromium.org/1526213002 Cr-Commit-Position: refs/heads/master@{#368212} --- .gn | 1 + build/common.gypi | 12 ++--- chrome/BUILD.gn | 1 + chrome/app/DEPS | 1 + chrome/app/kasko_client.cc | 5 +- chrome/app/kasko_client.h | 6 ++- chrome/app/main_dll_loader_win.cc | 19 ++++--- chrome/browser/BUILD.gn | 2 + chrome/browser/DEPS | 1 + chrome/browser/chrome_browser_main_win.cc | 10 ++-- chrome/browser/chrome_browser_main_win.h | 3 +- chrome/chrome.gyp | 36 ------------- chrome/chrome_browser.gypi | 10 +--- chrome/chrome_common.gypi | 1 + chrome/chrome_dll.gypi | 1 + chrome/chrome_exe.gypi | 10 +--- chrome/chrome_tests_unit.gypi | 1 + chrome/chrome_watcher/DEPS | 1 + chrome/chrome_watcher/chrome_watcher.gypi | 8 +-- chrome/chrome_watcher/chrome_watcher_main.cc | 19 +++---- chrome/common/BUILD.gn | 1 + chrome/common/DEPS | 1 + chrome/common/crash_keys.cc | 4 +- chrome/common/crash_keys.h | 3 +- chrome/test/BUILD.gn | 1 + components/crash.gypi | 1 + components/crash/content/app/BUILD.gn | 1 + components/crash/content/app/DEPS | 1 + components/crash/content/app/crashpad.cc | 4 +- components/crash/content/app/crashpad.h | 9 ++-- components/nacl/broker/BUILD.gn | 1 + content/browser/frame_host/DEPS | 2 + content/browser/frame_host/debug_urls.cc | 7 +-- content/content_browser.gypi | 1 + third_party/kasko/BUILD.gn | 31 +++++++---- third_party/kasko/kasko.gyp | 79 ++++++++++++++++++++++++++++ 36 files changed, 178 insertions(+), 117 deletions(-) create mode 100644 third_party/kasko/kasko.gyp diff --git a/.gn b/.gn index 7940a2e..0c36ec4 100644 --- a/.gn +++ b/.gn @@ -80,6 +80,7 @@ check_targets = [ "//testing/*", #"//third_party/*", # May not ever want this. + "//third_party/kasko/*", "//third_party/WebKit/Source/*", "//tools/*", diff --git a/build/common.gypi b/build/common.gypi index 9bf1997..dbb7669 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -482,6 +482,9 @@ # Enable crash reporting via Kasko. 'kasko%': 0, + # Enable hang reports in Kasko. + 'kasko_hang_reports%': 0, + # Enable building with LSan (Clang's -fsanitize=leak option). # -fsanitize=leak only works with clang, but lsan=1 implies clang=1 # See https://sites.google.com/a/chromium.org/dev/developers/testing/leaksanitizer @@ -1192,6 +1195,7 @@ 'use_sanitizer_options%': '<(use_sanitizer_options)', 'syzyasan%': '<(syzyasan)', 'kasko%': '<(kasko)', + 'kasko_hang_reports%': '<(kasko_hang_reports)', 'syzygy_optimize%': '<(syzygy_optimize)', 'lsan%': '<(lsan)', 'msan%': '<(msan)', @@ -2891,14 +2895,6 @@ 'MEMORY_SANITIZER_INITIAL_SIZE', ], }], - ['kasko==1', { - 'defines': [ - 'KASKO', - ], - 'include_dirs': [ - '<(DEPTH)/third_party/kasko/include', - ], - }], ['OS=="win"', { 'defines': [ '__STD_C', diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 11eb786..cc14b81 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -316,6 +316,7 @@ if (is_mac || is_win) { "//base/trace_event/etw_manifest:chrome_events_win", "//chrome/app/theme:chrome_unscaled_resources", "//chrome_elf", + "//components/crash/content/app", "//content/app/resources", "//crypto", "//net:net_resources", diff --git a/chrome/app/DEPS b/chrome/app/DEPS index f7be0ec..5d647ee 100644 --- a/chrome/app/DEPS +++ b/chrome/app/DEPS @@ -32,4 +32,5 @@ include_rules = [ "+sandbox", "+syzygy/kasko/api", "+third_party/crashpad/crashpad", + "+third_party/kasko", ] diff --git a/chrome/app/kasko_client.cc b/chrome/app/kasko_client.cc index afc5c07..ab44bac 100644 --- a/chrome/app/kasko_client.cc +++ b/chrome/app/kasko_client.cc @@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#if defined(KASKO) #include "chrome/app/kasko_client.h" +#if BUILDFLAG(ENABLE_KASKO) + #include #include @@ -115,4 +116,4 @@ extern "C" void __declspec(dllexport) ReportCrashWithProtobuf( nullptr, nullptr); } -#endif // defined(KASKO) +#endif // BUILDFLAG(ENABLE_KASKO) diff --git a/chrome/app/kasko_client.h b/chrome/app/kasko_client.h index 9f3da7d..aeb816f 100644 --- a/chrome/app/kasko_client.h +++ b/chrome/app/kasko_client.h @@ -5,7 +5,9 @@ #ifndef CHROME_APP_KASKO_CLIENT_H_ #define CHROME_APP_KASKO_CLIENT_H_ -#if defined(KASKO) +#include "third_party/kasko/kasko_features.h" + +#if BUILDFLAG(ENABLE_KASKO) #include "base/macros.h" #include "syzygy/kasko/api/minidump_type.h" @@ -28,6 +30,6 @@ class KaskoClient { DISALLOW_COPY_AND_ASSIGN(KaskoClient); }; -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) #endif // CHROME_APP_KASKO_CLIENT_H_ diff --git a/chrome/app/main_dll_loader_win.cc b/chrome/app/main_dll_loader_win.cc index 3ab9f69..8ef34fe 100644 --- a/chrome/app/main_dll_loader_win.cc +++ b/chrome/app/main_dll_loader_win.cc @@ -122,7 +122,10 @@ void ClearDidRun(const base::FilePath& dll_path) { typedef int (*InitMetro)(); -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) + +// For ::GetProfileType(). +#pragma comment(lib, "userenv.lib") // For ::GetProfileType(). #pragma comment(lib, "userenv.lib") @@ -156,7 +159,7 @@ std::wstring GetProfileType() { return profile_type; } -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) } // namespace @@ -317,9 +320,9 @@ class ChromeDllLoader : public MainDllLoader { private: scoped_ptr chrome_watcher_client_; -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) scoped_ptr kasko_client_; -#endif // KASKO +#endif }; void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type, @@ -340,7 +343,7 @@ void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type, chrome_watcher_client_.reset(new ChromeWatcherClient( base::Bind(&GenerateChromeWatcherCommandLine, exe_path))); if (chrome_watcher_client_->LaunchWatcher()) { -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) kasko::api::MinidumpType minidump_type = kasko::api::SMALL_DUMP_TYPE; if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kFullMemoryCrashReport)) { @@ -359,7 +362,7 @@ void ChromeDllLoader::OnBeforeLaunch(const std::string& process_type, kasko_client_.reset( new KaskoClient(chrome_watcher_client_.get(), minidump_type)); -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) } } } @@ -382,9 +385,9 @@ int ChromeDllLoader::OnBeforeExit(int return_code, ClearDidRun(dll_path); } -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) kasko_client_.reset(); -#endif // KASKO +#endif chrome_watcher_client_.reset(); return return_code; diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index dad6c5b..427c725 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -369,6 +369,7 @@ source_set("browser") { "//storage/common", "//third_party/WebKit/public:image_resources", "//third_party/WebKit/public:resources", + "//third_party/kasko", "//third_party/leveldatabase", "//third_party/libaddressinput", "//third_party/libyuv", @@ -843,6 +844,7 @@ source_set("browser") { ] deps += [ ":chrome_process_finder", + "//chrome/chrome_watcher:client", "//chrome/common:version_header", "//chrome/installer/util:strings", "//chrome_elf", diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 1f815d0..dfcf809 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -171,6 +171,7 @@ include_rules = [ "+sync/util", # Sync utilities like GetSessionName. "+syzygy/kasko", "+third_party/cros_system_api", + "+third_party/kasko", "+win8/util", # chrome only needs switches from cc. All usage of the compositor is from diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 0a1238b..30a71e4 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -74,7 +74,7 @@ #include "chrome/browser/google/did_run_updater_win.h" #endif -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) #include "syzygy/kasko/api/reporter.h" #endif @@ -122,7 +122,7 @@ void ExecuteFontCacheBuildTask(const base::FilePath& path) { new ChromeUtilityHostMsg_BuildDirectWriteFontCache(path)); } -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) void ObserveFailedCrashReportDirectory(const base::FilePath& path, bool error) { DCHECK(!error); if (error) @@ -155,7 +155,7 @@ void StartFailedKaskoCrashReportWatcher(base::FilePathWatcher* watcher) { ObserveFailedCrashReportDirectory(permanent_failure_directory, false); } } -#endif +#endif // BUILDFLAG(ENABLE_KASKO) void DetectFaultTolerantHeap() { enum FTHFlags { @@ -385,13 +385,13 @@ void ChromeBrowserMainPartsWin::PostBrowserStart() { InitializeChromeElf(); -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) content::BrowserThread::PostDelayedTask( content::BrowserThread::FILE, FROM_HERE, base::Bind(&StartFailedKaskoCrashReportWatcher, base::Unretained(&failed_kasko_crash_report_watcher_)), base::TimeDelta::FromMinutes(5)); -#endif +#endif // BUILDFLAG(ENABLE_KASKO) #if defined(GOOGLE_CHROME_BUILD) did_run_updater_.reset(new DidRunUpdater); diff --git a/chrome/browser/chrome_browser_main_win.h b/chrome/browser/chrome_browser_main_win.h index 254b487..c948edb 100644 --- a/chrome/browser/chrome_browser_main_win.h +++ b/chrome/browser/chrome_browser_main_win.h @@ -10,6 +10,7 @@ #include "base/files/file_path_watcher.h" #include "base/macros.h" #include "chrome/browser/chrome_browser_main.h" +#include "third_party/kasko/kasko_features.h" class DidRunUpdater; @@ -72,7 +73,7 @@ class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts { #if defined(GOOGLE_CHROME_BUILD) scoped_ptr did_run_updater_; #endif -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) // Cleans up Kasko crash reports that exceeded the maximum upload attempts. base::FilePathWatcher failed_kasko_crash_report_watcher_; #endif diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 6694fb5..6beaddd 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -773,41 +773,5 @@ }, ], }], - ['kasko==1', { - 'variables': { - 'kasko_exe_dir': '<(DEPTH)/third_party/kasko/binaries', - }, - 'targets': [ - { - 'target_name': 'kasko_dll', - 'type': 'none', - 'outputs': [ - '<(PRODUCT_DIR)/kasko.dll', - '<(PRODUCT_DIR)/kasko.dll.pdb', - ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)', - 'files': [ - '<(kasko_exe_dir)/kasko.dll', - '<(kasko_exe_dir)/kasko.dll.pdb', - ], - }, - ], - 'direct_dependent_settings': { - 'msvs_settings': { - 'VCLinkerTool': { - 'AdditionalDependencies': [ - 'kasko.dll.lib', - ], - 'AdditionalLibraryDirectories': [ - '<(DEPTH)/third_party/kasko/binaries' - ], - }, - }, - }, - }, - ], - }], ], # 'conditions' } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index c402751..6063186 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3816,24 +3816,18 @@ '../google_update/google_update.gyp:google_update', '../third_party/iaccessible2/iaccessible2.gyp:iaccessible2', '../third_party/isimpledom/isimpledom.gyp:isimpledom', + '../third_party/kasko/kasko.gyp:kasko', '../ui/metro_viewer/metro_viewer.gyp:metro_viewer_messages', '../ui/views/controls/webview/webview.gyp:webview', '../ui/views/views.gyp:views', '../win8/win8.gyp:metro_viewer', ], 'export_dependent_settings': [ + '../third_party/kasko/kasko.gyp:kasko', '../ui/views/controls/webview/webview.gyp:webview', '../ui/views/views.gyp:views', ], 'conditions': [ - ['kasko==1', { - 'dependencies': [ - 'kasko_dll', - ], - 'export_dependent_settings': [ - 'kasko_dll', - ], - }], ['branding!="Chrome"', { 'dependencies!': [ '../google_update/google_update.gyp:google_update', diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi index cbf6331..bac564e 100644 --- a/chrome/chrome_common.gypi +++ b/chrome/chrome_common.gypi @@ -352,6 +352,7 @@ '<(DEPTH)/skia/skia.gyp:skia_library', '<(DEPTH)/third_party/icu/icu.gyp:icui18n', '<(DEPTH)/third_party/icu/icu.gyp:icuuc', + '<(DEPTH)/third_party/kasko/kasko.gyp:kasko_features', '<(DEPTH)/third_party/zlib/google/zip.gyp:zip', '<(DEPTH)/ui/gfx/ipc/gfx_ipc.gyp:gfx_ipc', '<(DEPTH)/ui/resources/ui_resources.gyp:ui_resources', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index b6e7634..a0aa2c1 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -351,6 +351,7 @@ '<@(chromium_child_dependencies)', '../components/components.gyp:browser_watcher_client', '../content/content.gyp:content_app_child', + '../third_party/kasko/kasko.gyp:kasko', 'chrome_version_resources', 'policy_path_parser', ], diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index 4cec0e7..fda73bc 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -105,20 +105,13 @@ '../components/components.gyp:browser_watcher_client', '../components/components.gyp:crash_component', '../third_party/crashpad/crashpad/handler/handler.gyp:crashpad_handler_lib', + '../third_party/kasko/kasko.gyp:kasko', ], 'sources': [ 'app/chrome_crash_reporter_client.cc', 'app/chrome_crash_reporter_client.h', ], 'conditions': [ - ['kasko==1', { - 'dependencies': [ - 'kasko_dll', - ], - 'sources': [ - 'app/chrome_crash_reporter_client.cc', - ], - }], ['win_console_app==1', { 'defines': ['WIN_CONSOLE_APP'], }], @@ -433,6 +426,7 @@ '../components/components.gyp:crash_core_common', '../components/components.gyp:flags_ui_switches', '../sandbox/sandbox.gyp:sandbox', + '../third_party/kasko/kasko.gyp:kasko_features', '../ui/gfx/gfx.gyp:gfx', '../win8/metro_driver/metro_driver.gyp:metro_driver', '../win8/delegate_execute/delegate_execute.gyp:*', diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi index 19f47ce..65c11d4 100644 --- a/chrome/chrome_tests_unit.gypi +++ b/chrome/chrome_tests_unit.gypi @@ -2889,6 +2889,7 @@ '../components/components.gyp:crash_core_common', '../components/components.gyp:flags_ui_switches', '../content/content.gyp:content_app_both', + '../third_party/kasko/kasko.gyp:kasko_features', # 2) test-specific support libraries: '../base/base.gyp:run_all_unittests', '../testing/gmock.gyp:gmock', diff --git a/chrome/chrome_watcher/DEPS b/chrome/chrome_watcher/DEPS index d7f5402..7bc4be6 100644 --- a/chrome/chrome_watcher/DEPS +++ b/chrome/chrome_watcher/DEPS @@ -3,4 +3,5 @@ include_rules = [ "+chrome/installer/util", "+components/browser_watcher", "+syzygy/kasko/api", + "+third_party/kasko", ] diff --git a/chrome/chrome_watcher/chrome_watcher.gypi b/chrome/chrome_watcher/chrome_watcher.gypi index 9836501..f676a26 100644 --- a/chrome/chrome_watcher/chrome_watcher.gypi +++ b/chrome/chrome_watcher/chrome_watcher.gypi @@ -64,13 +64,7 @@ 'installer_util', '../base/base.gyp:base', '../components/components.gyp:browser_watcher', - ], - 'conditions': [ - ['kasko==1', { - 'dependencies': [ - 'kasko_dll', - ], - }], + '../third_party/kasko/kasko.gyp:kasko', ], 'msvs_settings': { 'VCLinkerTool': { diff --git a/chrome/chrome_watcher/chrome_watcher_main.cc b/chrome/chrome_watcher/chrome_watcher_main.cc index 01e916b..e28de01 100644 --- a/chrome/chrome_watcher/chrome_watcher_main.cc +++ b/chrome/chrome_watcher/chrome_watcher_main.cc @@ -37,8 +37,9 @@ #include "components/browser_watcher/endsession_watcher_window_win.h" #include "components/browser_watcher/exit_code_watcher_win.h" #include "components/browser_watcher/window_hang_monitor_win.h" +#include "third_party/kasko/kasko_features.h" -#ifdef KASKO +#if BUILDFLAG(ENABLE_KASKO) #include "syzygy/kasko/api/reporter.h" #endif @@ -194,7 +195,7 @@ void OnWindowEvent( } } -#ifdef KASKO +#if BUILDFLAG(ENABLE_KASKO) // Helper function for determining the crash server to use. Defaults to the // standard crash server, but can be overridden via an environment variable. // Enables easy integration testing. @@ -342,7 +343,7 @@ void OnCrashReportUpload(void* context, // TODO(erikwright): Copy minidump to some "last dump" location? } -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) } // namespace @@ -371,7 +372,7 @@ extern "C" int WatcherMain(const base::char16* registry_path, base::Callback on_hung_callback; -#ifdef KASKO +#if BUILDFLAG(ENABLE_KASKO) base::string16 crash_server; GetKaskoCrashServerUrl(&crash_server); @@ -389,14 +390,14 @@ extern "C" int WatcherMain(const base::char16* registry_path, .value() .c_str(), &OnCrashReportUpload, nullptr); -#ifdef KASKO_HANG_REPORTS +#if BUILDFLAG(ENABLE_KASKO_HANG_REPORTS) if (launched_kasko && base::StringPiece16(channel_name) == installer::kChromeChannelCanary) { on_hung_callback = base::Bind(&DumpHungBrowserProcess, main_thread_id, channel_name); } -#endif // KASKO_HANG_REPORTS -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO_HANG_REPORTS) +#endif // BUILDFLAG(ENABLE_KASKO) // Run a UI message loop on the main thread. base::MessageLoop msg_loop(base::MessageLoop::TYPE_UI); @@ -420,10 +421,10 @@ extern "C" int WatcherMain(const base::char16* registry_path, run_loop.Run(); } -#ifdef KASKO +#if BUILDFLAG(ENABLE_KASKO) if (launched_kasko) kasko::api::ShutdownReporter(); -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) // Wind logging down. logging::LogEventProvider::Uninitialize(); diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn index df5e371..61c533f 100644 --- a/chrome/common/BUILD.gn +++ b/chrome/common/BUILD.gn @@ -102,6 +102,7 @@ static_library("common") { "//net", "//skia", "//third_party/icu", + "//third_party/kasko:kasko_features", "//third_party/zlib:zip", "//ui/accessibility", "//ui/base", diff --git a/chrome/common/DEPS b/chrome/common/DEPS index d45be94..84bf958 100644 --- a/chrome/common/DEPS +++ b/chrome/common/DEPS @@ -32,6 +32,7 @@ include_rules = [ "+ppapi/c", "+ppapi/shared_impl", "+ppapi/thunk", + "+third_party/kasko", # FIXME - refactor code and remove these dependencies "+chrome/installer", diff --git a/chrome/common/crash_keys.cc b/chrome/common/crash_keys.cc index bdef33f..2254305 100644 --- a/chrome/common/crash_keys.cc +++ b/chrome/common/crash_keys.cc @@ -76,7 +76,7 @@ const char kSendAction[] = "sendaction"; } // namespace mac #endif -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) const char kKaskoGuid[] = "kasko-guid"; const char kKaskoEquivalentGuid[] = "kasko-equivalent-guid"; #endif @@ -141,7 +141,7 @@ size_t RegisterChromeCrashKeys() { // media/: { "VideoCaptureDeviceQTKit", kSmallSize }, #endif -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) { kKaskoGuid, kSmallSize }, { kKaskoEquivalentGuid, kSmallSize }, #endif diff --git a/chrome/common/crash_keys.h b/chrome/common/crash_keys.h index 01219e4..335b8d3 100644 --- a/chrome/common/crash_keys.h +++ b/chrome/common/crash_keys.h @@ -15,6 +15,7 @@ #include "base/macros.h" #include "build/build_config.h" #include "components/crash/core/common/crash_keys.h" +#include "third_party/kasko/kasko_features.h" namespace base { class CommandLine; @@ -118,7 +119,7 @@ extern const char kSendAction[]; } // namespace mac #endif -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) // Used to correlate a report sent via Kasko with one sent via Breakpad. extern const char kKaskoGuid[]; extern const char kKaskoEquivalentGuid[]; diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index e8d2a0f..58b218b 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -2154,6 +2154,7 @@ if (is_win || (is_linux && !is_chromeos)) { "//chrome/child", "//components/crash/core/common", "//components/flags_ui:switches", + "//third_party/kasko:kasko_features", ] if (cld_version == 2) { # Use whatever CLD2 data access mode that the diff --git a/components/crash.gypi b/components/crash.gypi index 3571a82..fcd252e 100644 --- a/components/crash.gypi +++ b/components/crash.gypi @@ -213,6 +213,7 @@ 'crash_component_non_mac_win', 'crash_component_lib', '../base/base.gyp:base', + '../third_party/kasko/kasko.gyp:kasko', ], 'defines': ['CRASH_IMPLEMENTATION'], 'conditions': [ diff --git a/components/crash/content/app/BUILD.gn b/components/crash/content/app/BUILD.gn index 474b2f2..52140ce 100644 --- a/components/crash/content/app/BUILD.gn +++ b/components/crash/content/app/BUILD.gn @@ -41,6 +41,7 @@ source_set("app") { public_deps = [ ":app_non_mac_win", + "//third_party/kasko", ] deps = [ "//base", diff --git a/components/crash/content/app/DEPS b/components/crash/content/app/DEPS index dc5e932..80bc21a 100644 --- a/components/crash/content/app/DEPS +++ b/components/crash/content/app/DEPS @@ -4,5 +4,6 @@ include_rules = [ "+content/public/common/content_descriptors.h", "+content/public/common/result_codes.h", "+third_party/crashpad", + "+third_party/kasko", "+third_party/lss/linux_syscall_support.h", ] diff --git a/components/crash/content/app/crashpad.cc b/components/crash/content/app/crashpad.cc index 19a363634..dfe83ca 100644 --- a/components/crash/content/app/crashpad.cc +++ b/components/crash/content/app/crashpad.cc @@ -243,7 +243,7 @@ void GetUploadedReports(std::vector* uploaded_reports) { }); } -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) void GetCrashKeysForKasko(std::vector* crash_keys) { // Reserve room for an extra key, the guid. @@ -282,7 +282,7 @@ void GetCrashKeysForKasko(std::vector* crash_keys) { } } -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) } // namespace crash_reporter diff --git a/components/crash/content/app/crashpad.h b/components/crash/content/app/crashpad.h index 59bc5d6..1f9f007 100644 --- a/components/crash/content/app/crashpad.h +++ b/components/crash/content/app/crashpad.h @@ -11,10 +11,11 @@ #include #include "base/files/file_path.h" +#include "third_party/kasko/kasko_features.h" -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) #include "syzygy/kasko/api/crash_key.h" -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) namespace crash_reporter { @@ -74,10 +75,10 @@ struct UploadedReport { // disabled. void GetUploadedReports(std::vector* uploaded_reports); -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) // Returns a copy of the current crash keys for Kasko. void GetCrashKeysForKasko(std::vector* crash_keys); -#endif // KASKO +#endif // BUILDFLAG(ENABLE_KASKO) namespace internal { diff --git a/components/nacl/broker/BUILD.gn b/components/nacl/broker/BUILD.gn index 23d8ba1..390f239 100644 --- a/components/nacl/broker/BUILD.gn +++ b/components/nacl/broker/BUILD.gn @@ -151,6 +151,7 @@ if (current_cpu == "x86") { "//components/policy", "//content/public/common:static_switches", "//ipc", + "//third_party/kasko:kasko_features", ] } } diff --git a/content/browser/frame_host/DEPS b/content/browser/frame_host/DEPS index 09569cb..a6068f73 100644 --- a/content/browser/frame_host/DEPS +++ b/content/browser/frame_host/DEPS @@ -5,6 +5,8 @@ include_rules = [ "-content/public/browser/web_contents.h", "-content/public/browser/web_contents_delegate.h", "-content/public/browser/web_contents_view.h", + + "+third_party/kasko", ] specific_include_rules = { diff --git a/content/browser/frame_host/debug_urls.cc b/content/browser/frame_host/debug_urls.cc index f095f8e..f3190a7 100644 --- a/content/browser/frame_host/debug_urls.cc +++ b/content/browser/frame_host/debug_urls.cc @@ -22,6 +22,7 @@ #include "content/public/common/content_constants.h" #include "content/public/common/url_constants.h" #include "ppapi/proxy/ppapi_messages.h" +#include "third_party/kasko/kasko_features.h" #include "url/gurl.h" #if defined(ENABLE_PLUGINS) @@ -42,7 +43,7 @@ const char kAsanCorruptHeapBlock[] = "/browser-corrupt-heap-block"; const char kAsanCorruptHeap[] = "/browser-corrupt-heap"; #endif -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) // Define the Kasko debug URLs. const char kKaskoCrashDomain[] = "kasko"; const char kKaskoSendReport[] = "/send-report"; @@ -66,7 +67,7 @@ void HandlePpapiFlashDebugURL(const GURL& url) { } bool IsKaskoDebugURL(const GURL& url) { -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) return (url.is_valid() && url.SchemeIs(kChromeUIScheme) && url.DomainIs(kKaskoCrashDomain) && url.path() == kKaskoSendReport); @@ -76,7 +77,7 @@ bool IsKaskoDebugURL(const GURL& url) { } void HandleKaskoDebugURL() { -#if defined(KASKO) +#if BUILDFLAG(ENABLE_KASKO) // Signature of the exported crash key setting function. using SetCrashKeyValueImplPtr = void(__cdecl *)(const wchar_t*, const wchar_t*); diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 30492a6..bc4a497 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -24,6 +24,7 @@ '../skia/skia.gyp:skia', '../skia/skia.gyp:skia_mojo', '../sql/sql.gyp:sql', + '../third_party/kasko/kasko.gyp:kasko_features', '../third_party/mojo/mojo_public.gyp:mojo_cpp_bindings', '../third_party/re2/re2.gyp:re2', '../third_party/zlib/google/zip.gyp:zip', diff --git a/third_party/kasko/BUILD.gn b/third_party/kasko/BUILD.gn index bedcb1d..2d06fe0 100644 --- a/third_party/kasko/BUILD.gn +++ b/third_party/kasko/BUILD.gn @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//build/config/features.gni") +import("//build/buildflag_header.gni") import("//build/config/sanitizers/sanitizers.gni") declare_args() { @@ -13,6 +13,15 @@ declare_args() { enable_kasko_hang_reports = false } +# GYP version: target 'kasko_features' in third_party/kasko/kasko.gyp +buildflag_header("kasko_features") { + header = "kasko_features.h" + flags = [ + "ENABLE_KASKO=$enable_kasko", + "ENABLE_KASKO_HANG_REPORTS=$enable_kasko_hang_reports", + ] +} + if (enable_kasko) { assert(is_win, "Kasko only support Windows.") assert(target_cpu == "x86", "Kasko only support 32 bits.") @@ -21,15 +30,12 @@ if (enable_kasko) { config("kasko_config") { visibility = [ ":*" ] - defines = [ "KASKO" ] - if (enable_kasko_hang_reports) { - defines += [ "KASKO_HANG_REPORTS" ] - } include_dirs = [ "//third_party/kasko/binaries/include" ] lib_dirs = [ "//third_party/kasko/binaries" ] libs = [ "kasko.dll.lib" ] } + # GYP version: target 'copy_kasko_dll' in third_party/kasko/kasko.gyp copy("copy_kasko_dll") { visibility = [ ":*" ] sources = [ @@ -41,15 +47,18 @@ if (enable_kasko) { ] } + # GYP version: target 'kasko' in third_party/kasko/kasko.gyp group("kasko") { - if (enable_kasko) { - deps = [ - ":copy_kasko_dll", - ] - public_configs = [ ":kasko_config" ] - } + public_deps = [ + ":copy_kasko_dll", + ":kasko_features", + ] + public_configs = [ ":kasko_config" ] } } else { group("kasko") { + public_deps = [ + ":kasko_features", + ] } } diff --git a/third_party/kasko/kasko.gyp b/third_party/kasko/kasko.gyp new file mode 100644 index 0000000..1d1162d --- /dev/null +++ b/third_party/kasko/kasko.gyp @@ -0,0 +1,79 @@ +{ + 'targets': [ + { + # GN: //third_party/kasko:kasko_features + 'target_name': 'kasko_features', + 'type': 'none', + 'includes': [ '../../build/buildflag_header.gypi' ], + 'variables': { + 'buildflag_header_path': 'third_party/kasko/kasko_features.h', + 'buildflag_flags': [ + 'ENABLE_KASKO=<(kasko)', + 'ENABLE_KASKO_HANG_REPORTS=<(kasko_hang_reports)', + ], + }, + }, + ], + 'conditions': [ + ['kasko==1', { + 'targets': [ + { + # GN: //third_party/kasko:copy_kasko_dll + 'target_name': 'copy_kasko_dll', + 'type': 'none', + 'variables': { + 'kasko_exe_dir': '<(DEPTH)/third_party/kasko/binaries', + }, + 'outputs': [ + '<(PRODUCT_DIR)/kasko.dll', + '<(PRODUCT_DIR)/kasko.dll.pdb', + ], + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)', + 'files': [ + '<(kasko_exe_dir)/kasko.dll', + '<(kasko_exe_dir)/kasko.dll.pdb', + ], + }, + ], + }, + { + # GN: //third_party/kasko + 'target_name': 'kasko', + 'type': 'none', + 'dependencies': [ + 'copy_kasko_dll', + 'kasko_features', + ], + 'direct_dependent_settings': { + 'msvs_settings': { + 'VCLinkerTool': { + 'AdditionalDependencies': [ + 'kasko.dll.lib', + ], + 'AdditionalLibraryDirectories': [ + '../third_party/kasko/binaries' + ], + }, + }, + 'include_dirs': [ + '../../third_party/kasko/binaries/include', + ], + }, + }, + ], + }, { # 'kasko==0' + 'targets': [ + { + # GN: //third_party/kasko + 'target_name': 'kasko', + 'type': 'none', + 'dependencies': [ + 'kasko_features', + ], + }, + ], + }], + ], # 'conditions' +} -- cgit v1.1