xref: /aosp_15_r20/art/build/apex/Android.bp (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1// ART APEX module
2//
3// Contains both the Android Managed Runtime (ART) and the Android Core Library
4// (Libcore).
5
6package {
7    // See: http://go/android-license-faq
8    // A large-scale-change added 'default_applicable_licenses' to import
9    // all of the 'license_kinds' from "art_license"
10    // to get the below license kinds:
11    //   SPDX-license-identifier-Apache-2.0
12    default_applicable_licenses: ["art_license"],
13}
14
15// Create combined library which is used for compiling run-tests.
16// This is much easier than trying to make the test depend on them directly,
17// or than trying to make the test compilation depend on the apex module.
18// Some of the components are only visible here (but not in test Android.bp).
19java_library {
20    name: "art-run-test-bootclasspath",
21    sdk_version: "core_platform",
22    static_libs: [
23        "framework-annotations-lib",
24        // Core Java libraries. This list must be the same as
25        // art-bootclasspath-fragment because it's that which is pulled in
26        // through bootclasspath_fragments in com.android-art-base-defaults.
27        "core-oj",
28        "core-libart",
29        "okhttp",
30        "bouncycastle",
31        "apache-xml",
32    ],
33}
34
35android_app_certificate {
36    name: "com.android.art.certificate",
37    certificate: "com.android.art",
38}
39
40apex_key {
41    name: "com.android.art.key",
42    public_key: "com.android.art.avbpubkey",
43    private_key: "com.android.art.pem",
44}
45
46linker_config {
47    name: "art-linker-config",
48    src: "linker.config.json",
49    installable: false,
50}
51
52prebuilt_etc {
53    name: "com.android.art.init.rc",
54    src: "art.rc",
55    filename: "init.rc",
56    installable: false,
57}
58
59prebuilt_etc {
60    name: "dirty-image-objects-art",
61    src: "dirty-image-objects",
62    filename: "dirty-image-objects",
63    installable: false,
64}
65
66// Default shared by all ART APEXes.
67apex_defaults {
68    name: "com.android.art-base-defaults",
69    defaults: ["s-launched-apex-module"],
70
71    manifest: "manifest-art.json",
72    key: "com.android.art.key",
73    certificate: ":com.android.art.certificate",
74    bootclasspath_fragments: ["art-bootclasspath-fragment"],
75    systemserverclasspath_fragments: ["art-systemserverclasspath-fragment"],
76    compat_configs: ["libcore-platform-compat-config"],
77    required: [
78        "com.android.i18n",
79    ],
80    prebuilts: [
81        "art-linker-config",
82        "com.android.art.init.rc",
83        "current_sdkinfo",
84        "dirty-image-objects-art",
85    ],
86
87    compile_multilib: "both",
88
89    // Note: ART Golem benchmarking does not use the ART APEX, meaning that
90    // copies of some of these libraries have to be installed in `/system` for
91    // the setup to work properly. This is done by the `standalone-apex-files`
92    // Make phony target (see `art/Android.mk`). If you add libraries to this
93    // list, you may have to also add them to `PRIVATE_ART_APEX_DEPENDENCY_LIBS`
94    // in `art/Android.mk`.
95    native_shared_libs: [
96        // ART
97        // External API (having APEX stubs).
98        "libdexfile",
99        "libnativebridge",
100        "libnativehelper",
101        "libnativeloader",
102        "libsigchain",
103        // These libraries are loaded at runtime from libart (either through
104        // dlopen() or by instructing the user to load with -Xplugin), but they
105        // cannot be runtime_lib dependencies from there because of cyclic
106        // dependencies (b/124505714).
107        "libadbconnection",
108        "libopenjdkjvmti",
109        "libperfetto_hprof",
110        // Likewise libart is loaded at runtime from libnativeloader and also must
111        // be specified explicitly due to cyclic dependencies. However, it's not
112        // listed directly here since test_broken_com.android.art uses a different
113        // implementation.
114
115        // Libcore
116        // External API (having APEX stubs).
117        "libandroidio",
118        // This library is loaded at runtime from libart but cannot be a runtime_lib
119        // dependency from there because of cyclic dependencies (b/124505714).
120        "libopenjdk",
121        // These libraries are internal dependencies in libcore, but they don't get
122        // pulled in automatically into apex_test modules.
123        "libexpat",
124        "libopenjdkjvm",
125    ],
126
127    multilib: {
128        both: {
129            binaries: [
130                "dalvikvm",
131                "dex2oat",
132            ],
133        },
134        first: {
135            binaries: [
136                "art_boot",
137                "art_exec",
138                "artd",
139                "dexdump",
140                "dexlist",
141                "dexopt_chroot_setup",
142                "dexoptanalyzer",
143                "oatdump",
144                "profman",
145            ],
146            jni_libs: [
147                "libartservice",
148            ],
149        },
150    },
151}
152
153// Default values shared by Debug and Testing ART APEXes.
154apex_defaults {
155    name: "com.android.art-devel-defaults",
156    defaults: ["com.android.art-base-defaults"],
157
158    native_shared_libs: [
159        "libadbconnectiond",
160        "libdexfiled",
161        "libopenjdkd",
162        "libopenjdkjvmtid",
163        "libperfetto_hprofd",
164    ],
165
166    multilib: {
167        both: {
168            binaries: [
169                "dex2oatd",
170                "imgdiag",
171                "imgdiagd",
172            ],
173        },
174        first: {
175            binaries: [
176                "dexanalyze",
177                "dexoptanalyzerd",
178                "oatdumpd",
179                "profmand",
180            ],
181        },
182    },
183}
184
185// "Broken" test APEX, only used for testing, including module
186// `libart-broken` instead of `libart`.
187apex_test {
188    name: "test_broken_com.android.art",
189    defaults: ["com.android.art-base-defaults"],
190    manifest: "test_apex_manifest.json",
191    file_contexts: ":com.android.art-file_contexts",
192    installable: false,
193    compressible: false,
194
195    native_shared_libs: ["libart-broken"],
196    unwanted_transitive_deps: ["libart"],
197}
198
199apex_test {
200    name: "test_jitzygote_com.android.art",
201    defaults: ["com.android.art-base-defaults"],
202    manifest: "test_apex_manifest.json",
203    file_contexts: ":com.android.art-file_contexts",
204    installable: false,
205
206    native_shared_libs: ["libart"],
207    multilib: {
208        first: {
209            binaries: ["odrefresh_broken"],
210        },
211    },
212}
213
214// Same as "com.android.art" APEX, but also contains "imgdiag" binary.
215// Used to collect dirty-image-objects.
216apex_test {
217    name: "test_imgdiag_com.android.art",
218    defaults: ["com.android.art-base-defaults"],
219    manifest: "test_apex_manifest.json",
220    file_contexts: ":com.android.art-file_contexts",
221    installable: false,
222
223    native_shared_libs: ["libart"],
224    multilib: {
225        both: {
226            binaries: ["imgdiag"],
227        },
228        first: {
229            binaries: ["odrefresh"],
230        },
231    },
232}
233
234// Release version of the ART APEX module (not containing debug
235// variants nor tools), included in user builds. Also used for
236// storage-constrained devices in userdebug and eng builds.
237apex {
238    name: "com.android.art",
239    defaults: ["com.android.art-base-defaults"],
240
241    native_shared_libs: ["libart"],
242    multilib: {
243        first: {
244            binaries: ["odrefresh"],
245        },
246    },
247
248    visibility: [
249        "//art/build/sdk",
250        "//packages/modules/common/build",
251    ],
252}
253
254// "Debug" version of the ART APEX module (containing both release and
255// debug variants, as well as additional tools), included in userdebug and
256// eng build.
257apex {
258    name: "com.android.art.debug",
259    defaults: ["com.android.art-devel-defaults"],
260    // Use a different manifest for this APEX (which has no prebuilts and is
261    // thus always built from sources), with a high version number that ensures
262    // that these packages can be installed on virtually all Android dessert
263    // releases.
264    manifest: "manifest-art-debug.json",
265
266    native_shared_libs: [
267        "libart",
268        "libartd",
269    ],
270    multilib: {
271        first: {
272            binaries: ["odrefresh"],
273            jni_libs: ["libartserviced"],
274        },
275    },
276
277    visibility: [
278        "//packages/modules/common/build",
279    ],
280}
281
282// ART gtests with dependencies on internal ART APEX libraries.
283art_gtests = [
284    "art_cmdline_tests",
285    "art_compiler_tests",
286    "art_dex2oat_tests",
287    "art_dexanalyze_tests",
288    "art_dexdump_tests",
289    "art_dexlist_tests",
290    "art_disassembler_tests",
291    "art_dexoptanalyzer_tests",
292    "art_imgdiag_tests",
293    "art_libartbase_tests",
294    "art_libdexfile_tests",
295    "art_libdexfile_support_tests",
296    "art_libprofile_tests",
297    "art_oatdump_tests",
298    "art_profman_tests",
299    "art_runtime_tests",
300    "art_sigchain_tests",
301]
302
303// ART gtests for which the "first" version is preferred.
304art_gtests_first = [
305    "art_odrefresh_tests",
306]
307
308// "Testing" version of the ART APEX module (containing both release
309// and debug variants, additional tools, and ART gtests), for testing
310// purposes only.
311apex_test {
312    name: "com.android.art.testing",
313    defaults: ["com.android.art-devel-defaults"],
314    file_contexts: ":com.android.art.debug-file_contexts",
315    tests: art_gtests,
316    binaries: ["signal_dumper"], // Need signal_dumper for run-tests.
317    // Use a different manifest for this APEX (which has no prebuilts and is
318    // thus always built from sources), with a high version number that ensures
319    // that these packages can be installed on virtually all Android dessert
320    // releases.
321    manifest: "manifest-art-debug.json",
322    // Mark this test APEX as non-updatable, as its contains
323    // additional files (used only for testing) that would not pass
324    // dependency checks performed on updatable APEXes (see
325    // go/apex-allowed-deps-error).
326    updatable: false,
327    // Because this APEX is non-updatable, some of its native shared
328    // libraries (implicitly added as dependencies) are eligible to
329    // the symlink optimization. As we want this APEX to be
330    // self-contained (for testing purposes), we want to package
331    // these dependencies in this APEX, instead of symbolic links to
332    // their counterparts on the `system` partition, which may not
333    // even exist, as in the case of `libbacktrace` (see b/232790938
334    // and b/233357459). Marking this APEX as "future updatable"
335    // disables all symlink optimizations for it.
336    future_updatable: true,
337
338    native_shared_libs: [
339        "libart",
340        "libartd",
341    ],
342    multilib: {
343        first: {
344            tests: art_gtests_first,
345            binaries: ["odrefresh"],
346            jni_libs: ["libartserviced"],
347        },
348    },
349}
350
351python_binary_host {
352    name: "art-apex-tester",
353    srcs: ["art_apex_test.py"],
354    main: "art_apex_test.py",
355}
356
357// Genrules so we can run the checker, and empty Java library so that it gets executed.
358
359art_check_apex_gen_stem = "$(location art-apex-tester)" +
360    " --deapexer $(location deapexer)" +
361    " --debugfs $(location debugfs_static)" +
362    " --fsckerofs $(location fsck.erofs)" +
363    " --tmpdir $(genDir)"
364
365// The non-flattened APEXes are always checked, as they are always generated
366// (even when APEX flattening is enabled).
367genrule_defaults {
368    name: "art-check-apex-gen-defaults",
369    tools: [
370        "art-apex-tester",
371        "deapexer",
372        "debugfs_static",
373        "fsck.erofs",
374    ],
375}
376
377cc_defaults {
378    name: "art-check-apex-gen-fakebin-defaults",
379    host_supported: true,
380    device_supported: false,
381
382    target: {
383        darwin: {
384            enabled: false, // No python3.
385        },
386    },
387}
388
389java_genrule {
390    name: "art-check-release-apex-gen",
391    host_supported: true,
392    device_supported: false,
393    defaults: ["art-check-apex-gen-defaults"],
394    device_common_srcs: [":com.android.art"],
395    cmd: art_check_apex_gen_stem +
396        " --flavor release" +
397        " $(in)" +
398        " && touch $(out)" +
399        " && chmod a+x $(out)",
400    out: ["art-check-release-apex-gen.unused"],
401}
402
403cc_prebuilt_binary {
404    name: "art-check-release-apex-gen-fakebin",
405    defaults: ["art-check-apex-gen-fakebin-defaults"],
406    srcs: [":art-check-release-apex-gen"],
407}
408
409java_genrule {
410    name: "art-check-debug-apex-gen",
411    host_supported: true,
412    device_supported: false,
413    defaults: ["art-check-apex-gen-defaults"],
414    device_common_srcs: [":com.android.art.debug"],
415    cmd: art_check_apex_gen_stem +
416        " --flavor debug" +
417        " $(in)" +
418        " && touch $(out)" +
419        " && chmod a+x $(out)",
420    out: ["art-check-debug-apex-gen.unused"],
421}
422
423cc_prebuilt_binary {
424    name: "art-check-debug-apex-gen-fakebin",
425    defaults: ["art-check-apex-gen-fakebin-defaults"],
426    srcs: [":art-check-debug-apex-gen"],
427}
428
429java_genrule {
430    name: "art-check-testing-apex-gen",
431    host_supported: true,
432    device_supported: false,
433    defaults: ["art-check-apex-gen-defaults"],
434    device_common_srcs: [":com.android.art.testing"],
435    cmd: art_check_apex_gen_stem +
436        " --flavor testing" +
437        " $(in)" +
438        " && touch $(out)" +
439        " && chmod a+x $(out)",
440    out: ["art-check-testing-apex-gen.unused"],
441}
442
443cc_prebuilt_binary {
444    name: "art-check-testing-apex-gen-fakebin",
445    defaults: ["art-check-apex-gen-fakebin-defaults"],
446    srcs: [":art-check-testing-apex-gen"],
447}
448
449// A zip containing ART binaries and ART bootclasspath jars.
450// At the time of writing, this is only for Compiler Explorer (https://godbolt.org).
451java_genrule {
452    name: "art_release_zip",
453    srcs: [
454        ":com.android.art",
455    ],
456    common_os_srcs: [
457        ":art-module-host-exports",
458    ],
459    out: [
460        "art_release.zip",
461    ],
462    tools: [
463        "deapexer",
464        "debugfs",
465        "fsck.erofs",
466        "merge_zips",
467        "soong_zip",
468    ],
469    cmd: "$(location deapexer) " +
470        "--debugfs_path $(location debugfs) " +
471        "--fsckerofs_path $(location fsck.erofs) " +
472        "extract $(location :com.android.art) $(genDir)/extracted && " +
473
474        "$(location soong_zip) -o $(out).tmp -P bootjars -j " +
475        "-f $(genDir)/extracted/javalib/core-oj.jar " +
476        "-f $(genDir)/extracted/javalib/core-libart.jar " +
477        "-f $(genDir)/extracted/javalib/okhttp.jar " +
478        "-f $(genDir)/extracted/javalib/bouncycastle.jar " +
479        "-f $(genDir)/extracted/javalib/apache-xml.jar && " +
480
481        "$(location merge_zips) $(out) $(out).tmp $(location :art-module-host-exports)",
482    dist: {
483        targets: ["droidcore"],
484    },
485}
486