blob: fcfbef351e37a9c6fa1cb84b361b9410e83c7d9b [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",
46 "libz",
47 ],
David Sehr10db8fe2018-07-18 11:01:20 -070048 shared_libs: [
Andreas Gampe0dc93b12019-05-15 10:30:22 -070049 // For MemMap.
50 "libartpalette",
51 "liblog",
52 // For common macros.
53 "libbase",
David Sehr10db8fe2018-07-18 11:01:20 -070054 ],
55 export_shared_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070056 "libbase",
57 ],
David Sehr334b9d72018-02-12 18:27:56 -080058 },
David Sehr10db8fe2018-07-18 11:01:20 -070059 not_windows: {
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000060 shared_libs: [
61 "libziparchive",
62 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070063 // For MemMap.
64 "libartpalette",
65 "liblog",
66 // For common macros.
67 "libbase",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000068 ],
David Sehr10db8fe2018-07-18 11:01:20 -070069 export_shared_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070070 "libbase",
71 ],
72 },
73 windows: {
74 static_libs: [
75 "libziparchive",
76 "libz",
Andreas Gampe0dc93b12019-05-15 10:30:22 -070077 // For MemMap.
78 "libartpalette",
79 "liblog",
80 // For common macros.
81 "libbase",
David Sehr10db8fe2018-07-18 11:01:20 -070082 ],
83 export_static_lib_headers: [
David Sehr10db8fe2018-07-18 11:01:20 -070084 "libbase",
85 ],
86 cflags: ["-Wno-thread-safety"],
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +000087 },
David Srbeckyd53f6062019-03-22 14:55:21 +000088 darwin: {
89 enabled: true,
90 },
David Sehr334b9d72018-02-12 18:27:56 -080091 },
92 generated_sources: ["dexfile_operator_srcs"],
David Sehr334b9d72018-02-12 18:27:56 -080093 export_include_dirs: ["."],
David Sehr334b9d72018-02-12 18:27:56 -080094}
95
Andreas Gampeec5ed062018-01-26 16:20:02 -080096cc_defaults {
97 name: "libdexfile_static_base_defaults",
98 static_libs: [
99 "libbase",
Andreas Gampeec5ed062018-01-26 16:20:02 -0800100 "liblog",
Nicolas Geoffray65ed42a2018-10-30 12:33:04 +0000101 "libz",
102 "libziparchive",
Andreas Gampeec5ed062018-01-26 16:20:02 -0800103 ],
104}
105
106cc_defaults {
107 name: "libdexfile_static_defaults",
108 defaults: [
109 "libartbase_static_defaults",
110 "libdexfile_static_base_defaults",
111 ],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100112 defaults_visibility: [
113 "//art:__subpackages__",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100114 ],
Andreas Gampeec5ed062018-01-26 16:20:02 -0800115 static_libs: ["libdexfile"],
116}
117
118cc_defaults {
119 name: "libdexfiled_static_defaults",
120 defaults: [
121 "libartbased_static_defaults",
122 "libdexfile_static_base_defaults",
123 ],
124 static_libs: ["libdexfiled"],
125}
126
David Sehr334b9d72018-02-12 18:27:56 -0800127gensrcs {
128 name: "dexfile_operator_srcs",
Alex Lightb69d2d32018-02-21 13:37:17 -0800129 cmd: "$(location generate_operator_out) art/libdexfile $(in) > $(out)",
130 tools: ["generate_operator_out"],
David Sehr334b9d72018-02-12 18:27:56 -0800131 srcs: [
132 "dex/dex_file.h",
David Sehrc431b9d2018-03-02 12:01:51 -0800133 "dex/dex_file_layout.h",
David Sehr334b9d72018-02-12 18:27:56 -0800134 "dex/dex_instruction.h",
135 "dex/dex_instruction_utils.h",
136 "dex/invoke_type.h",
David Sehr312f3b22018-03-19 08:39:26 -0700137 "dex/method_reference.h",
David Sehr334b9d72018-02-12 18:27:56 -0800138 ],
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 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100246 header_libs: ["jni_headers"],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000247 shared_libs: [
248 "libbacktrace",
249 "libziparchive",
250 ],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000251}
252
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000253cc_library_headers {
254 name: "libdexfile_external_headers",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100255 visibility: ["//visibility:public"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000256 host_supported: true,
257 header_libs: ["libbase_headers"],
258 export_header_lib_headers: ["libbase_headers"],
259 export_include_dirs: ["external/include"],
260
261 target: {
262 windows: {
263 enabled: true,
264 },
265 },
Jiyong Park71f661c2020-04-28 18:20:43 +0900266
267 apex_available: [
268 "//apex_available:platform",
269 "com.android.art.debug",
270 "com.android.art.release",
271 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000272}
273
Paul Duffin4345aac2019-07-17 15:51:54 +0100274// Make dex_instruction_list.h available for tools/jvmti-agents/titrace
275cc_library_headers {
276 name: "libdexfile_all_headers",
277 visibility: ["//art:__subpackages__"],
278 host_supported: true,
279 export_include_dirs: ["."],
Jiyong Park71f661c2020-04-28 18:20:43 +0900280
281 apex_available: [
282 "com.android.art.debug",
283 "com.android.art.release",
284 ],
Paul Duffin4345aac2019-07-17 15:51:54 +0100285}
286
David Srbecky7711c352019-04-10 17:50:12 +0100287cc_defaults {
288 name: "libdexfile_external-defaults",
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000289 host_supported: true,
290 srcs: [
291 "external/dex_file_ext.cc",
292 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100293 header_libs: [
294 "jni_headers",
295 "libdexfile_external_headers",
296 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000297 shared_libs: [
298 "libbase",
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000299 ],
Martin Stjernholm84bf6982019-02-05 15:07:57 +0000300 stubs: {
301 symbol_file: "external/libdexfile_external.map.txt",
302 versions: ["1"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000303 },
Orion Hodson00cb81d2020-04-03 06:47:07 +0100304 export_header_lib_headers: [
305 "jni_headers",
306 "libdexfile_external_headers",
307 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000308}
309
David Srbecky7711c352019-04-10 17:50:12 +0100310cc_library {
311 name: "libdexfile_external",
312 defaults: [
313 "art_defaults",
314 "libdexfile_external-defaults",
315 ],
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100316 visibility: ["//visibility:public"],
David Srbecky52fc7ab2019-05-03 11:03:52 +0100317 target: {
318 darwin: {
319 enabled: true,
320 },
321 },
David Srbecky7711c352019-04-10 17:50:12 +0100322 shared_libs: [
323 "libdexfile",
324 ],
Jiyong Park066dd9022019-12-19 02:11:59 +0000325 apex_available: [
326 "com.android.art.release",
327 "com.android.art.debug",
Jiyong Park066dd9022019-12-19 02:11:59 +0000328 ],
David Srbecky7711c352019-04-10 17:50:12 +0100329}
330
331cc_library {
332 name: "libdexfiled_external",
333 defaults: [
334 "art_debug_defaults",
335 "libdexfile_external-defaults",
336 ],
David Srbecky52fc7ab2019-05-03 11:03:52 +0100337 target: {
338 darwin: {
339 enabled: true,
340 },
341 },
David Srbecky7711c352019-04-10 17:50:12 +0100342 shared_libs: [
343 "libdexfiled",
344 ],
Jiyong Park066dd9022019-12-19 02:11:59 +0000345 apex_available: [
346 "com.android.art.debug",
347 ],
David Srbecky7711c352019-04-10 17:50:12 +0100348}
349
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000350art_cc_test {
351 name: "art_libdexfile_external_tests",
352 host_supported: true,
Andreas Gampe0dc93b12019-05-15 10:30:22 -0700353 test_per_src: true, // For consistency with other ART gtests.
Martin Stjernholm842555d2020-03-23 14:38:47 +0000354 test_suites: ["general-tests"],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000355 srcs: [
356 "external/dex_file_ext_c_test.c",
357 ],
Orion Hodson00cb81d2020-04-03 06:47:07 +0100358 header_libs: [
359 "jni_headers",
360 "libdexfile_external_headers",
361 ],
Martin Stjernholmfdb2f602019-01-09 14:47:00 +0000362}
363
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000364// Support library with a C++ API for accessing the libdexfile API for external
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000365// (non-ART) users.
366//
367// This library dlopens libdexfile_external on first use, so there is no build
368// time dependency on dex file logic. It is therefore safe to use from binaries
369// compiled without dex file support, given they won't encounter any dex file
370// stack frames.
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000371cc_library {
372 name: "libdexfile_support",
Martin Stjernholmb4abe0a2019-05-17 19:22:55 +0100373 visibility: ["//visibility:public"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000374 host_supported: true,
375 srcs: [
376 "external/dex_file_supp.cc",
377 ],
Martin Stjernholm80892042020-04-21 00:39:00 +0100378 runtime_libs: ["libdexfile_external"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000379 shared_libs: ["liblog"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000380 header_libs: ["libdexfile_external_headers"],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000381 export_header_lib_headers: ["libdexfile_external_headers"],
Jiyong Park71f661c2020-04-28 18:20:43 +0900382
383 apex_available: [
384 "//apex_available:platform",
385 "com.android.art.debug",
386 "com.android.art.release",
387 ],
Martin Stjernholmb3d2e832018-11-15 18:09:35 +0000388}
Martin Stjernholm750bf042019-01-09 22:51:12 +0000389
Martin Stjernholm70ae00d2019-02-15 22:41:14 +0000390// The same source file is used in two tests here, so unlike other ART gtests it
391// doesn't use test_per_src. Its test target is
392// test-art-{host,target}-gtest-art_libdexfile_support_tests.
Martin Stjernholm750bf042019-01-09 22:51:12 +0000393art_cc_test {
394 name: "art_libdexfile_support_tests",
Roland Levillain61f07162019-06-26 12:44:04 +0100395 defaults: [
396 "art_test_defaults",
397 ],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000398 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000399 test_suites: ["general-tests"],
Martin Stjernholm750bf042019-01-09 22:51:12 +0000400 srcs: [
401 "external/dex_file_supp_test.cc",
402 ],
403 shared_libs: [
404 "libartbase",
405 "libbase",
406 "libdexfile_external",
407 "libdexfile_support",
408 ],
409}
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000410
Martin Stjernholm621afb42019-09-23 22:01:36 +0100411cc_defaults {
412 name: "libdexfile_support_static_defaults",
Martin Stjernholmd3ee98a2019-09-23 16:26:50 +0100413 host_supported: true,
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000414 srcs: [
415 "external/dex_file_supp.cc",
416 ],
417 cflags: ["-DSTATIC_LIB"],
418 // Using whole_static_libs here only as a "poor man's transitivity" kludge.
419 whole_static_libs: [
420 "libbase",
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000421 "liblog",
422 "libz",
423 "libziparchive",
424 ],
425 header_libs: ["libdexfile_external_headers"],
426 export_header_lib_headers: ["libdexfile_external_headers"],
427}
428
Martin Stjernholm621afb42019-09-23 22:01:36 +0100429cc_library_static {
430 name: "libdexfile_support_static",
431 visibility: [
432 "//art:__subpackages__",
Martin Stjernholm2d187192019-10-23 21:52:29 +0100433 // Required for the simpleperf binary in the NDK. No other modules than
434 // //system/extras/simpleperf:simpleperf_ndk are allowed to use it.
Martin Stjernholm621afb42019-09-23 22:01:36 +0100435 "//system/extras/simpleperf",
436 ],
437 defaults: [
438 "libdexfile_static_defaults",
439 "libdexfile_support_static_defaults",
440 ],
441 whole_static_libs: [
442 "libdexfile",
443 "libdexfile_external",
444 ],
445}
446
447cc_library_static {
448 name: "libdexfiled_support_static",
449 defaults: [
450 "libdexfile_support_static_defaults",
451 "libdexfiled_static_defaults",
452 ],
453 whole_static_libs: [
454 "libdexfiled",
455 "libdexfiled_external",
456 ],
457}
458
Martin Stjernholm70ae00d2019-02-15 22:41:14 +0000459// The same source file is used in two tests here, so unlike other ART gtests it
460// doesn't use test_per_src. Its test target is
461// test-art-{host,target}-gtest-art_libdexfile_support_static_tests.
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000462art_cc_test {
463 name: "art_libdexfile_support_static_tests",
464 host_supported: true,
Martin Stjernholm842555d2020-03-23 14:38:47 +0000465 test_suites: ["general-tests"],
Martin Stjernholmfe94b1c2019-01-31 17:40:39 +0000466 srcs: [
467 "external/dex_file_supp_test.cc",
468 ],
469 static_libs: [
470 "libbase",
471 "libdexfile_support_static",
472 ],
473}