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