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