1// Copyright (C) 2007 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 15// 16// Definitions for building the native code needed for the core library. 17// 18 19// Defaults that apply to all of the modules 20 21cc_defaults { 22 name: "core_native_default_flags", 23 defaults: ["art_module_source_build_defaults"], 24 host_supported: true, 25 cflags: [ 26 "-Wall", 27 "-Wextra", 28 "-Werror", 29 ], 30 cppflags: ["-DU_USING_ICU_NAMESPACE=0"], 31 32 target: { 33 darwin: { 34 enabled: false, 35 }, 36 }, 37 min_sdk_version: "S", 38} 39 40cc_defaults { 41 name: "core_native_default_libs", 42 header_libs: ["jni_headers"], 43 shared_libs: [ 44 "libbase", 45 "liblog", 46 "libnativehelper", 47 ], 48 static_libs: ["libnativehelper_compat_libc++"], 49} 50 51cc_library_shared { 52 name: "libjavacore", 53 visibility: [ 54 "//art/build/apex", 55 "//art/runtime", 56 ], 57 apex_available: [ 58 "com.android.art", 59 "com.android.art.debug", 60 ], 61 defaults: [ 62 "core_native_default_flags", 63 "core_native_default_libs", 64 ], 65 srcs: [ 66 ":luni_native_srcs", 67 ], 68 shared_libs: [ 69 "libandroidio", 70 "libcrypto", 71 "libicu", 72 "libexpat", 73 "libz", 74 ], 75 static_libs: [ 76 "libziparchive", 77 ], 78} 79 80cc_library_shared { 81 name: "libandroidio", 82 visibility: [ 83 "//art/build/apex", 84 "//art/build/sdk", 85 "//external/conscrypt", 86 ], 87 apex_available: [ 88 "com.android.art", 89 "com.android.art.debug", 90 ], 91 defaults: [ 92 "core_native_default_flags", 93 ], 94 shared_libs: [ 95 "liblog", 96 ], 97 srcs: [ 98 ":libandroidio_srcs", 99 ], 100 stubs: { 101 symbol_file: "libandroidio.map.txt", 102 versions: ["1"], 103 }, 104} 105 106cc_defaults { 107 name: "libopenjdk_native_defaults", 108 defaults: [ 109 "core_native_default_flags", 110 "core_native_default_libs", 111 ], 112 srcs: [":libopenjdk_native_srcs"], 113 local_include_dirs: [ 114 "luni/src/main/native", 115 ], 116 cflags: [ 117 // TODO(narayan): Prune down this list of exclusions once the underlying 118 // issues have been fixed. Most of these are small changes except for 119 // -Wunused-parameter. 120 "-Wno-unused-parameter", 121 "-Wno-unused-variable", 122 "-Wno-parentheses-equality", 123 "-Wno-constant-logical-operand", 124 "-Wno-sometimes-uninitialized", 125 ], 126 127 shared_libs: [ 128 "libandroidio", 129 "libcrypto", 130 "libicu", 131 "libz", 132 ], 133 static_libs: [ 134 "libfdlibm", 135 ], 136 137 target: { 138 musl: { 139 cflags: [ 140 // Sigh. 141 "-D_LARGEFILE64_SOURCE", 142 "-D_GNU_SOURCE", 143 "-DLINUX", 144 ], 145 }, 146 glibc: { 147 cflags: [ 148 "-D__GLIBC__", 149 // Sigh. 150 "-D_LARGEFILE64_SOURCE", 151 "-D_GNU_SOURCE", 152 "-DLINUX", 153 ], 154 }, 155 android: { 156 shared_libs: [ 157 "libdl_android", 158 ], 159 }, 160 }, 161 162 notice: "ojluni/NOTICE", 163} 164 165cc_library_shared { 166 name: "libopenjdk", 167 visibility: [ 168 "//art/build/apex", 169 ], 170 apex_available: [ 171 "com.android.art", 172 "com.android.art.debug", 173 ], 174 defaults: ["libopenjdk_native_defaults"], 175 shared_libs: [ 176 "libopenjdkjvm", 177 ], 178} 179 180// Debug version of libopenjdk. Depends on libopenjdkjvmd. 181cc_library_shared { 182 name: "libopenjdkd", 183 visibility: [ 184 "//art/build/apex", 185 ], 186 apex_available: [ 187 "com.android.art.debug", 188 ], 189 defaults: ["libopenjdk_native_defaults"], 190 shared_libs: [ 191 "libopenjdkjvmd", 192 ], 193} 194 195// Test JNI library. 196cc_library_shared { 197 name: "libjavacoretests", 198 visibility: [ 199 "//art/build/sdk", 200 "//cts/tests/libcore/luni", 201 ], 202 defaults: ["core_native_default_flags"], 203 host_supported: true, 204 205 srcs: [ 206 "luni/src/test/native/libcore_dalvik_system_JniTest.cpp", 207 "luni/src/test/native/libcore_java_io_FileTest.cpp", 208 "luni/src/test/native/libcore_java_lang_ThreadTest.cpp", 209 "luni/src/test/native/libcore_java_nio_BufferTest.cpp", 210 "luni/src/test/native/libcore_java_time_BionicTzdbConsistencyTest.cpp", 211 "luni/src/test/native/libcore_libcore_util_NativeAllocationRegistryTest.cpp", 212 ], 213 shared_libs: [ 214 "liblog", 215 "libnativehelper", 216 ], 217} 218 219// Set of gtest unit tests. 220cc_test { 221 name: "libjavacore-unit-tests", 222 defaults: ["core_native_default_flags"], 223 224 // TODO(b/172480617): Fix this source dependency from 225 // platform_testing/build/tasks/tests/native_test_list.mk. 226 enabled: true, 227 228 // Add -fno-builtin so that the compiler doesn't attempt to inline 229 // memcpy calls that are not really aligned. 230 cflags: ["-fno-builtin"], 231 srcs: [ 232 "luni/src/test/native/libcore_io_Memory_test.cpp", 233 // libcore_io_Memory_test.cpp includes libcore_io_Memory.cpp which 234 // depends on JniConstants.cpp (but these are not used in the tests). 235 "luni/src/main/native/JniConstants.cpp", 236 ], 237 238 shared_libs: [ 239 "liblog", 240 "libnativehelper", 241 ], 242 243 static_libs: ["libnativehelper_compat_libc++"], 244} 245 246// Set of benchmarks for libjavacore functions. 247cc_benchmark { 248 name: "libjavacore-benchmarks", 249 defaults: ["core_native_default_flags"], 250 251 // TODO(b/172480617): Fix this source dependency from 252 // platform_testing/build/tasks/tests/native_metric_test_list.mk. 253 enabled: true, 254 255 srcs: [ 256 "luni/src/benchmark/native/libcore_io_Memory_bench.cpp", 257 // libcore_io_Memory_bench.cpp includes libcore_io_Memory.cpp which 258 // depends on JniConstants.cpp (but these are not used in the benchmark). 259 "luni/src/main/native/JniConstants.cpp", 260 ], 261 test_suites: ["device-tests"], 262 263 shared_libs: [ 264 "liblog", 265 "libnativehelper", 266 ], 267} 268