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 15package { 16 default_applicable_licenses: ["libnativehelper_license"], 17 default_team: "trendy_team_art_mainline", 18} 19 20// Added automatically by a large-scale-change 21// http://go/android-license-faq 22license { 23 name: "libnativehelper_license", 24 visibility: [":__subpackages__"], 25 license_kinds: [ 26 "SPDX-license-identifier-Apache-2.0", 27 ], 28 license_text: [ 29 "NOTICE", 30 ], 31} 32 33cc_defaults { 34 name: "libnativehelper_defaults", 35 cflags: [ 36 "-fvisibility=protected", 37 "-std=c11", 38 ], 39 shared_libs: ["liblog"], 40 export_shared_lib_headers: ["liblog"], 41} 42 43cc_library_headers { 44 name: "jni_headers", 45 host_supported: true, 46 export_include_dirs: ["include_jni"], 47 native_bridge_supported: true, 48 product_available: true, 49 vendor_available: true, 50 target: { 51 windows: { 52 enabled: true, 53 }, 54 }, 55 apex_available: [ 56 "//apex_available:platform", 57 "//apex_available:anyapex", 58 ], 59 ramdisk_available: true, 60 // recovery_available currently required for libchrome (https://r.android.com/799940). 61 recovery_available: true, 62 visibility: ["//visibility:public"], 63 stl: "none", 64 system_shared_libs: [], 65 // The minimum sdk version required by users of this module. 66 sdk_version: "minimum", 67 // As part of mainline modules(APEX), it should support at least 29(Q) 68 min_sdk_version: "29", 69} 70 71cc_library_headers { 72 name: "libnativehelper_header_only", 73 host_supported: true, 74 export_include_dirs: [ 75 "header_only_include", 76 ], 77 header_libs: ["jni_headers"], 78 export_header_lib_headers: ["jni_headers"], 79 // As part of mainline modules(APEX), it should support at least 29(Q) 80 min_sdk_version: "29", 81 sdk_version: "minimum", 82 apex_available: [ 83 "//apex_available:platform", 84 "//apex_available:anyapex", 85 ], 86} 87 88cc_library_headers { 89 name: "jni_platform_headers", 90 host_supported: true, 91 export_include_dirs: [ 92 "include_platform_header_only", 93 ], 94 header_libs: ["jni_headers"], 95 export_header_lib_headers: ["jni_headers"], 96 sdk_version: "minimum", 97 apex_available: [ 98 "//apex_available:platform", 99 "com.android.art", 100 "com.android.art.debug", 101 ], 102 min_sdk_version: "S", // 31 103} 104 105// This library contains code that is compatible with 106// both ART and JVM. All code specific to ART should go 107// inside libnativehelper directly. 108cc_library_static { 109 name: "libnativehelper_any_vm", 110 defaults: ["libnativehelper_defaults"], 111 host_supported: true, 112 srcs: [ 113 "DlHelp.c", 114 "ExpandableString.c", 115 "JNIHelp.c", 116 "JniInvocation.c", 117 ], 118 export_include_dirs: [ 119 "header_only_include", 120 "include", 121 "include_jni", 122 "include_platform", 123 "include_platform_header_only", 124 ], 125 visibility: ["//frameworks/base/libs/nativehelper_jvm"], 126 stl: "none", 127 apex_available: [ 128 "com.android.art", 129 "com.android.art.debug", 130 ], 131 min_sdk_version: "S", // 31 132 target: { 133 windows: { 134 enabled: true, 135 }, 136 }, 137} 138 139cc_library_shared { 140 name: "libnativehelper", 141 defaults: ["libnativehelper_defaults"], 142 bootstrap: false, 143 host_supported: true, 144 srcs: [ 145 "JNIPlatformHelp.c", 146 "JniConstants.c", 147 "file_descriptor_jni.c", 148 ], 149 whole_static_libs: ["libnativehelper_any_vm"], 150 export_static_lib_headers: ["libnativehelper_any_vm"], 151 stl: "none", 152 stubs: { 153 symbol_file: "libnativehelper.map.txt", 154 versions: ["S"], 155 }, 156 // Only distributed in the ART Module. 157 apex_available: [ 158 "com.android.art", 159 "com.android.art.debug", 160 ], 161 min_sdk_version: "S", // 31 162} 163 164// Lazy loading version of libnativehelper that can be used by code 165// that is running before the ART APEX is mounted and 166// libnativehelper.so is available. 167cc_library_static { 168 name: "libnativehelper_lazy", 169 defaults: ["libnativehelper_defaults"], 170 bootstrap: true, 171 host_supported: true, 172 export_include_dirs: [ 173 "header_only_include", 174 "include", 175 "include_jni", 176 "include_platform", 177 "include_platform_header_only", 178 ], 179 apex_available: ["//apex_available:platform"], 180 srcs: ["libnativehelper_lazy.c"], 181 target: { 182 linux: { 183 version_script: "libnativehelper.map.txt", 184 }, 185 }, 186} 187 188// NDK-only build for the target (device). 189// - Relies only on NDK exposed functionality. 190// - This doesn't include JniInvocation. 191// - This library is less than 20 KB - it is recommended that callers link it statically. 192// - Used to link libc++ (hence the name) but no longer does. 193cc_library { 194 name: "libnativehelper_compat_libc++", 195 defaults: ["libnativehelper_defaults"], 196 host_supported: true, 197 cflags: ["-Werror"], 198 199 header_libs: ["jni_headers"], 200 export_header_lib_headers: ["jni_headers"], 201 export_include_dirs: [ 202 "header_only_include", 203 "include", 204 ], 205 local_include_dirs: [ 206 "include_platform_header_only", 207 ], 208 srcs: [ 209 "ExpandableString.c", 210 "JNIHelp.c", 211 ], 212 213 min_sdk_version: "29", 214 sdk_version: "19", 215 stl: "none", 216 apex_available: [ 217 "//apex_available:anyapex", 218 "//apex_available:platform", 219 ], 220} 221 222// The NDK module definitions reside in 223// system/extras/module_ndk_libs/libnativehelper in platform, with copies of 224// these headers and map.txt. Any changes here should be synced there and vice 225// versa. 226// 227// TODO(b/170644498): Improve tooling to remove this duplication. 228// 229// ndk_headers { 230// name: "ndk_jni.h", 231// from: "include_jni", 232// to: "", 233// srcs: ["include_jni/jni.h"], 234// license: "NOTICE", 235// } 236// 237// ndk_headers { 238// name: "libnativehelper_ndk_headers", 239// from: "include", 240// to: "", 241// srcs: ["include/android/*.h"], 242// license: "NOTICE", 243// } 244// 245// ndk_library { 246// name: "libnativehelper", 247// symbol_file: "libnativehelper.map.txt", 248// first_version: "S", 249// } 250 251// 252// Tests. 253// 254 255subdirs = [ 256 "tests", 257 "tests_mts", 258] 259