1// ART APEX module
2//
3// Contains both the Android Managed Runtime (ART) and the Android Core Library
4// (Libcore).
5
6// Modules listed in LOCAL_REQUIRED_MODULES for module art-runtime in art/Android.mk.
7// - Base requirements (binaries for which both 32- and 64-bit versions are built, if relevant).
8art_runtime_base_binaries_both = [
9    "dalvikvm",
10]
11art_runtime_base_binaries_both_on_device_first_on_host = [
12    "dex2oat",
13]
14// - Base requirements (binaries for which a 32-bit version is preferred on device, but for which
15//   only the "first" (likely 64-bit) version is required on host).
16art_runtime_base_binaries_prefer32_on_device_first_on_host = [
17    "dexoptanalyzer",
18    "profman",
19]
20// - Base requirements (libraries).
21//
22// Note: ART on-device chroot-based testing and benchmarking is not yet using
23// the ART APEX, meaning that copies of some of these libraries have to be
24// installed in `/system` for the ART Buildbot set-up to work properly. This is
25// done by the `standalone-apex-files` Make phony target, used by the ART
26// Buildbot and Golem (see `art/Android.mk`). If you add libraries to this list,
27// you may have to also add them to `PRIVATE_ART_APEX_DEPENDENCY_LIBS` in
28// `art/Android.mk`.
29// TODO(b/121117762): Remove this note when both the ART Buildbot and Golem use
30// the ART APEX.
31art_runtime_base_native_shared_libs = [
32    // External API (having APEX stubs).
33    "libdexfile_external",
34    "libnativebridge",
35    "libnativehelper",
36    "libnativeloader",
37    // libadbconnection is internal and loaded with dlopen(), but it cannot use
38    // "required" because of cyclic dependency (b/124505714).
39    "libadbconnection",
40    // TODO(b/124476339): Clean up the following libraries once "required"
41    // dependencies work with APEX libraries.
42    "libart",
43    "libart-compiler",
44    "libdt_fd_forward",
45    "libdt_socket",
46    "libjdwp",
47    "libnpt",
48    "libopenjdkjvm",
49    "libopenjdkjvmti",
50]
51
52art_runtime_base_native_device_only_shared_libs = [
53    "libperfetto_hprof",
54]
55
56bionic_native_shared_libs = [
57    // External API (having APEX stubs).
58    "libc",
59    "libm",
60    "libdl",
61]
62
63bionic_binaries_both = [
64    "linker",
65]
66
67// - Debug variants (binaries for which a 32-bit version is preferred on device, but for which
68//   only the "first" (likely 64-bit) version is required on host).
69art_runtime_debug_binaries_prefer32_on_device_first_on_host = [
70    "dexoptanalyzerd",
71    "profmand",
72]
73art_runtime_debug_binaries_both_on_device_first_on_host = [
74    "dex2oatd",
75]
76
77// - Debug variants (libraries).
78art_runtime_debug_native_shared_libs = [
79    "libadbconnectiond",
80    "libartd",
81    "libartd-compiler",
82    "libdexfiled_external",
83    "libopenjdkjvmd",
84    "libopenjdkjvmtid",
85]
86
87art_runtime_base_native_device_only_debug_shared_libs = [
88    "libperfetto_hprofd",
89]
90
91// Libraries needed to execute ART run-tests.
92// TODO(b/124476339): When bug 124476339 is fixed, add these libraries as `runtime_libs`
93// dependencies of `libartd-compiler`, and remove `art_runtime_run_test_libs`.
94art_runtime_run_test_libs = [
95    "libart-disassembler",
96    "libartd-disassembler",
97]
98
99// Tools common to both device APEX and host APEX. Derived from art-tools in art/Android.mk.
100art_tools_common_binaries = [
101    "dexdump",
102    "dexlist",
103]
104
105// Tools common to both device and host debug APEXes.
106art_tools_debug_binaries = [
107    "dexanalyze",
108    "dexdiag",
109    "dexlayout",
110    "dexlayoutd",
111]
112
113art_tools_debug_binaries_both = [
114    "imgdiag",
115    "imgdiagd",
116]
117
118// Tools exclusively for the device APEX derived from art-tools in art/Android.mk.
119art_tools_device_only_binaries = [
120    // oatdump cannot link with host linux_bionic due to not using clang lld;
121    // TODO: Make it work with clang lld.
122    "oatdump",
123]
124// Same, but for only for debug packages.
125art_tools_debug_device_only_binaries = [
126    // oatdumpd cannot link with host linux_bionic due to not using clang lld;
127    // TODO: Make it work with clang lld.
128    "oatdumpd",
129]
130
131// Tools exclusively for the host APEX derived from art-tools in art/Android.mk.
132art_tools_host_only_binaries = [
133    // FIXME: Does not work as-is, because `ahat` is defined in tools/ahat/Android.mk
134    // (same issue as for `libart_fake` above).
135    //"ahat",
136    "hprof-conv",
137]
138
139// Core Java libraries.
140libcore_java_libs = [
141    "core-oj",
142    "core-libart",
143    "core-icu4j",
144    "okhttp",
145    "bouncycastle",
146    "apache-xml",
147]
148
149// Native libraries that support the core Java libraries.
150//
151// Note: ART on-device chroot-based testing and benchmarking is not yet using
152// the ART APEX, meaning that copies of some of these libraries have to be
153// installed in `/system` for the ART Buildbot set-up to work properly. This is
154// done by the `standalone-apex-files` Make phony target, used by the ART
155// Buildbot and Golem (see `art/Android.mk`). If you add libraries to this list,
156// you may have to also add them to `PRIVATE_ART_APEX_DEPENDENCY_LIBS` in
157// `art/Android.mk`.
158// TODO(b/121117762): Remove this note when both the ART Buildbot and Golem use
159// the ART APEX.
160libcore_native_shared_libs = [
161    // External API (having APEX stubs).
162    "libandroidicu",
163    "libandroidio",
164    // TODO(b/124476339): Clean up the following libraries once "required"
165    // dependencies work with APEX libraries.
166    "libexpat",
167    "libicui18n",
168    "libicuuc",
169    "libicu_jni",
170    "libjavacore",
171    "libopenjdk",
172]
173libcore_debug_native_shared_libs = [
174    "libopenjdkd",
175]
176
177libcore_native_device_only_shared_libs = [
178    // TODO(b/122876336): Remove libpac.so once it's migrated to Webview.
179    // libpac is used by frameworks, not by ART host.
180    "libpac",
181]
182
183// Temporary library includes for b/123591866 as all libraries are moved into the main art-apex.
184art_runtime_libraries_zipapex = [
185    "libnativebridge",
186    "libnativeloader",
187    "libnativehelper",
188    "libcutils",
189]
190
191android_app_certificate {
192    name: "com.android.art.certificate",
193    certificate: "com.android.art",
194}
195
196apex_key {
197    name: "com.android.art.key",
198    public_key: "com.android.art.avbpubkey",
199    private_key: "com.android.art.pem",
200}
201
202prebuilt_etc {
203    name: "com.android.art.ld.config.txt",
204    src: "ld.config.txt",
205    filename: "ld.config.txt",
206    installable: false,
207}
208
209// Default values shared by device ART APEXes.
210apex_defaults {
211    name: "com.android.art-defaults",
212    compile_multilib: "both",
213    manifest: "manifest-art.json",
214    java_libs: libcore_java_libs,
215    native_shared_libs: art_runtime_base_native_shared_libs +
216        art_runtime_base_native_device_only_shared_libs +
217        libcore_native_device_only_shared_libs +
218        libcore_native_shared_libs,
219    multilib: {
220        both: {
221            binaries: art_runtime_base_binaries_both +
222                art_runtime_base_binaries_both_on_device_first_on_host,
223        },
224        prefer32: {
225            binaries: art_runtime_base_binaries_prefer32_on_device_first_on_host,
226        },
227        first: {
228            binaries: art_tools_common_binaries +
229                art_tools_device_only_binaries,
230        },
231    },
232    prebuilts: ["com.android.art.ld.config.txt"],
233    key: "com.android.art.key",
234    required: [
235        "art_apex_boot_integrity",
236        "com.android.i18n",
237    ],
238}
239
240// Default values shared by (device) Debug and Testing ART APEXes.
241apex_defaults {
242    name: "com.android.art-dev-defaults",
243    defaults: ["com.android.art-defaults"],
244    native_shared_libs: art_runtime_base_native_device_only_debug_shared_libs +
245        art_runtime_run_test_libs +
246        art_runtime_debug_native_shared_libs +
247        libcore_debug_native_shared_libs,
248    multilib: {
249        both: {
250            binaries: art_tools_debug_binaries_both +
251                art_runtime_debug_binaries_both_on_device_first_on_host,
252        },
253        prefer32: {
254            binaries: art_runtime_debug_binaries_prefer32_on_device_first_on_host,
255        },
256        first: {
257            binaries: art_tools_debug_binaries +
258                art_tools_debug_device_only_binaries,
259        },
260    },
261}
262
263// Release version of the ART APEX module (not containing debug
264// variants nor tools), included in user builds. Also used for
265// storage-constrained devices in userdebug and eng builds.
266art_apex {
267    name: "com.android.art.release",
268    defaults: ["com.android.art-defaults"],
269    certificate: ":com.android.art.certificate",
270}
271
272// "Debug" version of the ART APEX module (containing both release and
273// debug variants, as well as additional tools), included in userdebug and
274// eng build.
275art_apex {
276    name: "com.android.art.debug",
277    defaults: ["com.android.art-dev-defaults"],
278    certificate: ":com.android.art.certificate",
279}
280
281// ART gtests with dependencies on internal ART APEX libraries.
282art_gtests = [
283    "art_cmdline_tests",
284    "art_compiler_tests",
285    "art_dex2oat_tests",
286    "art_dexanalyze_tests",
287    "art_dexdiag_tests",
288    "art_dexdump_tests",
289    "art_dexlayout_tests",
290    "art_dexlist_tests",
291    "art_dexoptanalyzer_tests",
292    "art_imgdiag_tests",
293    "art_libartbase_tests",
294    "art_libartpalette_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_compiler_tests",
301    "art_runtime_tests",
302    "art_sigchain_tests",
303]
304
305// "Testing" version of the ART APEX module (containing both release
306// and debug variants, additional tools, and ART gtests), for testing
307// purposes only.
308art_apex_test {
309    name: "com.android.art.testing",
310    defaults: ["com.android.art-dev-defaults"],
311    file_contexts: ":com.android.art.debug-file_contexts",
312    certificate: ":com.android.art.certificate",
313    tests: art_gtests,
314    binaries: ["signal_dumper"], // Need signal_dumper for run-tests.
315}
316
317// TODO: Do this better. art_apex_test_host will disable host builds when
318// HOST_PREFER_32_BIT is set. We cannot simply use com.android.art.debug
319// because binaries have different multilib classes and 'multilib: {}' isn't
320// supported by target: { ... }.
321// See b/120617876 for more information.
322art_apex_test_host {
323    name: "com.android.art.host",
324    compile_multilib: "both",
325    payload_type: "zip",
326    host_supported: true,
327    device_supported: false,
328    manifest: "manifest-art.json",
329    java_libs: libcore_java_libs,
330    ignore_system_library_special_case: true,
331    native_shared_libs: art_runtime_base_native_shared_libs +
332        art_runtime_debug_native_shared_libs +
333        libcore_native_shared_libs +
334        libcore_debug_native_shared_libs +
335        art_runtime_libraries_zipapex +
336        art_runtime_run_test_libs,
337    multilib: {
338        both: {
339            binaries: art_runtime_base_binaries_both +
340                art_tools_debug_binaries_both,
341        },
342        first: {
343            binaries: art_runtime_base_binaries_prefer32_on_device_first_on_host +
344                art_runtime_base_binaries_both_on_device_first_on_host +
345                art_runtime_debug_binaries_prefer32_on_device_first_on_host +
346                art_runtime_debug_binaries_both_on_device_first_on_host +
347                art_tools_common_binaries +
348                art_tools_debug_binaries + // Host APEX is always debug.
349                art_tools_host_only_binaries,
350        },
351    },
352    key: "com.android.art.key",
353    target: {
354        darwin: {
355            enabled: false,
356        },
357        linux_bionic: {
358            enabled: true,
359            multilib: {
360                both: {
361                    native_shared_libs: bionic_native_shared_libs,
362                    binaries: bionic_binaries_both,
363                },
364            },
365        },
366    },
367}
368
369python_binary_host {
370    name: "art-apex-tester",
371    srcs: ["art_apex_test.py"],
372    main: "art_apex_test.py",
373    version: {
374        py2: {
375            enabled: true,
376        },
377        py3: {
378            enabled: false,
379        },
380    },
381}
382
383// Genrules so we can run the checker, and empty Java library so that it gets executed.
384
385art_check_apex_gen_stem = "$(location art-apex-tester)" +
386    " --debugfs $(location debugfs)" +
387    " --tmpdir $(genDir)"
388
389// The non-flattened APEXes are always checked, as they are always generated
390// (even when APEX flattening is enabled).
391genrule_defaults {
392    name: "art-check-apex-gen-defaults",
393    tools: [
394        "art-apex-tester",
395        "debugfs",
396    ],
397}
398
399cc_defaults {
400    name: "art-check-apex-gen-fakebin-defaults",
401    host_supported: true,
402    device_supported: false,
403    target: {
404        darwin: {
405            enabled: false, // No python3.
406        },
407    },
408}
409
410genrule {
411    name: "art-check-release-apex-gen",
412    defaults: ["art-check-apex-gen-defaults"],
413    srcs: [":com.android.art.release"],
414    cmd: art_check_apex_gen_stem +
415        " --flavor release" +
416        " $(in)" +
417        " && touch $(out)",
418    out: ["art-check-release-apex-gen.dummy"],
419}
420
421cc_prebuilt_binary {
422    name: "art-check-release-apex-gen-fakebin",
423    defaults: ["art-check-apex-gen-fakebin-defaults"],
424    srcs: [":art-check-release-apex-gen"],
425}
426
427genrule {
428    name: "art-check-debug-apex-gen",
429    defaults: ["art-check-apex-gen-defaults"],
430    srcs: [":com.android.art.debug"],
431    cmd: art_check_apex_gen_stem +
432        " --flavor debug" +
433        " $(in)" +
434        " && touch $(out)",
435    out: ["art-check-debug-apex-gen.dummy"],
436}
437
438cc_prebuilt_binary {
439    name: "art-check-debug-apex-gen-fakebin",
440    defaults: ["art-check-apex-gen-fakebin-defaults"],
441    srcs: [":art-check-debug-apex-gen"],
442}
443
444genrule {
445    name: "art-check-testing-apex-gen",
446    defaults: ["art-check-apex-gen-defaults"],
447    srcs: [":com.android.art.testing"],
448    cmd: art_check_apex_gen_stem +
449        " --flavor testing" +
450        " $(in)" +
451        " && touch $(out)",
452    out: ["art-check-testing-apex-gen.dummy"],
453}
454
455cc_prebuilt_binary {
456    name: "art-check-testing-apex-gen-fakebin",
457    defaults: ["art-check-apex-gen-fakebin-defaults"],
458    srcs: [":art-check-testing-apex-gen"],
459}
460