xref: /aosp_15_r20/external/cronet/third_party/jni_zero/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//third_party/jni_zero/jni_zero.gni")
6
7config("jni_include_dir") {
8  include_dirs = [ jni_headers_dir ]
9}
10
11config("toolchain_define") {
12  if (is_robolectric) {
13    defines = [ "JNI_ZERO_IS_ROBOLECTRIC" ]
14  }
15}
16
17# This is the public target that we intend others to use.
18component("jni_zero") {
19  # This is the public API.
20  sources = [ "jni_zero.h" ]
21
22  # These are intended to only be used within jni_zero and the code it generates.
23  sources += [
24    "jni_export.h",
25    "jni_zero.cc",
26    "jni_zero_internal.h",
27    "logging.cc",
28    "logging.h",
29  ]
30  if (is_android) {
31    libs = [ "log" ]
32  } else if (is_robolectric) {
33    public_configs = [ "//third_party/jdk:jdk" ]
34  }
35  configs += [ ":toolchain_define" ]
36}
37
38if (enable_java_templates && is_android) {
39  import("//build/config/android/rules.gni")
40
41  java_library("jni_zero_java") {
42    supports_android = true
43    deps = [ "//build/android:build_java" ]
44    sources = [
45      "java/src/org/jni_zero/AccessedByNative.java",
46      "java/src/org/jni_zero/CalledByNative.java",
47      "java/src/org/jni_zero/CalledByNativeForTesting.java",
48      "java/src/org/jni_zero/CalledByNativeUnchecked.java",
49      "java/src/org/jni_zero/CheckDiscard.java",
50      "java/src/org/jni_zero/JNINamespace.java",
51      "java/src/org/jni_zero/JniStaticTestMocker.java",
52      "java/src/org/jni_zero/JniType.java",
53      "java/src/org/jni_zero/NativeClassQualifiedName.java",
54      "java/src/org/jni_zero/NativeLibraryLoadedStatus.java",
55      "java/src/org/jni_zero/NativeMethods.java",
56    ]
57    proguard_configs = [ "proguard.flags" ]
58  }
59
60  group("jni_zero_tests") {
61    testonly = true
62    deps = [
63      "//third_party/jni_zero/sample:jni_zero_sample_apk_test",
64      "//third_party/jni_zero/test:jni_zero_compile_check_apk",
65    ]
66  }
67}
68