• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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
17package {
18    // See: http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // all of the 'license_kinds' from "art_license"
21    // to get the below license kinds:
22    //   SPDX-license-identifier-Apache-2.0
23    default_applicable_licenses: ["art_license"],
24}
25
26cc_defaults {
27    name: "libdexfile_defaults",
28    defaults: ["art_defaults"],
29    host_supported: true,
30    tidy_timeout_srcs: [
31        "dex/dex_file_verifier.cc",
32    ],
33    srcs: [
34        "dex/art_dex_file_loader.cc",
35        "dex/compact_dex_file.cc",
36        "dex/compact_offset_table.cc",
37        "dex/descriptors_names.cc",
38        "dex/dex_file.cc",
39        "dex/dex_file_exception_helpers.cc",
40        "dex/dex_file_layout.cc",
41        "dex/dex_file_loader.cc",
42        "dex/dex_file_tracking_registrar.cc",
43        "dex/dex_file_verifier.cc",
44        "dex/dex_instruction.cc",
45        "dex/modifiers.cc",
46        "dex/primitive.cc",
47        "dex/signature.cc",
48        "dex/standard_dex_file.cc",
49        "dex/type_lookup_table.cc",
50        "dex/utf.cc",
51    ],
52    header_libs: [
53        "jni_headers",
54        "libdexfile_external_headers",
55    ],
56    export_header_lib_headers: [
57        "jni_headers",
58        "libdexfile_external_headers",
59    ],
60    static: {
61        cflags: ["-DSTATIC_LIB"],
62    },
63    target: {
64        android: {
65            srcs: [
66                "external/dex_file_ext.cc",
67            ],
68            static_libs: [
69                "libziparchive",
70            ],
71            shared_libs: [
72                // libz provides a stub from platform, shouldn't be statically linked
73                "libz",
74                // For MemMap.
75                "libartpalette",
76                "liblog",
77                // For common macros.
78                "libbase",
79            ],
80            export_shared_lib_headers: [
81                "libbase",
82            ],
83        },
84        not_windows: {
85            srcs: [
86                "external/dex_file_ext.cc",
87            ],
88            shared_libs: [
89                "libziparchive",
90                "libz",
91                // For MemMap.
92                "libartpalette",
93                "liblog",
94                // For common macros.
95                "libbase",
96            ],
97            export_shared_lib_headers: [
98                "libbase",
99            ],
100        },
101        windows: {
102            static_libs: [
103                "libziparchive",
104                "libz",
105                // For MemMap.
106                "libartpalette",
107                "liblog",
108                // For common macros.
109                "libbase",
110            ],
111            export_static_lib_headers: [
112                "libbase",
113            ],
114            cflags: ["-Wno-thread-safety"],
115        },
116        darwin: {
117            enabled: true,
118        },
119    },
120    generated_sources: ["dexfile_operator_srcs"],
121    export_include_dirs: ["."],
122}
123
124cc_defaults {
125    name: "libdexfile_static_base_defaults",
126    whole_static_libs: [
127        "libbase",
128        "liblog",
129        "libz",
130        "libziparchive",
131    ],
132}
133
134cc_defaults {
135    name: "libdexfile_static_defaults",
136    defaults: [
137        "libartbase_static_defaults",
138        "libdexfile_static_base_defaults",
139    ],
140    defaults_visibility: [
141        "//art:__subpackages__",
142    ],
143    whole_static_libs: ["libdexfile"],
144}
145
146cc_defaults {
147    name: "libdexfiled_static_defaults",
148    defaults: [
149        "libartbased_static_defaults",
150        "libdexfile_static_base_defaults",
151    ],
152    whole_static_libs: ["libdexfiled"],
153}
154
155gensrcs {
156    name: "dexfile_operator_srcs",
157    cmd: "$(location generate_operator_out) art/libdexfile $(in) > $(out)",
158    tools: ["generate_operator_out"],
159    srcs: [
160        "dex/dex_file.h",
161        "dex/dex_file_layout.h",
162        "dex/dex_instruction.h",
163        "dex/dex_instruction_utils.h",
164        "dex/invoke_type.h",
165    ],
166    output_extension: "operator_out.cc",
167}
168
169art_cc_library {
170    name: "libdexfile",
171    visibility: [
172        // Allow libdexfile_support users to list this as a runtime_libs
173        // dependency - see comment for libdexfile_support. It shouldn't be used
174        // for any other purpose.
175        "//external/perfetto",
176        "//system/core/debuggerd",
177        "//system/extras/simpleperf",
178        "//system/unwinding/libunwindstack",
179    ],
180    defaults: [
181        "libdexfile_defaults",
182        "libart_nativeunwind_defaults",
183    ],
184    target: {
185        android: {
186            shared_libs: [
187                "libartbase",
188            ],
189            export_shared_lib_headers: [
190                "libartbase",
191            ],
192        },
193        not_windows: {
194            shared_libs: [
195                "libartbase",
196            ],
197            export_shared_lib_headers: [
198                "libartbase",
199            ],
200        },
201        windows: {
202            enabled: true,
203            shared: {
204                enabled: false,
205            },
206            static_libs: [
207                "libartbase",
208            ],
209            export_static_lib_headers: [
210                "libartbase",
211            ],
212        },
213    },
214    apex_available: [
215        "com.android.art",
216        "com.android.art.debug",
217        "test_broken_com.android.art",
218    ],
219
220    // This library is exported in stub form by art-module-sdk, and it brings
221    // with it all the exported headers from libartbase and libbase, many of
222    // which are transitive dependencies outside ART. Those may conflict with
223    // other versions of the headers that the caller is using in their build,
224    // but in this case it's fine since external users only depend on this
225    // through runtime_libs (see comment for libdexfile_support), which doesn't
226    // propagate include dirs.
227    stubs: {
228        symbol_file: "libdexfile.map.txt",
229        versions: ["1"],
230    },
231}
232
233art_cc_library {
234    name: "libdexfiled",
235    defaults: [
236        "art_debug_defaults",
237        "libdexfile_defaults",
238    ],
239    target: {
240        android: {
241            shared_libs: [
242                "libartbased",
243            ],
244            export_shared_lib_headers: [
245                "libartbased",
246            ],
247        },
248        not_windows: {
249            shared_libs: [
250                "libartbased",
251            ],
252            export_shared_lib_headers: [
253                "libartbased",
254            ],
255        },
256        windows: {
257            enabled: true,
258            shared: {
259                enabled: false,
260            },
261            static_libs: [
262                "libartbased",
263            ],
264            export_static_lib_headers: [
265                "libartbased",
266            ],
267        },
268    },
269    apex_available: [
270        "com.android.art.debug",
271        // TODO(b/183882457): This lib doesn't go into com.android.art, but
272        // apex_available lists need to be the same for internal libs to avoid
273        // stubs, and libartd depends on this.
274        "com.android.art",
275    ],
276}
277
278art_cc_defaults {
279    name: "art_libdexfile_tests_defaults",
280    tidy_timeout_srcs: [
281        "dex/dex_file_verifier_test.cc",
282    ],
283    srcs: [
284        "dex/art_dex_file_loader_test.cc",
285        "dex/class_accessor_test.cc",
286        "dex/code_item_accessors_test.cc",
287        "dex/compact_dex_file_test.cc",
288        "dex/compact_offset_table_test.cc",
289        "dex/descriptors_names_test.cc",
290        "dex/test_dex_file_builder_test.cc",
291        "dex/dex_file_loader_test.cc",
292        "dex/dex_file_verifier_test.cc",
293        "dex/dex_instruction_test.cc",
294        "dex/primitive_test.cc",
295        "dex/string_reference_test.cc",
296        "dex/type_lookup_table_test.cc",
297        "dex/utf_test.cc",
298    ],
299    data: [
300        ":art-gtest-jars-GetMethodSignature",
301        ":art-gtest-jars-Lookup",
302        ":art-gtest-jars-Main",
303        ":art-gtest-jars-MainEmptyUncompressed",
304        ":art-gtest-jars-MultiDex",
305        ":art-gtest-jars-Nested",
306        ":art-gtest-jars-VerifierDeps",
307    ],
308    header_libs: ["jni_headers"],
309    static_libs: [
310        "libziparchive",
311    ],
312    shared_libs: [
313        "libunwindstack",
314        "libz", // libziparchive dependency; must be repeated here since it's a static lib.
315    ],
316}
317
318// Version of ART gtest `art_libdexfile_tests` bundled with the ART APEX on target.
319// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
320art_cc_test {
321    name: "art_libdexfile_tests",
322    defaults: [
323        "art_gtest_defaults",
324        "art_libdexfile_tests_defaults",
325    ],
326}
327
328// Standalone version of ART gtest `art_libdexfile_tests`, not bundled with the ART APEX on target.
329art_cc_test {
330    name: "art_standalone_libdexfile_tests",
331    defaults: [
332        "art_standalone_gtest_defaults",
333        "art_libdexfile_tests_defaults",
334    ],
335    test_config: "art_standalone_libdexfile_tests.xml",
336}
337
338cc_library_headers {
339    name: "libdexfile_external_headers",
340    defaults: ["art_defaults"],
341    visibility: ["//visibility:public"],
342    host_supported: true,
343    export_include_dirs: ["external/include"],
344
345    target: {
346        windows: {
347            enabled: true,
348        },
349        darwin: {
350            enabled: true,
351        },
352    },
353
354    apex_available: [
355        "//apex_available:platform",
356        "com.android.art",
357        "com.android.art.debug",
358        "com.android.media",
359        "com.android.runtime",
360    ],
361}
362
363// Make dex_instruction_list.h available for tools/jvmti-agents/titrace
364cc_library_headers {
365    name: "libdexfile_all_headers",
366    defaults: ["art_defaults"],
367    visibility: ["//art:__subpackages__"],
368    host_supported: true,
369    export_include_dirs: ["."],
370
371    apex_available: [
372        "com.android.art",
373        "com.android.art.debug",
374    ],
375}
376
377art_cc_defaults {
378    name: "art_libdexfile_external_tests_defaults",
379    defaults: [
380        "art_module_source_build_defaults",
381    ],
382    test_suites: ["general-tests"],
383    srcs: [
384        "external/dex_file_ext_c_test.c",
385        "external/dex_file_ext_test.cc",
386    ],
387    shared_libs: [
388        "libartbase",
389        "libdexfile",
390    ],
391    header_libs: [
392        "jni_headers",
393        "libdexfile_external_headers",
394    ],
395}
396
397// Version of ART gtest `art_libdexfile_external_tests` bundled with the ART APEX on target.
398// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
399art_cc_test {
400    name: "art_libdexfile_external_tests",
401    defaults: [
402        "art_test_defaults",
403        "art_libdexfile_external_tests_defaults",
404    ],
405}
406
407// Standalone version of ART gtest `art_libdexfile_external_tests`, not bundled with the ART APEX on
408// target.
409art_cc_test {
410    name: "art_standalone_libdexfile_external_tests",
411    defaults: [
412        "art_standalone_test_defaults",
413        "art_libdexfile_external_tests_defaults",
414    ],
415
416    test_config_template: ":art-gtests-target-standalone-cts-template",
417    test_suites: ["cts"], // For backed-by API coverage.
418}
419
420// Support library with a C++ API for accessing the libdexfile API for external
421// (non-ART) users.
422//
423// This library dlopens libdexfile(d).so on first use, so there is no build time
424// dependency on dex file logic. It is therefore safe to use from binaries
425// compiled without dex file support, given they won't encounter any dex file
426// stack frames.
427//
428// IMPORTANT: When adding a static_libs dependency on this library, please
429// remember to also add a corresponding
430//
431//     runtime_libs: ["libdexfile"],
432//
433// That is necessary since Soong doesn't propagate dependencies transitively for
434// static libraries (b/169779783).
435art_cc_library_static {
436    name: "libdexfile_support",
437    defaults: ["art_defaults"],
438    visibility: ["//visibility:public"],
439    host_supported: true,
440    srcs: [
441        "external/dex_file_supp.cc",
442    ],
443    runtime_libs: ["libdexfile"],
444    // Only NDK libs may be dynamic, because this becomes a prebuilt that must work on S+.
445    shared_libs: ["liblog"],
446    header_libs: ["libdexfile_external_headers"],
447    // Do not export any headers outside the ART module - they get included in
448    // the prebuilt SDK and may conflict with different versions of themselves
449    // in the build that the SDK user is using.
450    export_header_lib_headers: ["libdexfile_external_headers"],
451
452    apex_available: [
453        "//apex_available:platform",
454        "com.android.art",
455        "com.android.art.debug",
456        "com.android.media",
457        "com.android.media.swcodec",
458        "com.android.runtime",
459    ],
460}
461
462art_cc_defaults {
463    name: "art_libdexfile_support_tests_defaults",
464    defaults: [
465        "art_module_source_build_defaults",
466    ],
467    test_suites: ["general-tests"],
468    srcs: [
469        "external/dex_file_supp_test.cc",
470    ],
471    shared_libs: [
472        "libartbase",
473        "libbase",
474        "libdexfile",
475        "liblog",
476    ],
477    static_libs: [
478        "libdexfile_support",
479    ],
480}
481
482// Version of ART gtest `art_libdexfile_support_tests` bundled with the ART APEX on target.
483// TODO(b/192274705): Remove this module when the migration to standalone ART gtests is complete.
484art_cc_test {
485    name: "art_libdexfile_support_tests",
486    host_supported: true,
487    defaults: [
488        "art_test_defaults",
489        "art_libdexfile_support_tests_defaults",
490    ],
491}
492
493// Standalone version of ART gtest `art_libdexfile_support_tests`, not bundled with the ART APEX on
494// target.
495art_cc_test {
496    name: "art_standalone_libdexfile_support_tests",
497    defaults: [
498        "art_standalone_test_defaults",
499        "art_libdexfile_support_tests_defaults",
500    ],
501    test_suites: [
502        "mts-art",
503    ],
504}
505
506cc_library_static {
507    name: "libdexfile_support_static",
508    defaults: ["art_defaults"],
509    host_supported: true,
510    srcs: [
511        "external/dex_file_supp.cc",
512    ],
513    cflags: ["-DSTATIC_LIB"],
514    header_libs: ["libdexfile_external_headers"],
515    export_header_lib_headers: ["libdexfile_external_headers"],
516}
517
518cc_defaults {
519    name: "libdexfile_support_static_defaults",
520    defaults: [
521        "libdexfile_static_defaults",
522    ],
523    whole_static_libs: [
524        "libdexfile",
525        "libdexfile_support_static",
526    ],
527}
528
529cc_defaults {
530    name: "libdexfiled_support_static_defaults",
531    defaults: [
532        "libdexfiled_static_defaults",
533    ],
534    whole_static_libs: [
535        "libdexfiled",
536        "libdexfile_support_static",
537    ],
538}
539
540art_cc_test {
541    name: "art_libdexfile_support_static_tests",
542    test_suites: ["general-tests"],
543    defaults: [
544        "art_module_source_build_defaults",
545        "art_test_defaults",
546        "libdexfile_support_static_defaults",
547    ],
548    srcs: [
549        "external/dex_file_supp_test.cc",
550    ],
551}
552
553// For use by external packages allowed to link in static libdexfile_support.
554// This is not allowed in any module that may end up in an APEX or platform
555// image, so visibility is restrictive.
556//
557// TODO(b/169885605): This library brings with it all the exported headers from
558// libdexfile_support_static_defaults into the prebuilt SDK created by
559// art-module-sdk, many of which are transitive dependencies outside ART. Those
560// may conflict with other versions that the caller is using in their build. One
561// way to deal with that is to provide minimal headers without any transitive
562// dependencies on other headers.
563cc_library_static {
564    name: "libdexfile_static",
565    host_supported: true,
566    visibility: [
567        // Required for simpleperf, libsimpleperf_record, and libsimpleperf_report
568        // in the NDK.
569        "//system/extras/simpleperf",
570        "//cts/tests/tests/simpleperf",
571    ],
572    // Using libdexfile_support_static_defaults will link in external libs like
573    // libbase and libz statically as well, which are likely to cause duplicate
574    // copies in the depending module.
575    // TODO(b/169885605): Avoid exposing symbols from those libs.
576    defaults: [
577        "art_defaults",
578        "libdexfile_support_static_defaults",
579    ],
580}
581
582art_cc_test {
583    name: "art_libdexfile_static_tests",
584    defaults: ["art_test_defaults"],
585    test_suites: ["general-tests"],
586    srcs: [
587        "external/dex_file_supp_test.cc",
588    ],
589    static_libs: [
590        "libdexfile_static",
591    ],
592    enabled: false,
593    target: {
594        android: {
595            // Build static test binary on device, to make sure libdexfile_static can be used in
596            // static simpleperf binary in ndk.
597            static_executable: true,
598            static_libs: [
599                "libc",
600            ],
601        },
602        linux: {
603            enabled: true,
604        },
605    },
606    // TODO(b/181740144): Enable a ubsan check to create a dependency on
607    // ubsan_minimal. It's needed to be able to link with the prebuilt
608    // libdexfile_static.a, which contains libziparchive.a, which is
609    // built with some ubsan checks
610    // (https://cs.android.com/android/platform/superproject/+/master:system/libziparchive/Android.bp;l=47-59;drc=c7b498fdf2002194709e40ea58ce39f43684fc14)
611    // that the SDK snapshots currently don't propagate properly for static
612    // libs.
613    sanitize: {
614        misc_undefined: ["shift"],
615    },
616}
617
618filegroup {
619    name: "art_libdexfile_dex_instruction_list_header",
620    srcs: ["dex/dex_instruction_list.h"],
621}
622