xref: /aosp_15_r20/external/cronet/third_party/jni_zero/test/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2024 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.
4import("//build/config/android/rules.gni")
5import("//third_party/jni_zero/jni_zero.gni")
6
7# All targets in this file are meant as compile tests only to make sure the
8# generated code compiles for all edgecases.
9testonly = true
10
11generate_jni("test_jni") {
12  sources = [
13    "java/src/org/jni_zero/SampleForAnnotationProcessor.java",
14    "java/src/org/jni_zero/SampleForTests.java",
15  ]
16}
17
18android_library("stubs_java") {
19  sources = [
20    "java/src/org/stubs/MyClass.java",
21    "java/src/org/stubs/MyInterface.java",
22  ]
23}
24
25android_library("test_java") {
26  srcjar_deps = [ ":test_jni" ]
27  sources = [
28    "java/src/org/jni_zero/SampleForAnnotationProcessor.java",
29    "java/src/org/jni_zero/SampleForTests.java",
30  ]
31
32  deps = [
33    ":stubs_java",
34    "//third_party/jni_zero:jni_zero_java",
35  ]
36}
37
38source_set("test_native_side") {
39  deps = [
40    ":test_jni",
41    "//third_party/jni_zero",
42  ]
43  sources = [
44    "sample_for_tests.cc",
45    "sample_for_tests.h",
46  ]
47}
48
49shared_library_with_jni("libjni_zero_compile_check") {
50  sources = [ "../sample/sample_entry_point.cc" ]
51
52  deps = [
53    ":test_native_side",
54    "//third_party/jni_zero",
55  ]
56  java_targets = [ ":jni_zero_compile_check_apk" ]
57  remove_uncalled_jni = true
58}
59
60# This apk is meant to be a compile only test to make sure the generated code,
61# both java and native, compiles for all the edgecases. APK itself is not meant
62# to be run or installed on a device since a lot of internal implementations are
63# empty stubs and are just meant for the compiler or linker to see.
64android_apk("jni_zero_compile_check_apk") {
65  apk_name = "JniZeroCompileCheck"
66  android_manifest = "../sample/AndroidManifest.xml"
67  deps = [ ":test_java" ]
68  shared_libraries = [ ":libjni_zero_compile_check" ]
69  srcjar_deps = [ ":libjni_zero_compile_check__jni_registration" ]
70  proguard_enabled = true
71}
72