xref: /aosp_15_r20/art/build/README.md (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker# Building the ART Module
2*795d594fSAndroid Build Coastguard Worker
3*795d594fSAndroid Build Coastguard WorkerART is built as a module in the form of an APEX package, `com.android.art.apex`.
4*795d594fSAndroid Build Coastguard WorkerThat package can be installed with `adb install` on a device running Android S
5*795d594fSAndroid Build Coastguard Workeror later. It is also included in the system partition (in the `system/apex`
6*795d594fSAndroid Build Coastguard Workerdirectory) of platform releases, to ensure it is always available.
7*795d594fSAndroid Build Coastguard Worker
8*795d594fSAndroid Build Coastguard WorkerThe recommended way to build the ART Module is to use the `master-art` manifest,
9*795d594fSAndroid Build Coastguard Workerwhich only has the sources and dependencies required for the module.
10*795d594fSAndroid Build Coastguard Worker
11*795d594fSAndroid Build Coastguard WorkerThe ART Module is available as a debug variant, `com.android.art.debug.apex`,
12*795d594fSAndroid Build Coastguard Workerwhich has extra internal consistency checks enabled, and some debug tools. A
13*795d594fSAndroid Build Coastguard Workerdevice cannot have both the non-debug and debug variants installed at once - it
14*795d594fSAndroid Build Coastguard Workermay not boot then.
15*795d594fSAndroid Build Coastguard Worker
16*795d594fSAndroid Build Coastguard Worker`com.google.android.art.apex` (note `.google.`) is the Google signed variant of
17*795d594fSAndroid Build Coastguard Workerthe module. It is also mutually exclusive with the other ones.
18*795d594fSAndroid Build Coastguard Worker
19*795d594fSAndroid Build Coastguard Worker
20*795d594fSAndroid Build Coastguard Worker## Building as a module on `master-art`
21*795d594fSAndroid Build Coastguard Worker
22*795d594fSAndroid Build Coastguard Worker1.  Check out the `master-art` tree:
23*795d594fSAndroid Build Coastguard Worker
24*795d594fSAndroid Build Coastguard Worker    ```
25*795d594fSAndroid Build Coastguard Worker    repo init -b master-art -u <repository url>
26*795d594fSAndroid Build Coastguard Worker    ```
27*795d594fSAndroid Build Coastguard Worker
28*795d594fSAndroid Build Coastguard Worker    See the [Android source access
29*795d594fSAndroid Build Coastguard Worker    instructions](https://source.android.com/setup/build/downloading) for
30*795d594fSAndroid Build Coastguard Worker    further details. Google internal users please see [go/sync](http://go/sync).
31*795d594fSAndroid Build Coastguard Worker
32*795d594fSAndroid Build Coastguard Worker2.  Set up the development environment:
33*795d594fSAndroid Build Coastguard Worker
34*795d594fSAndroid Build Coastguard Worker    See
35*795d594fSAndroid Build Coastguard Worker    [art/test/README.chroot.md](https://android.googlesource.com/platform/art/+/refs/heads/main/test/README.chroot.md)
36*795d594fSAndroid Build Coastguard Worker    for details on how to set up the environment on `master-art`, but the
37*795d594fSAndroid Build Coastguard Worker    `lunch` step can be skipped. Instead use `banchan` to initialize an
38*795d594fSAndroid Build Coastguard Worker    unbundled module build:
39*795d594fSAndroid Build Coastguard Worker
40*795d594fSAndroid Build Coastguard Worker    ```
41*795d594fSAndroid Build Coastguard Worker    source build/envsetup.sh
42*795d594fSAndroid Build Coastguard Worker    banchan com.android.art <arch>
43*795d594fSAndroid Build Coastguard Worker    ```
44*795d594fSAndroid Build Coastguard Worker
45*795d594fSAndroid Build Coastguard Worker    `<arch>` is the device architecture - use `hmm` to see the options.
46*795d594fSAndroid Build Coastguard Worker    Regardless of the device architecture, the build also includes the usual
47*795d594fSAndroid Build Coastguard Worker    host architectures, and 64/32-bit multilib for the 64-bit products.
48*795d594fSAndroid Build Coastguard Worker
49*795d594fSAndroid Build Coastguard Worker    To build the debug variant of the module, specify `com.android.art.debug`
50*795d594fSAndroid Build Coastguard Worker    instead of `com.android.art`. It is also possible to list both.
51*795d594fSAndroid Build Coastguard Worker
52*795d594fSAndroid Build Coastguard Worker3.  Build the module:
53*795d594fSAndroid Build Coastguard Worker
54*795d594fSAndroid Build Coastguard Worker    ```
55*795d594fSAndroid Build Coastguard Worker    m apps_only dist
56*795d594fSAndroid Build Coastguard Worker    ```
57*795d594fSAndroid Build Coastguard Worker
58*795d594fSAndroid Build Coastguard Worker4.  Install the module and reboot:
59*795d594fSAndroid Build Coastguard Worker
60*795d594fSAndroid Build Coastguard Worker    ```
61*795d594fSAndroid Build Coastguard Worker    adb install out/dist/com.android.art.apex
62*795d594fSAndroid Build Coastguard Worker    adb reboot
63*795d594fSAndroid Build Coastguard Worker    ```
64*795d594fSAndroid Build Coastguard Worker
65*795d594fSAndroid Build Coastguard Worker    The name of the APEX file depends on what you passed to `banchan`.
66*795d594fSAndroid Build Coastguard Worker
67*795d594fSAndroid Build Coastguard Worker
68*795d594fSAndroid Build Coastguard Worker## Building as part of the base system image
69*795d594fSAndroid Build Coastguard Worker
70*795d594fSAndroid Build Coastguard WorkerNOTE: This method of building is slated to be obsoleted in favor of the
71*795d594fSAndroid Build Coastguard Workermodule build on `master-art` above (b/172480617).
72*795d594fSAndroid Build Coastguard Worker
73*795d594fSAndroid Build Coastguard Worker1.  Check out a full Android platform tree and lunch the appropriate product the
74*795d594fSAndroid Build Coastguard Worker    normal way.
75*795d594fSAndroid Build Coastguard Worker
76*795d594fSAndroid Build Coastguard Worker2.  Ensure the ART Module is built from source:
77*795d594fSAndroid Build Coastguard Worker
78*795d594fSAndroid Build Coastguard Worker    Active development on ART module happens in `trunk_staging` release
79*795d594fSAndroid Build Coastguard Worker    configuration. Whenever possible, use this configuration for local development.
80*795d594fSAndroid Build Coastguard Worker
81*795d594fSAndroid Build Coastguard Worker    ```
82*795d594fSAndroid Build Coastguard Worker    lunch <product>-trunk_staging-<variant>
83*795d594fSAndroid Build Coastguard Worker    ```
84*795d594fSAndroid Build Coastguard Worker
85*795d594fSAndroid Build Coastguard Worker    Some release configurations use prebuilts of ART module. To verify whether a
86*795d594fSAndroid Build Coastguard Worker    particular release configuration uses ART prebuilts, run the following command
87*795d594fSAndroid Build Coastguard Worker
88*795d594fSAndroid Build Coastguard Worker    ```
89*795d594fSAndroid Build Coastguard Worker    get_build_var RELEASE_APEX_CONTRIBUTIONS_ART
90*795d594fSAndroid Build Coastguard Worker    ```
91*795d594fSAndroid Build Coastguard Worker
92*795d594fSAndroid Build Coastguard Worker    If this returns a non-empty value, it usually means that this release
93*795d594fSAndroid Build Coastguard Worker    configuration uses ART prebuilts. (To verify, you can inspect the `contents` of
94*795d594fSAndroid Build Coastguard Worker    the `apex_contributions` Android.bp module reported by the above command.)
95*795d594fSAndroid Build Coastguard Worker
96*795d594fSAndroid Build Coastguard Worker    For troubleshooting, it might be desirable to build ART from source in that
97*795d594fSAndroid Build Coastguard Worker    release configuration. To do so, please modify the <release>.scl file and unset
98*795d594fSAndroid Build Coastguard Worker    the `RELEASE_APEX_CONTIRBUTIONS_ART` build flag. To determine which .scl files
99*795d594fSAndroid Build Coastguard Worker    are used in the current release configuration, please refer to
100*795d594fSAndroid Build Coastguard Worker    `out/release_config_entrypoint.scl`.
101*795d594fSAndroid Build Coastguard Worker
102*795d594fSAndroid Build Coastguard Worker3.  Build the system image the normal way, for example:
103*795d594fSAndroid Build Coastguard Worker
104*795d594fSAndroid Build Coastguard Worker    ```
105*795d594fSAndroid Build Coastguard Worker    m droid
106*795d594fSAndroid Build Coastguard Worker    ```
107*795d594fSAndroid Build Coastguard Worker
108*795d594fSAndroid Build Coastguard Worker
109*795d594fSAndroid Build Coastguard Worker## Prebuilts
110*795d594fSAndroid Build Coastguard Worker
111*795d594fSAndroid Build Coastguard WorkerPrebuilts are used for the ART Module dependencies that have sources outside the
112*795d594fSAndroid Build Coastguard Worker`master-art` manifest. Conversely the ART Module may be a prebuilt when used in
113*795d594fSAndroid Build Coastguard Workerplatform builds of the base system image.
114*795d594fSAndroid Build Coastguard Worker
115*795d594fSAndroid Build Coastguard WorkerThe locations of the prebuilts are:
116*795d594fSAndroid Build Coastguard Worker
117*795d594fSAndroid Build Coastguard Worker*  `prebuilts/runtime/mainline` for prebuilts and SDKs required to build the ART
118*795d594fSAndroid Build Coastguard Worker   Module.
119*795d594fSAndroid Build Coastguard Worker
120*795d594fSAndroid Build Coastguard Worker   See
121*795d594fSAndroid Build Coastguard Worker   [prebuilts/runtime/mainline/README.md](https://android.googlesource.com/platform/prebuilts/runtime/+/master/mainline/README.md)
122*795d594fSAndroid Build Coastguard Worker   for instructions on how to update them.
123*795d594fSAndroid Build Coastguard Worker
124*795d594fSAndroid Build Coastguard Worker*  `packages/modules/ArtPrebuilt` for the ART Module APEX packages, if present.
125*795d594fSAndroid Build Coastguard Worker
126*795d594fSAndroid Build Coastguard Worker*  `prebuilts/module_sdk/art` for the ART Module SDK and other tools, needed to
127*795d594fSAndroid Build Coastguard Worker   build platform images and other modules that depend on the ART Module.
128