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