chromium/chrome/android/modules/stack_unwinder/internal/BUILD.gn

# Copyright 2019 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("//chrome/android/modules/buildflags.gni")
import("//third_party/jni_zero/jni_zero.gni")

android_library("java") {
  srcjar_deps = [ ":jni_headers" ]
  sources = [ "java/src/org/chromium/chrome/modules/stack_unwinder/StackUnwinderModuleContentsImpl.java" ]

  deps = [
    "//build/android:build_java",
    "//chrome/android/modules/stack_unwinder/public:java",
    "//third_party/jni_zero:jni_zero_java",
  ]
}

generate_jni("jni_headers") {
  sources = [ "java/src/org/chromium/chrome/modules/stack_unwinder/StackUnwinderModuleContentsImpl.java" ]
}

# This group is effectively an alias representing the module's native code,
# allowing it to be named "native" for clarity in module descriptors. The
# component target must be named according to the feature, so that the component
# build's .cr.co library is named properly (ie. libstack_unwinder.cr.so).
group("native") {
  deps = [ ":stack_unwinder" ]
}

component_with_jni("stack_unwinder") {
  java_targets = [ ":java" ]
  sources = [
    "entrypoints.cc",
    "stack_unwinder_module_contents_impl.cc",
  ]
  deps = [
    ":jni_headers",
    "//base",
    "//base:native_unwinder_android",
    "//chrome/android/features/stack_unwinder/public:native",
    "//third_party/jni_zero",
  ]

  # stack unwinder native entrypoints belong in the partition.
  if (use_native_partitions) {
    cflags = [ "-fsymbol-partition=stack_unwinder_partition" ]
  }
  manual_jni_registration = true
  namespace = "stack_unwinder"
  module_name = "stack_unwinder"
}

# Since loading of a partitioned library is not supported in an APK, a separate
# target without partition is necessary for testing.
source_set("stack_unwinder_for_testing") {
  testonly = true
  sources = [ "stack_unwinder_module_contents_impl.cc" ]
  deps = [
    ":jni_headers",
    "//base",
    "//base:native_unwinder_android",
    "//chrome/android/features/stack_unwinder/public:native",
  ]
}