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