blob: 7722b2bea527fd0e7ef8dc9bd459936b86ab4efd [file] [log] [blame]
# Copyright 2018 The Chromium OS 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("//common-mk/pkg_config.gni")
import("//common-mk/proto_library.gni")
shared_defines = [
"USE_DIRENCRYPTION=${use.direncryption}",
"USE_KVM_GUEST=${use.kvm_guest}",
"USE_ARCPP=${use.arcpp}",
"USE_ARCVM=${use.arcvm}",
"USE_KVM_GUEST=${use.kvm_guest}",
"USE_CHROMELESS_TTY=${use.chromeless_tty}",
]
group("all") {
deps = [
":anomaly_detector",
":crash_reporter",
":crash_sender",
":crash_serializer_main",
":libcrash",
":libcrash_reporter",
]
if (use.arcpp) {
deps += [ ":core_collector" ]
}
if (use.test) {
deps += [
":anomaly_detector_log_reader_test",
":anomaly_detector_test",
":anomaly_detector_text_file_reader_test",
":crash_reporter_test",
]
}
if (use.fuzzer) {
deps += [
":anomaly_detector_fuzzer",
":chrome_collector_fuzzer",
":crash_sender_fuzzer",
]
}
}
pkg_config("libcrash_config") {
pkg_deps = [
"libchrome",
"libsession_manager-client",
"re2",
"vboot_host",
"zlib",
]
}
static_library("libcrash") {
sources = [
"crossystem.cc",
"paths.cc",
"util.cc",
"vm_support.cc",
]
all_dependent_configs = [ ":libcrash_config" ]
defines = shared_defines
if (use.direncryption) {
libs = [ "keyutils" ]
}
}
pkg_config("libcrash_reporter_config") {
pkg_deps = [
"libbrillo",
"libchrome",
"libdebugd-client",
"libsession_manager-client",
]
}
static_library("libcrash_reporter") {
sources = [
"bert_collector.cc",
"chrome_collector.cc",
"clobber_state_collector.cc",
"crash_collector.cc",
"crash_reporter_failure_collector.cc",
"ec_collector.cc",
"ephemeral_crash_collector.cc",
"generic_failure_collector.cc",
"kernel_collector.cc",
"kernel_util.cc",
"kernel_warning_collector.cc",
"missed_crash_collector.cc",
"mount_failure_collector.cc",
"security_anomaly_collector.cc",
"selinux_violation_collector.cc",
"udev_collector.cc",
"unclean_shutdown_collector.cc",
"user_collector.cc",
"user_collector_base.cc",
"vm_collector.cc",
]
all_dependent_configs = [ ":libcrash_reporter_config" ]
defines = shared_defines
libs = [ "policy" ]
deps = [ "//common-mk/external_dependencies:policy-protos" ]
if (use.arcpp || use.arcvm) {
sources += [
"arc_java_collector.cc",
"arc_util.cc",
]
}
if (use.arcpp) {
sources += [ "arcpp_cxx_collector.cc" ]
}
if (use.arcvm) {
sources += [
"arcvm_cxx_collector.cc",
"arcvm_kernel_collector.cc",
]
}
if (use.kvm_guest) {
sources += [ "vm_support_proper.cc" ]
}
}
pkg_config("crash_reporter_config") {
pkg_deps = [
"dbus-1",
"libmetrics",
"libminijail",
"protobuf",
"vm_protos",
]
if (use.kvm_guest) {
pkg_deps += [ "grpc++" ]
}
}
proto_library("crash_reporter_proto") {
proto_in_dir = "./proto"
proto_out_dir = "include/crash-reporter"
sources = [ "${proto_in_dir}/crash_reporter.proto" ]
}
executable("crash_reporter") {
sources = [ "crash_reporter.cc" ]
configs += [ ":crash_reporter_config" ]
defines = shared_defines
deps = [
":crash_reporter_proto",
":libcrash",
":libcrash_reporter",
]
}
pkg_config("libcrash_sender_config") {
pkg_deps = [
"libbrillo",
"libchrome",
"libmetrics",
"libminijail",
"libsession_manager-client",
"libshill-client",
]
if (use.fuzzer) {
pkg_deps += [ "protobuf" ]
} else {
pkg_deps += [ "protobuf-lite" ]
}
}
proto_library("crash_sender_proto") {
proto_in_dir = "./proto"
proto_out_dir = "include/crash-reporter"
sources = [ "${proto_in_dir}/crash_sender.proto" ]
}
static_library("libcrash_sender") {
sources = [
"crash_sender_base.cc",
"crash_sender_util.cc",
]
all_dependent_configs = [ ":libcrash_sender_config" ]
defines = shared_defines
deps = [ ":crash_sender_proto" ]
}
executable("crash_sender") {
sources = [ "crash_sender.cc" ]
deps = [
":libcrash",
":libcrash_sender",
]
}
pkg_config("crash_serializer_config") {
pkg_deps = [
"libbrillo",
"libchrome",
"libsession_manager-client",
"protobuf",
]
}
static_library("libcrash_serializer") {
sources = [ "crash_serializer.cc" ]
all_dependent_configs = [ ":crash_serializer_config" ]
deps = [
":crash_serializer_proto",
":libcrash",
":libcrash_sender",
]
}
executable("crash_serializer_main") {
output_name = "crash_serializer"
sources = [ "crash_serializer_main.cc" ]
deps = [
":libcrash",
":libcrash_sender",
":libcrash_serializer",
]
}
proto_library("crash_serializer_proto") {
proto_in_dir = "./proto"
proto_out_dir = "include/crash-reporter"
sources = [ "${proto_in_dir}/crash_serializer.proto" ]
}
pkg_config("anomaly_detector_config") {
# NOSORT
pkg_deps = [
"libbrillo",
"libchrome",
"libmetrics",
"re2",
# system_api depends on protobuf. It must appear before protobuf
# here or the linker flags won't be in the right order.
"system_api",
"vm_protos",
"protobuf",
]
}
executable("anomaly_detector") {
sources = [
"anomaly_detector.cc",
"anomaly_detector_log_reader.cc",
"anomaly_detector_main.cc",
"anomaly_detector_service.cc",
"anomaly_detector_text_file_reader.cc",
"crash_reporter_parser.cc",
]
configs += [ ":anomaly_detector_config" ]
libs = [
"system_api-metrics_event-protos",
"system_api-anomaly_detector-protos",
]
deps = [ ":libcrash" ]
}
if (use.arcpp) {
pkg_config("core_collector_config") {
pkg_deps = [ "breakpad-client" ]
}
executable("core_collector") {
sources = [
"core-collector/core_collector.cc",
"core-collector/coredump_writer.cc",
"core-collector/coredump_writer.h",
]
# This condition matches the "use_i686" helper in the "cros-i686"
# eclass. The "amd64" check allows the "cros_i686" USE flag to be
# enabled for an overlay inherited by non-x86 boards.
if (use.cros_i686 && use.amd64) {
# We link the C & C++ runtime statically because dynamic libs for these
# (multilib) ABIs aren't installed. The eclasses handle forcing -static,
# and that doesn't work with PIE linking
configs -= [ "//common-mk:pie" ]
}
# This condition matches the "use_arm64" helper in the "cros-arm64"
# eclass. The "arm" check allows the "cros_arm64" USE flag to be
# enabled for an overlay inherited by non-arm boards.
if (use.cros_arm64 && use.arm) {
# We link the C & C++ runtime statically because dynamic libs for these
# (multilib) ABIs aren't installed. The eclasses handle forcing -static,
# and that doesn't work with PIE linking
configs -= [ "//common-mk:pie" ]
}
configs += [ ":core_collector_config" ]
}
}
if (use.test || use.fuzzer) {
pkg_config("crash_reporter_test_config") {
pkg_deps = [
"libbrillo-test",
"libchrome-test",
"libdebugd-client-test",
"libmetrics",
"libsession_manager-client-test",
"libshill-client-test",
"protobuf",
"vm_protos",
]
if (use.kvm_guest) {
pkg_deps += [ "grpc++" ]
}
}
static_library("libcrash_test_util") {
sources = [ "test_util.cc" ]
all_dependent_configs = [
":crash_reporter_test_config",
":libcrash_config",
]
configs += [
"//common-mk:test",
":libcrash_reporter_config",
]
}
}
if (use.test) {
pkg_config("test_helper_config") {
pkg_deps = [
"libbrillo",
"libbrillo-test",
"libchrome",
"libchrome-test",
]
}
executable("lock_file_tester") {
sources = [ "lock_file_tester.cc" ]
configs += [
"//common-mk:test",
":test_helper_config",
]
}
executable("hold_lock_file") {
sources = [ "hold_lock_file.cc" ]
configs += [
"//common-mk:test",
":test_helper_config",
]
}
executable("crash_reporter_test") {
sources = [
"bert_collector_test.cc",
"chrome_collector_test.cc",
"clobber_state_collector_test.cc",
"crash_collector_test.cc",
"crash_collector_test.h",
"crash_reporter_failure_collector_test.cc",
"crash_reporter_logs_test.cc",
"crash_sender_base_test.cc",
"crash_sender_util_test.cc",
"crash_serializer_test.cc",
"ec_collector_test.cc",
"ephemeral_crash_collector_test.cc",
"generic_failure_collector_test.cc",
"kernel_collector_test.cc",
"kernel_collector_test.h",
"kernel_util_test.cc",
"kernel_warning_collector_test.cc",
"missed_crash_collector_test.cc",
"mount_failure_collector_test.cc",
"paths_test.cc",
"security_anomaly_collector_test.cc",
"selinux_violation_collector_test.cc",
"testrunner.cc",
"udev_collector_test.cc",
"unclean_shutdown_collector_test.cc",
"user_collector_test.cc",
"util_test.cc",
]
configs += [
"//common-mk:test",
":crash_reporter_test_config",
]
defines = shared_defines
deps = [
":crash_reporter_proto",
":crash_serializer_proto",
":hold_lock_file",
":libcrash",
":libcrash_reporter",
":libcrash_sender",
":libcrash_serializer",
":libcrash_test_util",
":lock_file_tester",
]
if (use.arcpp || use.arcvm) {
sources += [
"arc_java_collector_test.cc",
"arc_util_test.cc",
]
}
if (use.arcpp) {
sources += [ "arcpp_cxx_collector_test.cc" ]
}
if (use.arcvm) {
sources += [
"arcvm_cxx_collector_test.cc",
"arcvm_kernel_collector_test.cc",
]
}
if (use.kvm_guest) {
sources += [ "vm_support_proper_test.cc" ]
}
}
executable("anomaly_detector_test") {
sources = [
"anomaly_detector.cc",
"anomaly_detector_test.cc",
"anomaly_detector_test_utils.cc",
"crash_reporter_parser.cc",
"crash_reporter_parser_test.cc",
"test_util.cc",
]
configs += [
"//common-mk:test",
":anomaly_detector_config",
":crash_reporter_test_config",
]
libs = [ "system_api-anomaly_detector-protos" ]
deps = [
":libcrash",
"//common-mk/testrunner:testrunner",
]
}
executable("anomaly_detector_text_file_reader_test") {
sources = [
"anomaly_detector_text_file_reader.cc",
"anomaly_detector_text_file_reader_test.cc",
"test_util.cc",
]
configs += [
"//common-mk:test",
":anomaly_detector_config",
":crash_reporter_test_config",
]
libs = [ "system_api-anomaly_detector-protos" ]
deps = [
":libcrash",
"//common-mk/testrunner:testrunner",
]
}
executable("anomaly_detector_log_reader_test") {
sources = [
"anomaly_detector_log_reader.cc",
"anomaly_detector_log_reader_test.cc",
"anomaly_detector_text_file_reader.cc",
"test_util.cc",
]
configs += [
"//common-mk:test",
":anomaly_detector_config",
":crash_reporter_test_config",
]
libs = [ "system_api-anomaly_detector-protos" ]
deps = [
":libcrash",
"//common-mk/testrunner:testrunner",
]
}
}
if (use.fuzzer) {
executable("crash_sender_fuzzer") {
sources = [ "crash_sender_fuzzer.cc" ]
configs += [ "//common-mk/common_fuzzer:common_fuzzer" ]
deps = [
":libcrash",
":libcrash_sender",
":libcrash_test_util",
]
}
executable("chrome_collector_fuzzer") {
sources = [ "chrome_collector_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer:common_fuzzer",
":crash_reporter_test_config",
]
deps = [
":libcrash",
":libcrash_reporter",
":libcrash_test_util",
]
}
executable("anomaly_detector_fuzzer") {
sources = [
"anomaly_detector.cc",
"anomaly_detector_fuzzer.cc",
"crash_reporter_parser.cc",
]
configs += [
"//common-mk/common_fuzzer:common_fuzzer",
":anomaly_detector_config",
]
libs = [ "system_api-anomaly_detector-protos" ]
deps = [
":libcrash",
":libcrash_test_util",
]
}
}