blob: 6ce66cd71defcff647fe54f5f31c513cb32aab78 [file] [log] [blame]
David Sehr334b9d72018-02-12 18:27:56 -08001//
2// Copyright (C) 2011 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17cc_defaults {
18 name: "libdexfile_defaults",
19 defaults: ["art_defaults"],
20 host_supported: true,
21 srcs: [
David Sehr1f010162018-05-15 08:59:32 -070022 "dex/art_dex_file_loader.cc",
David Sehr334b9d72018-02-12 18:27:56 -080023 "dex/compact_dex_file.cc",
Mathieu Chartier5e3cfa22018-02-20 16:53:37 -080024 "dex/compact_offset_table.cc",
David Sehr334b9d72018-02-12 18:27:56 -080025 "dex/descriptors_names.cc",
26 "dex/dex_file.cc",
27 "dex/dex_file_exception_helpers.cc",
David Sehrc431b9d2018-03-02 12:01:51 -080028 "dex/dex_file_layout.cc",
David Sehr334b9d72018-02-12 18:27:56 -080029 "dex/dex_file_loader.cc",
30 "dex/dex_file_tracking_registrar.cc",
31 "dex/dex_file_verifier.cc",
32 "dex/dex_instruction.cc",
33 "dex/modifiers.cc",
David Sehr67bf42e2018-02-26 16:43:04 -080034 "dex/primitive.cc",
Andreas Gampead1aa632019-01-02 10:30:54 -080035 "dex/signature.cc",
David Sehr334b9d72018-02-12 18:27:56 -080036 "dex/standard_dex_file.cc",
David Sehr9c4a0152018-04-05 12:23:54 -070037 "dex/type_lookup_table.cc",
David Sehr334b9d72018-02-12 18:27:56 -080038 "dex/utf.cc",
39 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +010040 header_libs: ["jni_headers"],
41 export_header_lib_headers: ["jni_headers"],
David Sehr334b9d72018-02-12 18:27:56 -080042 target: {
43 android: {
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000044 static_libs: [
45 "libziparchive",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000046 ],
David Sehr10db8fe2018-07-18 11:01:20 -070047 shared_libs: [
Jiyong Parkb1c8e162020-05-18 19:04:42 +090048 // libz provides a stub from platform, shouldn't be statically linked
49 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070050 // For MemMap.
51 "libartpalette",
52 "liblog",
53 // For common macros.
54 "libbase",
David Sehr10db8fe2018-07-18 11:01:20 -070055 ],
56 export_shared_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070057 "libbase",
58 ],
David Sehr334b9d72018-02-12 18:27:56 -080059 },
David Sehr10db8fe2018-07-18 11:01:20 -070060 not_windows: {
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000061 shared_libs: [
62 "libziparchive",
63 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070064 // For MemMap.
65 "libartpalette",
66 "liblog",
67 // For common macros.
68 "libbase",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000069 ],
David Sehr10db8fe2018-07-18 11:01:20 -070070 export_shared_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070071 "libbase",
72 ],
73 },
74 windows: {
75 static_libs: [
76 "libziparchive",
77 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070078 // For MemMap.
79 "libartpalette",
80 "liblog",
81 // For common macros.
82 "libbase",
David Sehr10db8fe2018-07-18 11:01:20 -070083 ],
84 export_static_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070085 "libbase",
86 ],
87 cflags: ["-Wno-thread-safety"],
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000088 },
David Srbeckyd53f6062019-03-22 14:55:21 +000089 darwin: {
90 enabled: true,
91 },
David Sehr334b9d72018-02-12 18:27:56 -080092 },
93 generated_sources: ["dexfile_operator_srcs"],
David Sehr334b9d72018-02-12 18:27:56 -080094 export_include_dirs: ["."],
David Sehr334b9d72018-02-12 18:27:56 -080095}
96
Andreas Gampeec5ed062018-01-26 16:20:02 -080097cc_defaults {
98 name: "libdexfile_static_base_defaults",
Martin Stjernholm35f765b2020-09-23 00:38:38 +010099 whole_static_libs: [
Andreas Gampeec5ed062018-01-26 16:20:02 -0800100 "libbase",
Andreas Gampeec5ed062018-01-26 16:20:02 -0800101 "liblog",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +0000102 "libz",
103 "libziparchive",
Andreas Gampeec5ed062018-01-26 16:20:02 -0800104 ],
105}
106
107cc_defaults {
108 name: "libdexfile_static_defaults",
109 defaults: [
110 "libartbase_static_defaults",
111 "libdexfile_static_base_defaults",
112 ],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100113 defaults_visibility: [
114 "//art:__subpackages__",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100115 ],
Martin Stjernholm35f765b2020-09-23 00:38:38 +0100116 whole_static_libs: ["libdexfile"],
Andreas Gampeec5ed062018-01-26 16:20:02 -0800117}
118
119cc_defaults {
120 name: "libdexfiled_static_defaults",
121 defaults: [
122 "libartbased_static_defaults",
123 "libdexfile_static_base_defaults",
124 ],
Martin Stjernholm35f765b2020-09-23 00:38:38 +0100125 whole_static_libs: ["libdexfiled"],
Andreas Gampeec5ed062018-01-26 16:20:02 -0800126}
127
David Sehr334b9d72018-02-12 18:27:56 -0800128gensrcs {
129 name: "dexfile_operator_srcs",
Alex Lightb69d2d32018-02-21 13:37:17 -0800130 cmd: "$(location generate_operator_out) art/libdexfile $(in) > $(out)",
131 tools: ["generate_operator_out"],
David Sehr334b9d72018-02-12 18:27:56 -0800132 srcs: [
133 "dex/dex_file.h",
David Sehrc431b9d2018-03-02 12:01:51 -0800134 "dex/dex_file_layout.h",
David Sehr334b9d72018-02-12 18:27:56 -0800135 "dex/dex_instruction.h",
136 "dex/dex_instruction_utils.h",
137 "dex/invoke_type.h",
138 ],
139 output_extension: "operator_out.cc",
140}
141
David Sehr334b9d72018-02-12 18:27:56 -0800142art_cc_library {
143 name: "libdexfile",
Christopher Ferris0d38e852019-12-11 09:37:19 -0800144 defaults: [
145 "libdexfile_defaults",
146 "libart_nativeunwind_defaults",
147 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700148 target: {
David Srbecky7711c352019-04-10 17:50:12 +0100149 android: {
150 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700151 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100152 ],
153 export_shared_lib_headers: [
154 "libartbase",
155 ],
156 },
157 not_windows: {
158 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700159 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100160 ],
161 export_shared_lib_headers: [
162 "libartbase",
163 ],
164 },
David Sehr10db8fe2018-07-18 11:01:20 -0700165 windows: {
166 enabled: true,
167 shared: {
168 enabled: false,
169 },
David Srbecky7711c352019-04-10 17:50:12 +0100170 static_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700171 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100172 ],
173 export_static_lib_headers: [
174 "libartbase",
175 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700176 },
177 },
Jiyong Park066dd9022019-12-19 02:11:59 +0000178 apex_available: [
179 "com.android.art.release",
180 "com.android.art.debug",
Jiyong Park066dd9022019-12-19 02:11:59 +0000181 ],
David Sehr334b9d72018-02-12 18:27:56 -0800182}
183
David Sehrfcbe15c2018-02-15 09:41:13 -0800184art_cc_library {
185 name: "libdexfiled",
186 defaults: [
187 "art_debug_defaults",
188 "libdexfile_defaults",
189 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700190 target: {
David Srbecky7711c352019-04-10 17:50:12 +0100191 android: {
192 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700193 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100194 ],
195 export_shared_lib_headers: [
196 "libartbased",
197 ],
198 },
199 not_windows: {
200 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700201 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100202 ],
203 export_shared_lib_headers: [
204 "libartbased",
205 ],
206 },
David Sehr10db8fe2018-07-18 11:01:20 -0700207 windows: {
208 enabled: true,
209 shared: {
210 enabled: false,
211 },
David Srbecky7711c352019-04-10 17:50:12 +0100212 static_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700213 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100214 ],
215 export_static_lib_headers: [
216 "libartbased",
217 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700218 },
219 },
Jiyong Park066dd9022019-12-19 02:11:59 +0000220 apex_available: [
221 "com.android.art.debug",
222 ],
David Sehrfcbe15c2018-02-15 09:41:13 -0800223}
224
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000225art_cc_test {
226 name: "art_libdexfile_tests",
227 defaults: [
228 "art_gtest_defaults",
229 ],
230 srcs: [
231 "dex/art_dex_file_loader_test.cc",
232 "dex/class_accessor_test.cc",
233 "dex/code_item_accessors_test.cc",
234 "dex/compact_dex_file_test.cc",
235 "dex/compact_offset_table_test.cc",
236 "dex/descriptors_names_test.cc",
237 "dex/test_dex_file_builder_test.cc",
238 "dex/dex_file_loader_test.cc",
239 "dex/dex_file_verifier_test.cc",
240 "dex/dex_instruction_test.cc",
241 "dex/primitive_test.cc",
242 "dex/string_reference_test.cc",
243 "dex/type_lookup_table_test.cc",
244 "dex/utf_test.cc",
245 ],
David Srbecky4a88a5a2020-05-05 16:21:57 +0100246 data: [
247 ":art-gtest-jars-GetMethodSignature",
248 ":art-gtest-jars-Lookup",
249 ":art-gtest-jars-Main",
250 ":art-gtest-jars-MultiDex",
251 ":art-gtest-jars-Nested",
252 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100253 header_libs: ["jni_headers"],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000254 shared_libs: [
255 "libbacktrace",
256 "libziparchive",
257 ],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000258}
259
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000260cc_library_headers {
261 name: "libdexfile_external_headers",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100262 visibility: ["//visibility:public"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000263 host_supported: true,
264 header_libs: ["libbase_headers"],
265 export_header_lib_headers: ["libbase_headers"],
266 export_include_dirs: ["external/include"],
267
268 target: {
269 windows: {
270 enabled: true,
271 },
272 },
Jiyong Park71f661c2020-04-28 18:20:43 +0900273
274 apex_available: [
275 "//apex_available:platform",
276 "com.android.art.debug",
277 "com.android.art.release",
278 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000279}
280
Paul Duffin4345aac2019-07-17 15:51:54 +0100281// Make dex_instruction_list.h available for tools/jvmti-agents/titrace
282cc_library_headers {
283 name: "libdexfile_all_headers",
284 visibility: ["//art:__subpackages__"],
285 host_supported: true,
286 export_include_dirs: ["."],
Jiyong Park71f661c2020-04-28 18:20:43 +0900287
288 apex_available: [
289 "com.android.art.debug",
290 "com.android.art.release",
291 ],
Paul Duffin4345aac2019-07-17 15:51:54 +0100292}
293
David Srbecky7711c352019-04-10 17:50:12 +0100294cc_defaults {
295 name: "libdexfile_external-defaults",
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000296 host_supported: true,
297 srcs: [
298 "external/dex_file_ext.cc",
299 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100300 header_libs: [
301 "jni_headers",
302 "libdexfile_external_headers",
303 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000304 shared_libs: [
305 "libbase",
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000306 ],
Martin Stjernholm84bf6982019-02-05 15:07:57 +0000307 stubs: {
308 symbol_file: "external/libdexfile_external.map.txt",
309 versions: ["1"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000310 },
Orion Hodson00cb81d2020-04-03 06:47:07 +0100311 export_header_lib_headers: [
312 "jni_headers",
313 "libdexfile_external_headers",
314 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000315}
316
David Srbecky1cf46a32020-06-22 15:39:00 +0100317art_cc_library {
David Srbecky7711c352019-04-10 17:50:12 +0100318 name: "libdexfile_external",
319 defaults: [
320 "art_defaults",
321 "libdexfile_external-defaults",
322 ],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100323 visibility: ["//visibility:public"],
David Srbecky52fc7ab2019-05-03 11:03:52 +0100324 target: {
325 darwin: {
326 enabled: true,
327 },
328 },
David Srbecky7711c352019-04-10 17:50:12 +0100329 shared_libs: [
330 "libdexfile",
331 ],
Jiyong Park066dd9022019-12-19 02:11:59 +0000332 apex_available: [
333 "com.android.art.release",
334 "com.android.art.debug",
Jiyong Park066dd9022019-12-19 02:11:59 +0000335 ],
David Srbecky7711c352019-04-10 17:50:12 +0100336}
337
David Srbecky1cf46a32020-06-22 15:39:00 +0100338art_cc_library {
David Srbecky7711c352019-04-10 17:50:12 +0100339 name: "libdexfiled_external",
340 defaults: [
341 "art_debug_defaults",
342 "libdexfile_external-defaults",
343 ],
David Srbecky52fc7ab2019-05-03 11:03:52 +0100344 target: {
345 darwin: {
346 enabled: true,
347 },
348 },
David Srbecky7711c352019-04-10 17:50:12 +0100349 shared_libs: [
350 "libdexfiled",
351 ],
Jiyong Park066dd9022019-12-19 02:11:59 +0000352 apex_available: [
353 "com.android.art.debug",
354 ],
David Srbecky7711c352019-04-10 17:50:12 +0100355}
356
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000357art_cc_test {
358 name: "art_libdexfile_external_tests",
359 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000360 test_suites: ["general-tests"],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000361 srcs: [
362 "external/dex_file_ext_c_test.c",
363 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100364 header_libs: [
365 "jni_headers",
366 "libdexfile_external_headers",
367 ],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000368}
369
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000370// Support library with a C++ API for accessing the libdexfile API for external
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000371// (non-ART) users.
372//
373// This library dlopens libdexfile_external on first use, so there is no build
374// time dependency on dex file logic. It is therefore safe to use from binaries
375// compiled without dex file support, given they won't encounter any dex file
376// stack frames.
David Srbecky1cf46a32020-06-22 15:39:00 +0100377art_cc_library {
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000378 name: "libdexfile_support",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100379 visibility: ["//visibility:public"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000380 host_supported: true,
381 srcs: [
382 "external/dex_file_supp.cc",
383 ],
Martin Stjernholm80892042020-04-21 00:39:00 +0100384 runtime_libs: ["libdexfile_external"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000385 shared_libs: ["liblog"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000386 header_libs: ["libdexfile_external_headers"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000387 export_header_lib_headers: ["libdexfile_external_headers"],
Jiyong Park71f661c2020-04-28 18:20:43 +0900388
389 apex_available: [
390 "//apex_available:platform",
391 "com.android.art.debug",
392 "com.android.art.release",
393 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000394}
Martin Stjernholm750bf042019-01-09 22:51:12 +0000395
396art_cc_test {
397 name: "art_libdexfile_support_tests",
Roland Levillain61f07162019-06-26 12:44:04 +0100398 defaults: [
399 "art_test_defaults",
400 ],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000401 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000402 test_suites: ["general-tests"],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000403 srcs: [
404 "external/dex_file_supp_test.cc",
405 ],
406 shared_libs: [
407 "libartbase",
408 "libbase",
409 "libdexfile_external",
410 "libdexfile_support",
411 ],
412}
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000413
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100414cc_library_static {
415 name: "libdexfile_support_static",
Martin Stjernholmd3ee98a2019-09-23 16:26:50 +0100416 host_supported: true,
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000417 srcs: [
418 "external/dex_file_supp.cc",
419 ],
420 cflags: ["-DSTATIC_LIB"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000421 header_libs: ["libdexfile_external_headers"],
422 export_header_lib_headers: ["libdexfile_external_headers"],
423}
424
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100425cc_defaults {
426 name: "libdexfile_support_static_defaults",
Martin Stjernholm621afb42019-09-23 22:01:36 +0100427 defaults: [
428 "libdexfile_static_defaults",
Martin Stjernholm621afb42019-09-23 22:01:36 +0100429 ],
Martin Stjernholm35f765b2020-09-23 00:38:38 +0100430 whole_static_libs: [
Martin Stjernholm621afb42019-09-23 22:01:36 +0100431 "libdexfile_external",
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100432 "libdexfile_support_static",
Martin Stjernholm621afb42019-09-23 22:01:36 +0100433 ],
434}
435
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100436cc_defaults {
437 name: "libdexfiled_support_static_defaults",
Martin Stjernholm621afb42019-09-23 22:01:36 +0100438 defaults: [
Martin Stjernholm621afb42019-09-23 22:01:36 +0100439 "libdexfiled_static_defaults",
440 ],
Martin Stjernholm35f765b2020-09-23 00:38:38 +0100441 whole_static_libs: [
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100442 "libdexfile_support_static",
Martin Stjernholm621afb42019-09-23 22:01:36 +0100443 "libdexfiled_external",
444 ],
445}
446
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000447art_cc_test {
448 name: "art_libdexfile_support_static_tests",
449 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000450 test_suites: ["general-tests"],
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100451 defaults: ["libdexfile_support_static_defaults"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000452 srcs: [
453 "external/dex_file_supp_test.cc",
454 ],
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100455}
456
Martin Stjernholmcbbc8df2020-09-30 22:02:32 +0100457// For use by external packages allowed to link in static libdexfile_support.
458// This is not allowed in any module that may end up in an APEX or platform
459// image, so visibility is restrictive.
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100460cc_library_static {
461 name: "libdexfile_external_static",
462 host_supported: true,
Martin Stjernholmcbbc8df2020-09-30 22:02:32 +0100463 visibility: [
464 // Required for simpleperf, libsimpleperf_record, and libsimpleperf_report
465 // in the NDK.
466 "//system/extras/simpleperf",
467 "//cts/tests/tests/simpleperf",
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000468 ],
Martin Stjernholmcbbc8df2020-09-30 22:02:32 +0100469 // Using libdexfile_support_static_defaults will link in external libs like
470 // libbase and libz statically as well, which are likely to cause duplicate
471 // copies in the depending module.
472 // TODO(b/169885605): Avoid exposing symbols from those libs.
473 defaults: [
474 "art_defaults",
475 "libdexfile_support_static_defaults",
476 ],
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100477}
478
479art_cc_test {
480 name: "art_libdexfile_external_static_tests",
481 host_supported: true,
482 test_suites: ["general-tests"],
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100483 srcs: [
484 "external/dex_file_supp_test.cc",
485 ],
Martin Stjernholmcbbc8df2020-09-30 22:02:32 +0100486 static_libs: [
487 "libdexfile_external_static",
488 ],
Martin Stjernholm68e5db52020-09-23 20:43:56 +0100489 enabled: false,
490 target: {
491 linux: {
492 enabled: true,
493 },
494 },
495}