blob: defc30698a074c1e437e3de0c6bef7c712dd8c17 [file] [log] [blame]
Colin Cross09975c32017-08-29 15:01:05 -07001// 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",
Martin Stjernholm7abd1e12021-05-10 20:39:21 +010023 defaults: ["art_module_source_build_defaults"],
Colin Cross09975c32017-08-29 15:01:05 -070024 host_supported: true,
Colin Cross09975c32017-08-29 15:01:05 -070025 cflags: [
26 "-Wall",
27 "-Wextra",
28 "-Werror",
29 ],
Logan Chien568c0bc2018-02-27 16:03:04 +080030 cppflags: ["-DU_USING_ICU_NAMESPACE=0"],
Colin Cross09975c32017-08-29 15:01:05 -070031
32 target: {
33 darwin: {
34 enabled: false,
35 },
36 },
Nicolas Geoffray83f47302021-03-03 22:00:47 +000037 min_sdk_version: "S",
Colin Cross09975c32017-08-29 15:01:05 -070038}
39
40cc_defaults {
41 name: "core_native_default_libs",
Orion Hodson15981542020-04-03 06:47:08 +010042 header_libs: ["jni_headers"],
Colin Cross09975c32017-08-29 15:01:05 -070043 shared_libs: [
Vladimir Marko26a4cb82018-06-07 14:57:30 +000044 "libbase",
Colin Cross09975c32017-08-29 15:01:05 -070045 "liblog",
46 "libnativehelper",
47 ],
Orion Hodson13f17b92021-05-20 21:46:51 +010048 static_libs: ["libnativehelper_compat_libc++"],
Colin Cross09975c32017-08-29 15:01:05 -070049}
50
51cc_library_shared {
52 name: "libjavacore",
Paul Duffinc241d6a2019-06-25 15:40:29 +010053 visibility: [
54 "//art/build/apex",
Martin Stjernholm03033cd2021-06-22 13:32:00 +010055 "//art/runtime",
Paul Duffinc241d6a2019-06-25 15:40:29 +010056 ],
Jiyong Parkb916cac2019-12-19 02:12:09 +000057 apex_available: [
Martin Stjernholmfe8feb62020-10-12 15:11:14 +010058 "com.android.art",
Jiyong Parkb916cac2019-12-19 02:12:09 +000059 "com.android.art.debug",
60 ],
Colin Cross09975c32017-08-29 15:01:05 -070061 defaults: [
62 "core_native_default_flags",
63 "core_native_default_libs",
64 ],
65 srcs: [
66 ":luni_native_srcs",
Colin Cross09975c32017-08-29 15:01:05 -070067 ],
Colin Cross09975c32017-08-29 15:01:05 -070068 shared_libs: [
Pete Bentleyc2d71642019-02-22 17:20:03 +000069 "libandroidio",
Colin Cross09975c32017-08-29 15:01:05 -070070 "libcrypto",
Victor Chang4ab33ea2020-09-22 21:45:30 +010071 "libicu",
Colin Cross09975c32017-08-29 15:01:05 -070072 "libexpat",
Dan Willemsen82553c72017-09-27 16:22:54 -070073 "libz",
Colin Cross09975c32017-08-29 15:01:05 -070074 ],
75 static_libs: [
76 "libziparchive",
Colin Cross09975c32017-08-29 15:01:05 -070077 ],
Colin Cross09975c32017-08-29 15:01:05 -070078}
79
Pete Bentleyc2d71642019-02-22 17:20:03 +000080cc_library_shared {
81 name: "libandroidio",
Paul Duffinc241d6a2019-06-25 15:40:29 +010082 visibility: [
83 "//art/build/apex",
Paul Duffin8aadfc22020-03-05 08:37:41 +000084 "//art/build/sdk",
Jooyung Han826f28e2019-12-16 23:36:50 +090085 "//external/conscrypt",
Paul Duffinc241d6a2019-06-25 15:40:29 +010086 ],
Jiyong Parkb916cac2019-12-19 02:12:09 +000087 apex_available: [
Martin Stjernholmfe8feb62020-10-12 15:11:14 +010088 "com.android.art",
Jiyong Parkb916cac2019-12-19 02:12:09 +000089 "com.android.art.debug",
90 ],
Pete Bentleyc2d71642019-02-22 17:20:03 +000091 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
Colin Cross09975c32017-08-29 15:01:05 -0700106cc_defaults {
107 name: "libopenjdk_native_defaults",
108 defaults: [
109 "core_native_default_flags",
110 "core_native_default_libs",
111 ],
112 srcs: [":libopenjdk_native_srcs"],
Paul Duffind96f57e2019-07-12 16:12:49 +0100113 local_include_dirs: [
114 "luni/src/main/native",
Pete Bentleydfc8ce02019-02-06 10:58:56 +0000115 ],
Colin Cross09975c32017-08-29 15:01:05 -0700116 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",
Colin Cross09975c32017-08-29 15:01:05 -0700125 ],
126
127 shared_libs: [
Pete Bentleyc2d71642019-02-22 17:20:03 +0000128 "libandroidio",
Colin Cross09975c32017-08-29 15:01:05 -0700129 "libcrypto",
Victor Chang4ab33ea2020-09-22 21:45:30 +0100130 "libicu",
Pete Bentleydfc8ce02019-02-06 10:58:56 +0000131 "libz",
Colin Cross09975c32017-08-29 15:01:05 -0700132 ],
Orion Hodson13f17b92021-05-20 21:46:51 +0100133 static_libs: [
134 "libfdlibm",
Orion Hodson13f17b92021-05-20 21:46:51 +0100135 ],
Colin Cross09975c32017-08-29 15:01:05 -0700136
137 target: {
Colin Cross3fd596f2022-03-24 15:45:22 -0700138 musl: {
139 cflags: [
140 // Sigh.
Colin Cross09975c32017-08-29 15:01:05 -0700141 "-D_LARGEFILE64_SOURCE",
142 "-D_GNU_SOURCE",
143 "-DLINUX",
Colin Cross09975c32017-08-29 15:01:05 -0700144 ],
145 },
Colin Cross74f5a592021-09-14 10:57:21 -0700146 glibc: {
Colin Cross3fd596f2022-03-24 15:45:22 -0700147 cflags: [
148 "-D__GLIBC__",
149 // Sigh.
150 "-D_LARGEFILE64_SOURCE",
151 "-D_GNU_SOURCE",
152 "-DLINUX",
153 ],
Colin Cross74f5a592021-09-14 10:57:21 -0700154 },
Victor Change05511a2018-11-26 17:26:39 +0000155 android: {
Victor Chang8f37b142019-10-04 17:15:18 +0100156 shared_libs: [
vichangf52da6d2019-10-08 10:36:13 +0000157 "libdl_android",
Victor Chang8f37b142019-10-04 17:15:18 +0100158 ],
159 },
Colin Cross09975c32017-08-29 15:01:05 -0700160 },
Colin Cross09975c32017-08-29 15:01:05 -0700161}
162
163cc_library_shared {
164 name: "libopenjdk",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100165 visibility: [
166 "//art/build/apex",
167 ],
Jiyong Parkb916cac2019-12-19 02:12:09 +0000168 apex_available: [
Martin Stjernholmfe8feb62020-10-12 15:11:14 +0100169 "com.android.art",
Jiyong Parkb916cac2019-12-19 02:12:09 +0000170 "com.android.art.debug",
171 ],
Colin Cross09975c32017-08-29 15:01:05 -0700172 defaults: ["libopenjdk_native_defaults"],
173 shared_libs: [
174 "libopenjdkjvm",
175 ],
176}
177
178// Debug version of libopenjdk. Depends on libopenjdkjvmd.
179cc_library_shared {
180 name: "libopenjdkd",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100181 visibility: [
182 "//art/build/apex",
183 ],
Jiyong Parkb916cac2019-12-19 02:12:09 +0000184 apex_available: [
185 "com.android.art.debug",
186 ],
Colin Cross09975c32017-08-29 15:01:05 -0700187 defaults: ["libopenjdk_native_defaults"],
188 shared_libs: [
189 "libopenjdkjvmd",
190 ],
191}
192
193// Test JNI library.
194cc_library_shared {
195 name: "libjavacoretests",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100196 visibility: [
Paul Duffin86abe9e2020-01-16 16:55:36 +0000197 "//art/build/sdk",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100198 "//cts/tests/libcore/luni",
199 ],
Colin Cross09975c32017-08-29 15:01:05 -0700200 defaults: ["core_native_default_flags"],
Logan Chien568c0bc2018-02-27 16:03:04 +0800201 host_supported: true,
Colin Cross09975c32017-08-29 15:01:05 -0700202
203 srcs: [
Tobias Thiererd430cc72017-11-01 14:35:40 +0000204 "luni/src/test/native/libcore_dalvik_system_JniTest.cpp",
Colin Cross09975c32017-08-29 15:01:05 -0700205 "luni/src/test/native/libcore_java_io_FileTest.cpp",
Victor Chang8ade7ed2022-07-27 15:32:47 +0100206 "luni/src/test/native/libcore_java_lang_OldStackTraceElementTest.cpp",
Colin Cross09975c32017-08-29 15:01:05 -0700207 "luni/src/test/native/libcore_java_lang_ThreadTest.cpp",
208 "luni/src/test/native/libcore_java_nio_BufferTest.cpp",
Almaz Mingaleevb9b48ee2022-07-07 14:16:27 +0100209 "luni/src/test/native/libcore_java_time_TimeApisConsistencyTest.cpp",
Tobias Thiererd430cc72017-11-01 14:35:40 +0000210 "luni/src/test/native/libcore_libcore_util_NativeAllocationRegistryTest.cpp",
Almaz Mingaleev7e7eeaf2022-07-22 21:38:46 +0100211 "luni/src/test/native/tests_support_AndroidProperties.cpp",
Colin Cross09975c32017-08-29 15:01:05 -0700212 ],
Victor Chang67b3fa62020-03-04 18:01:08 +0000213 shared_libs: [
Victor Chang67b3fa62020-03-04 18:01:08 +0000214 "liblog",
Orion Hodson6272f2d2020-04-28 14:25:16 +0100215 "libnativehelper",
Victor Chang67b3fa62020-03-04 18:01:08 +0000216 ],
Orion Hodsonb13ab912022-11-25 14:04:44 +0000217 static_libs: [
218 "libbase",
219 ],
Colin Cross09975c32017-08-29 15:01:05 -0700220}
221
222// Set of gtest unit tests.
223cc_test {
224 name: "libjavacore-unit-tests",
225 defaults: ["core_native_default_flags"],
226
Martin Stjernholm7abd1e12021-05-10 20:39:21 +0100227 // TODO(b/172480617): Fix this source dependency from
228 // platform_testing/build/tasks/tests/native_test_list.mk.
229 enabled: true,
230
Colin Cross09975c32017-08-29 15:01:05 -0700231 // Add -fno-builtin so that the compiler doesn't attempt to inline
232 // memcpy calls that are not really aligned.
233 cflags: ["-fno-builtin"],
Orion Hodson73caf182020-09-22 17:42:30 +0100234 srcs: [
235 "luni/src/test/native/libcore_io_Memory_test.cpp",
236 // libcore_io_Memory_test.cpp includes libcore_io_Memory.cpp which
237 // depends on JniConstants.cpp (but these are not used in the tests).
238 "luni/src/main/native/JniConstants.cpp",
239 ],
Colin Cross09975c32017-08-29 15:01:05 -0700240
Orion Hodson73caf182020-09-22 17:42:30 +0100241 shared_libs: [
242 "liblog",
243 "libnativehelper",
244 ],
Orion Hodson13f17b92021-05-20 21:46:51 +0100245
246 static_libs: ["libnativehelper_compat_libc++"],
Colin Cross09975c32017-08-29 15:01:05 -0700247}
248
249// Set of benchmarks for libjavacore functions.
250cc_benchmark {
251 name: "libjavacore-benchmarks",
252 defaults: ["core_native_default_flags"],
253
Martin Stjernholm7abd1e12021-05-10 20:39:21 +0100254 // TODO(b/172480617): Fix this source dependency from
255 // platform_testing/build/tasks/tests/native_metric_test_list.mk.
256 enabled: true,
257
Orion Hodson73caf182020-09-22 17:42:30 +0100258 srcs: [
259 "luni/src/benchmark/native/libcore_io_Memory_bench.cpp",
260 // libcore_io_Memory_bench.cpp includes libcore_io_Memory.cpp which
261 // depends on JniConstants.cpp (but these are not used in the benchmark).
262 "luni/src/main/native/JniConstants.cpp",
263 ],
Colin Cross09975c32017-08-29 15:01:05 -0700264 test_suites: ["device-tests"],
265
Orion Hodson73caf182020-09-22 17:42:30 +0100266 shared_libs: [
267 "liblog",
268 "libnativehelper",
269 ],
Colin Cross09975c32017-08-29 15:01:05 -0700270}