1// Copyright (C) 2009 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15cc_defaults {
16    name: "libnativehelper_defaults",
17    cflags: [
18        "-fvisibility=protected",
19        "-std=c11",
20    ],
21}
22
23cc_library_headers {
24    name: "jni_headers",
25    host_supported: true,
26    export_include_dirs: ["include_jni"],
27    native_bridge_supported: true,
28    vendor_available: true,
29    target: {
30        windows: {
31            enabled: true,
32        },
33    },
34    apex_available: [
35        "//apex_available:platform",
36        "//apex_available:anyapex",
37    ],
38    // recovery_available currently required for libchrome (https://r.android.com/799940).
39    recovery_available: true,
40    visibility: ["//visibility:public"],
41    stl: "none",
42    system_shared_libs: [],
43    // The minimum sdk version required by users of this module.
44    sdk_version: "minimum",
45    // As part of mainline modules(APEX), it should support at least 29(Q)
46    min_sdk_version: "29",
47}
48
49cc_library_headers {
50    name: "libnativehelper_header_only",
51    host_supported: true,
52    export_include_dirs: [
53        "header_only_include",
54    ],
55    header_libs: ["jni_headers"],
56    export_header_lib_headers: ["jni_headers"],
57    target: {
58        windows: {
59            enabled: true,
60        },
61    },
62    // As part of mainline modules(APEX), it should support at least 29(Q)
63    min_sdk_version: "29",
64    sdk_version: "minimum",
65    apex_available: [
66        "//apex_available:platform",
67        "//apex_available:anyapex",
68    ],
69}
70
71cc_library_headers {
72    name: "jni_platform_headers",
73    host_supported: true,
74    export_include_dirs: [
75        "include_platform_header_only",
76    ],
77    header_libs: ["jni_headers"],
78    export_header_lib_headers: ["jni_headers"],
79    sdk_version: "minimum",
80    target: {
81        windows: {
82            enabled: true,
83        },
84    },
85    apex_available: [
86        "//apex_available:platform",
87        "com.android.art.debug",
88        "com.android.art.release",
89    ],
90}
91
92cc_library_shared {
93    name: "libnativehelper",
94    defaults: ["libnativehelper_defaults"],
95    host_supported: true,
96    srcs: [
97        "DlHelp.c",
98        "ExpandableString.c",
99        "JNIHelp.c",
100        "JNIPlatformHelp.c",
101        "JniConstants.c",
102        "JniInvocation.c",
103    ],
104    shared_libs: ["liblog"],
105    export_include_dirs: [
106        "header_only_include",
107        "include",
108        "include_jni",
109        "include_platform",
110        "include_platform_header_only",
111    ],
112    stl: "none",
113    stubs: {
114        symbol_file: "libnativehelper.map.txt",
115        versions: ["31"],
116    },
117    target: {
118        android: {
119            // FileDescriptor NDK API is Android-only.
120            srcs: ["file_descriptor_jni.c"],
121        },
122        windows: {
123            enabled: true,
124        },
125    },
126    // Only distributed in the ART Module.
127    apex_available: [
128        "com.android.art.release",
129        "com.android.art.debug",
130    ],
131}
132
133//
134// NDK-only build for the target (device), using libc++.
135// - Relies only on NDK exposed functionality.
136// - This doesn't include JniInvocation.
137//
138
139cc_library_shared {
140    name: "libnativehelper_compat_libc++",
141    defaults: ["libnativehelper_defaults"],
142    header_libs: ["jni_headers"],
143    cflags: ["-Werror"],
144    export_header_lib_headers: ["jni_headers"],
145    export_include_dirs: [
146        "header_only_include",
147        "include",
148    ],
149    local_include_dirs: [
150        "header_only_include",
151        "include_platform_header_only",
152    ],
153    srcs: [
154        "ExpandableString.c",
155        "JNIHelp.c",
156        // This is needed for NetworkStack and Tethering until a better
157        // solution is found (b/158749603).
158        "JNIHelpCompat.c",
159    ],
160    shared_libs: [
161        "liblog",
162    ],
163    sdk_version: "19",
164    stl: "none",
165    apex_available: [
166        "//apex_available:platform",
167        "com.android.tethering",
168    ],
169    visibility: [
170        "//cts:__subpackages__",
171        "//external/perfetto:__subpackages__",
172        "//frameworks/base/tests/net/integration:__pkg__",
173        "//frameworks/base/packages/Tethering:__subpackages__",
174        "//packages/modules/NetworkStack:__subpackages__",
175        ":__subpackages__",
176    ],
177}
178
179ndk_headers {
180    name: "ndk_jni.h",
181    from: "include_jni",
182    to: "",
183    srcs: ["include_jni/jni.h"],
184    license: "NOTICE",
185}
186
187ndk_headers {
188    name: "libnativehelper_ndk_headers",
189    from: "include",
190    to: "",
191    srcs: ["include/android/*.h"],
192    license: "NOTICE",
193}
194
195ndk_library {
196    name: "libnativehelper",
197    symbol_file: "libnativehelper.map.txt",
198    first_version: "31",
199}
200
201//
202// Tests.
203//
204
205subdirs = [
206    "tests",
207    "tests_mts",
208]
209