blob: c3ef0a960b98dc1c0d56eddf06a4dd8c313073b4 [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"],
Martin Stjernholm75b961a2020-05-07 01:45:27 +010020 visibility: [
21 // Visibility for prebuilt dex2oat(d) from the prebuilt of this module.
22 // TODO(b/155921753): Restrict this when prebuilts are in their proper
23 // locations.
24 "//prebuilts:__subpackages__",
25 ],
David Sehr334b9d72018-02-12 18:27:56 -080026 host_supported: true,
27 srcs: [
David Sehr1f010162018-05-15 08:59:32 -070028 "dex/art_dex_file_loader.cc",
David Sehr334b9d72018-02-12 18:27:56 -080029 "dex/compact_dex_file.cc",
Mathieu Chartier5e3cfa22018-02-20 16:53:37 -080030 "dex/compact_offset_table.cc",
David Sehr334b9d72018-02-12 18:27:56 -080031 "dex/descriptors_names.cc",
32 "dex/dex_file.cc",
33 "dex/dex_file_exception_helpers.cc",
David Sehrc431b9d2018-03-02 12:01:51 -080034 "dex/dex_file_layout.cc",
David Sehr334b9d72018-02-12 18:27:56 -080035 "dex/dex_file_loader.cc",
36 "dex/dex_file_tracking_registrar.cc",
37 "dex/dex_file_verifier.cc",
38 "dex/dex_instruction.cc",
39 "dex/modifiers.cc",
David Sehr67bf42e2018-02-26 16:43:04 -080040 "dex/primitive.cc",
Andreas Gampead1aa632019-01-02 10:30:54 -080041 "dex/signature.cc",
David Sehr334b9d72018-02-12 18:27:56 -080042 "dex/standard_dex_file.cc",
David Sehr9c4a0152018-04-05 12:23:54 -070043 "dex/type_lookup_table.cc",
David Sehr334b9d72018-02-12 18:27:56 -080044 "dex/utf.cc",
45 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +010046 header_libs: ["jni_headers"],
47 export_header_lib_headers: ["jni_headers"],
David Sehr334b9d72018-02-12 18:27:56 -080048 target: {
49 android: {
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000050 static_libs: [
51 "libziparchive",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000052 ],
David Sehr10db8fe2018-07-18 11:01:20 -070053 shared_libs: [
Jiyong Parkb1c8e162020-05-18 19:04:42 +090054 // libz provides a stub from platform, shouldn't be statically linked
55 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070056 // For MemMap.
57 "libartpalette",
58 "liblog",
59 // For common macros.
60 "libbase",
David Sehr10db8fe2018-07-18 11:01:20 -070061 ],
62 export_shared_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070063 "libbase",
64 ],
David Sehr334b9d72018-02-12 18:27:56 -080065 },
David Sehr10db8fe2018-07-18 11:01:20 -070066 not_windows: {
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000067 shared_libs: [
68 "libziparchive",
69 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070070 // For MemMap.
71 "libartpalette",
72 "liblog",
73 // For common macros.
74 "libbase",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000075 ],
David Sehr10db8fe2018-07-18 11:01:20 -070076 export_shared_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070077 "libbase",
78 ],
79 },
80 windows: {
81 static_libs: [
82 "libziparchive",
83 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070084 // For MemMap.
85 "libartpalette",
86 "liblog",
87 // For common macros.
88 "libbase",
David Sehr10db8fe2018-07-18 11:01:20 -070089 ],
90 export_static_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070091 "libbase",
92 ],
93 cflags: ["-Wno-thread-safety"],
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000094 },
David Srbeckyd53f6062019-03-22 14:55:21 +000095 darwin: {
96 enabled: true,
97 },
David Sehr334b9d72018-02-12 18:27:56 -080098 },
99 generated_sources: ["dexfile_operator_srcs"],
David Sehr334b9d72018-02-12 18:27:56 -0800100 export_include_dirs: ["."],
David Sehr334b9d72018-02-12 18:27:56 -0800101}
102
Andreas Gampeec5ed062018-01-26 16:20:02 -0800103cc_defaults {
104 name: "libdexfile_static_base_defaults",
105 static_libs: [
106 "libbase",
Andreas Gampeec5ed062018-01-26 16:20:02 -0800107 "liblog",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +0000108 "libz",
109 "libziparchive",
Andreas Gampeec5ed062018-01-26 16:20:02 -0800110 ],
111}
112
113cc_defaults {
114 name: "libdexfile_static_defaults",
115 defaults: [
116 "libartbase_static_defaults",
117 "libdexfile_static_base_defaults",
118 ],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100119 defaults_visibility: [
120 "//art:__subpackages__",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100121 ],
Andreas Gampeec5ed062018-01-26 16:20:02 -0800122 static_libs: ["libdexfile"],
123}
124
125cc_defaults {
126 name: "libdexfiled_static_defaults",
127 defaults: [
128 "libartbased_static_defaults",
129 "libdexfile_static_base_defaults",
130 ],
131 static_libs: ["libdexfiled"],
132}
133
David Sehr334b9d72018-02-12 18:27:56 -0800134gensrcs {
135 name: "dexfile_operator_srcs",
Alex Lightb69d2d32018-02-21 13:37:17 -0800136 cmd: "$(location generate_operator_out) art/libdexfile $(in) > $(out)",
137 tools: ["generate_operator_out"],
David Sehr334b9d72018-02-12 18:27:56 -0800138 srcs: [
139 "dex/dex_file.h",
David Sehrc431b9d2018-03-02 12:01:51 -0800140 "dex/dex_file_layout.h",
David Sehr334b9d72018-02-12 18:27:56 -0800141 "dex/dex_instruction.h",
142 "dex/dex_instruction_utils.h",
143 "dex/invoke_type.h",
144 ],
145 output_extension: "operator_out.cc",
146}
147
David Sehr334b9d72018-02-12 18:27:56 -0800148art_cc_library {
149 name: "libdexfile",
Christopher Ferris0d38e852019-12-11 09:37:19 -0800150 defaults: [
151 "libdexfile_defaults",
152 "libart_nativeunwind_defaults",
153 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700154 target: {
David Srbecky7711c352019-04-10 17:50:12 +0100155 android: {
156 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700157 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100158 ],
159 export_shared_lib_headers: [
160 "libartbase",
161 ],
162 },
163 not_windows: {
164 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700165 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100166 ],
167 export_shared_lib_headers: [
168 "libartbase",
169 ],
170 },
David Sehr10db8fe2018-07-18 11:01:20 -0700171 windows: {
172 enabled: true,
173 shared: {
174 enabled: false,
175 },
David Srbecky7711c352019-04-10 17:50:12 +0100176 static_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700177 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100178 ],
179 export_static_lib_headers: [
180 "libartbase",
181 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700182 },
183 },
Jiyong Park066dd9022019-12-19 02:11:59 +0000184 apex_available: [
185 "com.android.art.release",
186 "com.android.art.debug",
Jiyong Park066dd9022019-12-19 02:11:59 +0000187 ],
David Sehr334b9d72018-02-12 18:27:56 -0800188}
189
David Sehrfcbe15c2018-02-15 09:41:13 -0800190art_cc_library {
191 name: "libdexfiled",
192 defaults: [
193 "art_debug_defaults",
194 "libdexfile_defaults",
195 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700196 target: {
David Srbecky7711c352019-04-10 17:50:12 +0100197 android: {
198 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700199 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100200 ],
201 export_shared_lib_headers: [
202 "libartbased",
203 ],
204 },
205 not_windows: {
206 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700207 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100208 ],
209 export_shared_lib_headers: [
210 "libartbased",
211 ],
212 },
David Sehr10db8fe2018-07-18 11:01:20 -0700213 windows: {
214 enabled: true,
215 shared: {
216 enabled: false,
217 },
David Srbecky7711c352019-04-10 17:50:12 +0100218 static_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700219 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100220 ],
221 export_static_lib_headers: [
222 "libartbased",
223 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700224 },
225 },
Jiyong Park066dd9022019-12-19 02:11:59 +0000226 apex_available: [
227 "com.android.art.debug",
228 ],
David Sehrfcbe15c2018-02-15 09:41:13 -0800229}
230
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000231art_cc_test {
232 name: "art_libdexfile_tests",
233 defaults: [
234 "art_gtest_defaults",
235 ],
236 srcs: [
237 "dex/art_dex_file_loader_test.cc",
238 "dex/class_accessor_test.cc",
239 "dex/code_item_accessors_test.cc",
240 "dex/compact_dex_file_test.cc",
241 "dex/compact_offset_table_test.cc",
242 "dex/descriptors_names_test.cc",
243 "dex/test_dex_file_builder_test.cc",
244 "dex/dex_file_loader_test.cc",
245 "dex/dex_file_verifier_test.cc",
246 "dex/dex_instruction_test.cc",
247 "dex/primitive_test.cc",
248 "dex/string_reference_test.cc",
249 "dex/type_lookup_table_test.cc",
250 "dex/utf_test.cc",
251 ],
David Srbecky4a88a5a2020-05-05 16:21:57 +0100252 data: [
253 ":art-gtest-jars-GetMethodSignature",
254 ":art-gtest-jars-Lookup",
255 ":art-gtest-jars-Main",
256 ":art-gtest-jars-MultiDex",
257 ":art-gtest-jars-Nested",
258 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100259 header_libs: ["jni_headers"],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000260 shared_libs: [
261 "libbacktrace",
262 "libziparchive",
263 ],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000264}
265
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000266cc_library_headers {
267 name: "libdexfile_external_headers",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100268 visibility: ["//visibility:public"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000269 host_supported: true,
270 header_libs: ["libbase_headers"],
271 export_header_lib_headers: ["libbase_headers"],
272 export_include_dirs: ["external/include"],
273
274 target: {
275 windows: {
276 enabled: true,
277 },
278 },
Jiyong Park71f661c2020-04-28 18:20:43 +0900279
280 apex_available: [
281 "//apex_available:platform",
282 "com.android.art.debug",
283 "com.android.art.release",
284 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000285}
286
Paul Duffin4345aac2019-07-17 15:51:54 +0100287// Make dex_instruction_list.h available for tools/jvmti-agents/titrace
288cc_library_headers {
289 name: "libdexfile_all_headers",
290 visibility: ["//art:__subpackages__"],
291 host_supported: true,
292 export_include_dirs: ["."],
Jiyong Park71f661c2020-04-28 18:20:43 +0900293
294 apex_available: [
295 "com.android.art.debug",
296 "com.android.art.release",
297 ],
Paul Duffin4345aac2019-07-17 15:51:54 +0100298}
299
David Srbecky7711c352019-04-10 17:50:12 +0100300cc_defaults {
301 name: "libdexfile_external-defaults",
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000302 host_supported: true,
303 srcs: [
304 "external/dex_file_ext.cc",
305 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100306 header_libs: [
307 "jni_headers",
308 "libdexfile_external_headers",
309 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000310 shared_libs: [
311 "libbase",
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000312 ],
Martin Stjernholm84bf6982019-02-05 15:07:57 +0000313 stubs: {
314 symbol_file: "external/libdexfile_external.map.txt",
315 versions: ["1"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000316 },
Orion Hodson00cb81d2020-04-03 06:47:07 +0100317 export_header_lib_headers: [
318 "jni_headers",
319 "libdexfile_external_headers",
320 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000321}
322
David Srbecky1cf46a32020-06-22 15:39:00 +0100323art_cc_library {
David Srbecky7711c352019-04-10 17:50:12 +0100324 name: "libdexfile_external",
325 defaults: [
326 "art_defaults",
327 "libdexfile_external-defaults",
328 ],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100329 visibility: ["//visibility:public"],
David Srbecky52fc7ab2019-05-03 11:03:52 +0100330 target: {
331 darwin: {
332 enabled: true,
333 },
334 },
David Srbecky7711c352019-04-10 17:50:12 +0100335 shared_libs: [
336 "libdexfile",
337 ],
Jiyong Park066dd9022019-12-19 02:11:59 +0000338 apex_available: [
339 "com.android.art.release",
340 "com.android.art.debug",
Jiyong Park066dd9022019-12-19 02:11:59 +0000341 ],
David Srbecky7711c352019-04-10 17:50:12 +0100342}
343
David Srbecky1cf46a32020-06-22 15:39:00 +0100344art_cc_library {
David Srbecky7711c352019-04-10 17:50:12 +0100345 name: "libdexfiled_external",
346 defaults: [
347 "art_debug_defaults",
348 "libdexfile_external-defaults",
349 ],
David Srbecky52fc7ab2019-05-03 11:03:52 +0100350 target: {
351 darwin: {
352 enabled: true,
353 },
354 },
David Srbecky7711c352019-04-10 17:50:12 +0100355 shared_libs: [
356 "libdexfiled",
357 ],
Jiyong Park066dd9022019-12-19 02:11:59 +0000358 apex_available: [
359 "com.android.art.debug",
360 ],
David Srbecky7711c352019-04-10 17:50:12 +0100361}
362
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000363art_cc_test {
364 name: "art_libdexfile_external_tests",
365 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000366 test_suites: ["general-tests"],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000367 srcs: [
368 "external/dex_file_ext_c_test.c",
369 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100370 header_libs: [
371 "jni_headers",
372 "libdexfile_external_headers",
373 ],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000374}
375
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000376// Support library with a C++ API for accessing the libdexfile API for external
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000377// (non-ART) users.
378//
379// This library dlopens libdexfile_external on first use, so there is no build
380// time dependency on dex file logic. It is therefore safe to use from binaries
381// compiled without dex file support, given they won't encounter any dex file
382// stack frames.
David Srbecky1cf46a32020-06-22 15:39:00 +0100383art_cc_library {
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000384 name: "libdexfile_support",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100385 visibility: ["//visibility:public"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000386 host_supported: true,
387 srcs: [
388 "external/dex_file_supp.cc",
389 ],
Martin Stjernholm80892042020-04-21 00:39:00 +0100390 runtime_libs: ["libdexfile_external"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000391 shared_libs: ["liblog"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000392 header_libs: ["libdexfile_external_headers"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000393 export_header_lib_headers: ["libdexfile_external_headers"],
Jiyong Park71f661c2020-04-28 18:20:43 +0900394
395 apex_available: [
396 "//apex_available:platform",
397 "com.android.art.debug",
398 "com.android.art.release",
399 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000400}
Martin Stjernholm750bf042019-01-09 22:51:12 +0000401
David Srbecky883c1342020-05-11 23:30:29 +0000402// The same source file is used in two tests here.
403// Its test target is test-art-{host,target}-gtest-art_libdexfile_support_tests.
Martin Stjernholm750bf042019-01-09 22:51:12 +0000404art_cc_test {
405 name: "art_libdexfile_support_tests",
Roland Levillain61f07162019-06-26 12:44:04 +0100406 defaults: [
407 "art_test_defaults",
408 ],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000409 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000410 test_suites: ["general-tests"],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000411 srcs: [
412 "external/dex_file_supp_test.cc",
413 ],
414 shared_libs: [
415 "libartbase",
416 "libbase",
417 "libdexfile_external",
418 "libdexfile_support",
419 ],
420}
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000421
Martin Stjernholm621afb42019-09-23 22:01:36 +0100422cc_defaults {
423 name: "libdexfile_support_static_defaults",
Martin Stjernholmd3ee98a2019-09-23 16:26:50 +0100424 host_supported: true,
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000425 srcs: [
426 "external/dex_file_supp.cc",
427 ],
428 cflags: ["-DSTATIC_LIB"],
Orion Hodson26ab2702020-07-29 09:54:10 +0100429 // Using whole_static_libs here only as an "approximate transitivity" kludge.
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000430 whole_static_libs: [
431 "libbase",
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000432 "liblog",
433 "libz",
434 "libziparchive",
435 ],
436 header_libs: ["libdexfile_external_headers"],
437 export_header_lib_headers: ["libdexfile_external_headers"],
438}
439
Martin Stjernholm621afb42019-09-23 22:01:36 +0100440cc_library_static {
441 name: "libdexfile_support_static",
442 visibility: [
443 "//art:__subpackages__",
Martin Stjernholm2d187192019-10-23 21:52:29 +0100444 // Required for the simpleperf binary in the NDK. No other modules than
445 // //system/extras/simpleperf:simpleperf_ndk are allowed to use it.
Martin Stjernholm621afb42019-09-23 22:01:36 +0100446 "//system/extras/simpleperf",
Dan Willemsen3255f502020-06-04 16:29:36 -0700447 "//cts/tests/tests/simpleperf",
Martin Stjernholm621afb42019-09-23 22:01:36 +0100448 ],
449 defaults: [
450 "libdexfile_static_defaults",
451 "libdexfile_support_static_defaults",
452 ],
453 whole_static_libs: [
454 "libdexfile",
455 "libdexfile_external",
456 ],
457}
458
459cc_library_static {
460 name: "libdexfiled_support_static",
461 defaults: [
462 "libdexfile_support_static_defaults",
463 "libdexfiled_static_defaults",
464 ],
465 whole_static_libs: [
466 "libdexfiled",
467 "libdexfiled_external",
468 ],
469}
470
David Srbecky883c1342020-05-11 23:30:29 +0000471// The same source file is used in two tests here.
472// Its test target is test-art-{host,target}-gtest-art_libdexfile_support_static_tests.
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000473art_cc_test {
474 name: "art_libdexfile_support_static_tests",
475 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000476 test_suites: ["general-tests"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000477 srcs: [
478 "external/dex_file_supp_test.cc",
479 ],
480 static_libs: [
481 "libbase",
482 "libdexfile_support_static",
483 ],
484}