blob: c73908d9b4421812cc566dc7296dc7cb9853f7c8 [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",
David Sehr312f3b22018-03-19 08:39:26 -0700144 "dex/method_reference.h",
David Sehr334b9d72018-02-12 18:27:56 -0800145 ],
146 output_extension: "operator_out.cc",
147}
148
David Sehr334b9d72018-02-12 18:27:56 -0800149art_cc_library {
150 name: "libdexfile",
Christopher Ferris0d38e852019-12-11 09:37:19 -0800151 defaults: [
152 "libdexfile_defaults",
153 "libart_nativeunwind_defaults",
154 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700155 target: {
David Srbecky7711c352019-04-10 17:50:12 +0100156 android: {
157 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700158 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100159 ],
160 export_shared_lib_headers: [
161 "libartbase",
162 ],
163 },
164 not_windows: {
165 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700166 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100167 ],
168 export_shared_lib_headers: [
169 "libartbase",
170 ],
171 },
David Sehr10db8fe2018-07-18 11:01:20 -0700172 windows: {
173 enabled: true,
174 shared: {
175 enabled: false,
176 },
David Srbecky7711c352019-04-10 17:50:12 +0100177 static_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700178 "libartbase",
David Srbecky7711c352019-04-10 17:50:12 +0100179 ],
180 export_static_lib_headers: [
181 "libartbase",
182 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700183 },
184 },
Jiyong Park066dd9022019-12-19 02:11:59 +0000185 apex_available: [
186 "com.android.art.release",
187 "com.android.art.debug",
Jiyong Park066dd9022019-12-19 02:11:59 +0000188 ],
David Sehr334b9d72018-02-12 18:27:56 -0800189}
190
David Sehrfcbe15c2018-02-15 09:41:13 -0800191art_cc_library {
192 name: "libdexfiled",
193 defaults: [
194 "art_debug_defaults",
195 "libdexfile_defaults",
196 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700197 target: {
David Srbecky7711c352019-04-10 17:50:12 +0100198 android: {
199 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700200 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100201 ],
202 export_shared_lib_headers: [
203 "libartbased",
204 ],
205 },
206 not_windows: {
207 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700208 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100209 ],
210 export_shared_lib_headers: [
211 "libartbased",
212 ],
213 },
David Sehr10db8fe2018-07-18 11:01:20 -0700214 windows: {
215 enabled: true,
216 shared: {
217 enabled: false,
218 },
David Srbecky7711c352019-04-10 17:50:12 +0100219 static_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700220 "libartbased",
David Srbecky7711c352019-04-10 17:50:12 +0100221 ],
222 export_static_lib_headers: [
223 "libartbased",
224 ],
David Sehr10db8fe2018-07-18 11:01:20 -0700225 },
226 },
Jiyong Park066dd9022019-12-19 02:11:59 +0000227 apex_available: [
228 "com.android.art.debug",
229 ],
David Sehrfcbe15c2018-02-15 09:41:13 -0800230}
231
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000232art_cc_test {
233 name: "art_libdexfile_tests",
234 defaults: [
235 "art_gtest_defaults",
236 ],
237 srcs: [
238 "dex/art_dex_file_loader_test.cc",
239 "dex/class_accessor_test.cc",
240 "dex/code_item_accessors_test.cc",
241 "dex/compact_dex_file_test.cc",
242 "dex/compact_offset_table_test.cc",
243 "dex/descriptors_names_test.cc",
244 "dex/test_dex_file_builder_test.cc",
245 "dex/dex_file_loader_test.cc",
246 "dex/dex_file_verifier_test.cc",
247 "dex/dex_instruction_test.cc",
248 "dex/primitive_test.cc",
249 "dex/string_reference_test.cc",
250 "dex/type_lookup_table_test.cc",
251 "dex/utf_test.cc",
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 Srbecky7711c352019-04-10 17:50:12 +0100317cc_library {
318 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
338cc_library {
339 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.
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000377cc_library {
378 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
David Srbecky883c1342020-05-11 23:30:29 +0000396// The same source file is used in two tests here.
397// Its test target is test-art-{host,target}-gtest-art_libdexfile_support_tests.
Martin Stjernholm750bf042019-01-09 22:51:12 +0000398art_cc_test {
399 name: "art_libdexfile_support_tests",
Roland Levillain61f07162019-06-26 12:44:04 +0100400 defaults: [
401 "art_test_defaults",
402 ],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000403 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000404 test_suites: ["general-tests"],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000405 srcs: [
406 "external/dex_file_supp_test.cc",
407 ],
408 shared_libs: [
409 "libartbase",
410 "libbase",
411 "libdexfile_external",
412 "libdexfile_support",
413 ],
414}
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000415
Martin Stjernholm621afb42019-09-23 22:01:36 +0100416cc_defaults {
417 name: "libdexfile_support_static_defaults",
Martin Stjernholmd3ee98a2019-09-23 16:26:50 +0100418 host_supported: true,
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000419 srcs: [
420 "external/dex_file_supp.cc",
421 ],
422 cflags: ["-DSTATIC_LIB"],
423 // Using whole_static_libs here only as a "poor man's transitivity" kludge.
424 whole_static_libs: [
425 "libbase",
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000426 "liblog",
427 "libz",
428 "libziparchive",
429 ],
430 header_libs: ["libdexfile_external_headers"],
431 export_header_lib_headers: ["libdexfile_external_headers"],
432}
433
Martin Stjernholm621afb42019-09-23 22:01:36 +0100434cc_library_static {
435 name: "libdexfile_support_static",
436 visibility: [
437 "//art:__subpackages__",
Martin Stjernholm2d187192019-10-23 21:52:29 +0100438 // Required for the simpleperf binary in the NDK. No other modules than
439 // //system/extras/simpleperf:simpleperf_ndk are allowed to use it.
Martin Stjernholm621afb42019-09-23 22:01:36 +0100440 "//system/extras/simpleperf",
441 ],
442 defaults: [
443 "libdexfile_static_defaults",
444 "libdexfile_support_static_defaults",
445 ],
446 whole_static_libs: [
447 "libdexfile",
448 "libdexfile_external",
449 ],
450}
451
452cc_library_static {
453 name: "libdexfiled_support_static",
454 defaults: [
455 "libdexfile_support_static_defaults",
456 "libdexfiled_static_defaults",
457 ],
458 whole_static_libs: [
459 "libdexfiled",
460 "libdexfiled_external",
461 ],
462}
463
David Srbecky883c1342020-05-11 23:30:29 +0000464// The same source file is used in two tests here.
465// Its test target is test-art-{host,target}-gtest-art_libdexfile_support_static_tests.
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000466art_cc_test {
467 name: "art_libdexfile_support_static_tests",
468 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000469 test_suites: ["general-tests"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000470 srcs: [
471 "external/dex_file_supp_test.cc",
472 ],
473 static_libs: [
474 "libbase",
475 "libdexfile_support_static",
476 ],
477}