1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
# Copyright 2015 The Chromium Authors
# 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("//build/config/cronet/config.gni")
import("//build/config/features.gni")
import("//components/gwp_asan/buildflags/buildflags.gni")
declare_args() {
# If set to true, this will stub out and disable the entire crash key system.
use_crash_key_stubs = is_fuchsia
}
group("common") {
public_deps = [
":crash_key",
":crash_key_utils",
]
if (is_apple) {
public_deps += [ ":zombies" ]
}
if (is_ios) {
public_deps += [ ":reporter_running_ios" ]
}
}
use_crashpad_annotation =
(is_mac || is_ios || is_win || is_android || is_chromeos ||
(is_linux && !is_castos)) && !use_crash_key_stubs
# Make sure that breakpad use is limited to is_castos here so that there's no
# unknown unenumerated target.
assert(use_crash_key_stubs || use_crashpad_annotation || is_castos)
buildflag_header("crash_buildflags") {
header = "crash_buildflags.h"
flags = [
"USE_CRASHPAD_ANNOTATION=$use_crashpad_annotation",
"USE_CRASH_KEY_STUBS=$use_crash_key_stubs",
]
}
group("crash_key") {
public_deps = [ ":crash_key_lib" ]
}
# Crashpad's annotation system can store data on a per-module basis (i.e.,
# in different shared libraries in the component build) without issue. The
# Breakpad implementation uses a static global variable, so ensure there is
# only one instance of the symbol in the component build by making this
# target a component.
if (use_crash_key_stubs || use_crashpad_annotation) {
crash_key_target_type = "static_library"
} else {
crash_key_target_type = "component"
}
target(crash_key_target_type, "crash_key_lib") {
sources = [
"crash_export.h",
"crash_key.cc",
"crash_key.h",
"crash_key_base_support.cc",
"crash_key_base_support.h",
]
defines = []
# Consumers should depend on `:crash_key`.
visibility = [ ":*" ]
# This target is not always a component, depending on the implementation.
# When it is not a component, annotating functions with the standard
# CRASH_EXPORT macro causes linking errors on Windows (clients of this target
# expect it to be dllimport but it is linked statically). Instead, provide a
# wrapper macro CRASH_KEY_EXPORT that only evaluates to CRASH_EXPORT if this
# target is really a component.
if (crash_key_target_type == "component") {
defines += [
"CRASH_KEY_EXPORT=CRASH_EXPORT",
"CRASH_CORE_COMMON_IMPLEMENTATION",
]
}
public_deps = [ ":crash_buildflags" ]
deps = [ "//base" ]
if (use_crash_key_stubs) {
sources += [ "crash_key_stubs.cc" ]
} else if (use_crashpad_annotation) {
sources += [ "crash_key_crashpad.cc" ]
public_deps += [ "//third_party/crashpad/crashpad/client" ]
} else {
include_dirs = [ "//third_party/breakpad/breakpad/src" ]
sources += [
"crash_key_breakpad.cc",
"crash_key_internal.h",
]
deps += [ "//third_party/breakpad:client" ]
}
}
static_library("crash_key_utils") {
visibility = [ ":*" ]
sources = [
"crash_keys.cc",
"crash_keys.h",
]
deps = [
":crash_key",
"//base",
]
}
if (is_apple) {
component("zombies") {
visibility = [ ":common" ]
sources = [
"objc_zombie.h",
"objc_zombie.mm",
]
defines = [ "CRASH_CORE_COMMON_IMPLEMENTATION" ]
# Do not compile with ARC because ARC would prevent intercepting and
# interfering with low-level object destruction.
configs -= [ "//build/config/compiler:enable_arc" ]
deps = [
":crash_key",
"//base",
"//components/gwp_asan/buildflags",
]
if (enable_gwp_asan_malloc) {
deps += [ "//components/gwp_asan/client" ]
}
frameworks = [ "Foundation.framework" ]
}
}
if (is_ios) {
source_set("reporter_running_ios") {
sources = [
"reporter_running_ios.cc",
"reporter_running_ios.h",
]
}
}
source_set("unit_tests") {
testonly = true
sources = [
"crash_key_unittest.cc",
"crash_keys_unittest.cc",
]
deps = [
":common",
"//base",
"//testing/gtest",
]
if (is_apple) {
sources += [ "objc_zombie_unittest.mm" ]
# Do not compile with ARC because ARC would prevent intercepting and
# interfering with low-level object destruction.
configs -= [ "//build/config/compiler:enable_arc" ]
}
if (is_castos) {
include_dirs = [ "//third_party/breakpad/breakpad/src/" ]
sources += [ "crash_key_breakpad_unittest.cc" ]
}
# TODO(crbug.com/40172607): Enable when crash keys are supported on Fuchsia.
if (is_fuchsia) {
sources -= [
"crash_key_unittest.cc",
"crash_keys_unittest.cc",
]
}
}
|