chromium/components/crash/android/BUILD.gn

# Copyright 2017 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/config/android/rules.gni")
import("//third_party/jni_zero/jni_zero.gni")

_jni_sources = [
  "java/src/org/chromium/components/crash/CrashKeys.java",
  "java/src/org/chromium/components/crash/PureJavaExceptionHandler.java",
]

generate_jni("jni_headers") {
  sources = _jni_sources
}

generate_jni("package_paths_jni") {
  sources =
      [ "java/src/org/chromium/components/crash/browser/PackagePaths.java" ]
}

java_cpp_enum("java_enums_srcjar") {
  sources = [ "crash_keys_android.h" ]
}

android_library("java") {
  deps = [
    ":jni_headers_java",
    "//base:base_java",
    "//base/version_info/android:version_constants_java",
    "//build/android:build_java",
    "//components/crash/content/browser:jni_headers_java",
    "//components/minidump_uploader:minidump_uploader_java",
    "//content/public/android:content_main_dex_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/jni_zero:jni_zero_java",
  ]

  srcjar_deps = [ ":java_enums_srcjar" ]
  sources = [
    "java/src/org/chromium/components/crash/CustomAssertionHandler.java",
    "java/src/org/chromium/components/crash/LogcatCrashExtractor.java",
    "java/src/org/chromium/components/crash/MinidumpLogcatPrepender.java",
    "java/src/org/chromium/components/crash/NativeAndJavaSmartExceptionReporter.java",
    "java/src/org/chromium/components/crash/PureJavaExceptionReporter.java",
    "java/src/org/chromium/components/crash/browser/ChildProcessCrashObserver.java",
    "java/src/org/chromium/components/crash/browser/PackagePaths.java",
    "java/src/org/chromium/components/crash/browser/ProcessExitReasonFromSystem.java",
  ]
  sources += _jni_sources
}

robolectric_library("junit") {
  sources = [
    "junit/src/org/chromium/components/crash/LogcatCrashExtractorTest.java",
    "junit/src/org/chromium/components/crash/PureJavaExceptionReporterTest.java",
    "junit/src/org/chromium/components/crash/anr/AnrCollectorTest.java",
  ]
  deps = [
    ":anr_collector_java",
    ":anr_data_proto_java",
    ":java",
    "//base:base_java_test_support",
    "//base:base_junit_test_support",
    "//base:tasks_java",
    "//components/minidump_uploader:minidump_uploader_java_test_support",
    "//content/public/test/android:content_java_test_support",
    "//third_party/androidx:androidx_test_runner_java",
    "//third_party/junit",
  ]
}

source_set("crash_android") {
  sources = [
    "anr_build_id_provider.cc",
    "anr_build_id_provider.h",
    "crash_keys_android.cc",
    "crash_keys_android.h",
    "pure_java_exception_handler.cc",
    "pure_java_exception_handler.h",
  ]
  deps = [
    ":anr_collector_jni_headers",
    ":jni_headers",
    "//base",
    "//components/crash/core/common:crash_key",
  ]
}

source_set("unit_tests") {
  testonly = true
  sources = [ "crash_keys_android_unittest.cc" ]
  deps = [
    ":crash_android",
    "//components/crash/core/common:crash_key",
    "//testing/gtest",
  ]
}

_java_handler_jni_sources =
    [ "java/src/org/chromium/components/crash/browser/CrashpadMain.java" ]

generate_jni("java_handler_jni_headers") {
  sources = _java_handler_jni_sources
}

android_library("handler_java") {
  deps = [
    "//build/android:build_java",
    "//third_party/jni_zero:jni_zero_java",
  ]

  srcjar_deps = [ ":java_handler_jni_headers" ]
  sources = _java_handler_jni_sources
}

static_library("crashpad_main") {
  sources = [ "crashpad_main.cc" ]

  deps = [
    ":java_handler_jni_headers",
    "//base",
    "//third_party/crashpad/crashpad/client",
    "//third_party/crashpad/crashpad/handler",
  ]
}

source_set("anr_skipped_reason") {
  sources = [ "anr_skipped_reason.h" ]
}
java_cpp_enum("anr_skipped_reason_enum") {
  sources = [ "anr_skipped_reason.h" ]
}

proto_java_library("anr_data_proto_java") {
  proto_path = "."
  sources = [ "anr_data.proto" ]
}

_anr_collector_jni_sources =
    [ "java/src/org/chromium/components/crash/anr/AnrCollector.java" ]

generate_jni("anr_collector_jni_headers") {
  sources = _anr_collector_jni_sources
}
android_library("anr_collector_java") {
  deps = [
    ":anr_data_proto_java",
    "//base:base_java",
    "//build/android:build_java",
    "//third_party/android_deps:protobuf_lite_runtime_java",
    "//third_party/androidx:androidx_annotation_annotation_java",
    "//third_party/jni_zero:jni_zero_java",
  ]

  srcjar_deps = [
    ":anr_collector_jni_headers",
    ":anr_skipped_reason_enum",
  ]
  sources = _anr_collector_jni_sources
}