blob: 0adaf991702dd25008999a84010b16599ea5ff8c [file] [log] [blame]
Colin Cross43f08db2018-11-12 10:13:39 -08001// Copyright 2018 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
Jiakai Zhangca9bc982021-09-09 08:09:41 +000018 "path/filepath"
19 "strings"
20
Colin Cross43f08db2018-11-12 10:13:39 -080021 "android/soong/android"
22 "android/soong/dexpreopt"
23)
24
Jiakai Zhangca9bc982021-09-09 08:09:41 +000025type DexpreopterInterface interface {
Martin Stjernholm6d415272020-01-31 17:10:36 +000026 IsInstallable() bool // Structs that embed dexpreopter must implement this.
27 dexpreoptDisabled(ctx android.BaseModuleContext) bool
Jiakai Zhangca9bc982021-09-09 08:09:41 +000028 DexpreoptBuiltInstalledForApex() []dexpreopterInstall
29 AndroidMkEntriesForApex() []android.AndroidMkEntries
30}
31
32type dexpreopterInstall struct {
33 // A unique name to distinguish an output from others for the same java library module. Usually in
34 // the form of `<arch>-<encoded-path>.odex/vdex/art`.
35 name string
36
37 // The name of the input java module.
38 moduleName string
39
40 // The path to the dexpreopt output on host.
41 outputPathOnHost android.Path
42
43 // The directory on the device for the output to install to.
44 installDirOnDevice android.InstallPath
45
46 // The basename (the last segment of the path) for the output to install as.
47 installFileOnDevice string
48}
49
50// The full module name of the output in the makefile.
51func (install *dexpreopterInstall) FullModuleName() string {
52 return install.moduleName + install.SubModuleName()
53}
54
55// The sub-module name of the output in the makefile (the name excluding the java module name).
56func (install *dexpreopterInstall) SubModuleName() string {
57 return "-dexpreopt-" + install.name
Martin Stjernholm6d415272020-01-31 17:10:36 +000058}
59
Jiakai Zhang6decef92022-01-12 17:56:19 +000060// Returns Make entries for installing the file.
61//
62// This function uses a value receiver rather than a pointer receiver to ensure that the object is
63// safe to use in `android.AndroidMkExtraEntriesFunc`.
64func (install dexpreopterInstall) ToMakeEntries() android.AndroidMkEntries {
65 return android.AndroidMkEntries{
66 Class: "ETC",
67 SubName: install.SubModuleName(),
68 OutputFile: android.OptionalPathForPath(install.outputPathOnHost),
69 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
70 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
71 entries.SetString("LOCAL_MODULE_PATH", install.installDirOnDevice.String())
72 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", install.installFileOnDevice)
73 entries.SetString("LOCAL_NOT_AVAILABLE_FOR_PLATFORM", "false")
74 },
75 },
76 }
77}
78
Colin Cross43f08db2018-11-12 10:13:39 -080079type dexpreopter struct {
80 dexpreoptProperties DexpreoptProperties
81
Colin Cross70dda7e2019-10-01 22:05:35 -070082 installPath android.InstallPath
Jaewoong Jungccbb3932019-04-15 09:48:31 -070083 uncompressedDex bool
84 isSDKLibrary bool
Ulya Trafimovich76b08522021-01-14 17:52:43 +000085 isApp bool
Jaewoong Jungccbb3932019-04-15 09:48:31 -070086 isTest bool
Jaewoong Jungccbb3932019-04-15 09:48:31 -070087 isPresignedPrebuilt bool
Colin Crossfa9bfcd2021-11-10 16:42:38 -080088 preventInstall bool
Colin Cross43f08db2018-11-12 10:13:39 -080089
Ulya Trafimovich8cbc5d22020-11-03 15:15:46 +000090 manifestFile android.Path
Ulya Trafimovich8c35fcf2021-02-17 16:23:28 +000091 statusFile android.WritablePath
Ulya Trafimovich8cbc5d22020-11-03 15:15:46 +000092 enforceUsesLibs bool
93 classLoaderContexts dexpreopt.ClassLoaderContextMap
Colin Cross50ddcc42019-05-16 12:28:22 -070094
Jiakai Zhangca9bc982021-09-09 08:09:41 +000095 // See the `dexpreopt` function for details.
96 builtInstalled string
97 builtInstalledForApex []dexpreopterInstall
Ulya Trafimovich76b08522021-01-14 17:52:43 +000098
Jeongik Chac6246672021-04-08 00:00:19 +090099 // The config is used for two purposes:
100 // - Passing dexpreopt information about libraries from Soong to Make. This is needed when
101 // a <uses-library> is defined in Android.bp, but used in Android.mk (see dex_preopt_config_merger.py).
102 // Note that dexpreopt.config might be needed even if dexpreopt is disabled for the library itself.
103 // - Dexpreopt post-processing (using dexpreopt artifacts from a prebuilt system image to incrementally
104 // dexpreopt another partition).
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000105 configPath android.WritablePath
Colin Cross43f08db2018-11-12 10:13:39 -0800106}
107
108type DexpreoptProperties struct {
109 Dex_preopt struct {
Nicolas Geoffrayc1bf7242019-10-18 14:51:38 +0100110 // If false, prevent dexpreopting. Defaults to true.
Colin Cross43f08db2018-11-12 10:13:39 -0800111 Enabled *bool
112
113 // If true, generate an app image (.art file) for this module.
114 App_image *bool
115
116 // If true, use a checked-in profile to guide optimization. Defaults to false unless
117 // a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR
118 // that matches the name of this module, in which case it is defaulted to true.
119 Profile_guided *bool
120
121 // If set, provides the path to profile relative to the Android.bp file. If not set,
122 // defaults to searching for a file that matches the name of this module in the default
123 // profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found.
Colin Crossde4e4e62019-04-26 10:52:32 -0700124 Profile *string `android:"path"`
Colin Cross43f08db2018-11-12 10:13:39 -0800125 }
126}
127
Ulya Trafimovich6cf2c0c2020-04-24 12:15:20 +0100128func init() {
129 dexpreopt.DexpreoptRunningInSoong = true
130}
131
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000132func isApexVariant(ctx android.BaseModuleContext) bool {
133 apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
134 return !apexInfo.IsForPlatform()
135}
136
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000137func forPrebuiltApex(ctx android.BaseModuleContext) bool {
138 apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
139 return apexInfo.ForPrebuiltApex
140}
141
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000142func moduleName(ctx android.BaseModuleContext) string {
143 // Remove the "prebuilt_" prefix if the module is from a prebuilt because the prefix is not
144 // expected by dexpreopter.
145 return android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName())
146}
147
Martin Stjernholm6d415272020-01-31 17:10:36 +0000148func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
Colin Cross38310bb2021-12-01 10:34:14 -0800149 if !ctx.Device() {
Colin Cross43f08db2018-11-12 10:13:39 -0800150 return true
151 }
152
Colin Cross43f08db2018-11-12 10:13:39 -0800153 if d.isTest {
154 return true
155 }
156
157 if !BoolDefault(d.dexpreoptProperties.Dex_preopt.Enabled, true) {
158 return true
159 }
160
Jiakai Zhang28bc9a82021-12-20 15:08:57 +0000161 // If the module is from a prebuilt APEX, it shouldn't be installable, but it can still be
162 // dexpreopted.
163 if !ctx.Module().(DexpreopterInterface).IsInstallable() && !forPrebuiltApex(ctx) {
Martin Stjernholm6d415272020-01-31 17:10:36 +0000164 return true
165 }
166
Colin Cross38310bb2021-12-01 10:34:14 -0800167 if !android.IsModulePreferred(ctx.Module()) {
168 return true
169 }
170
171 global := dexpreopt.GetGlobalConfig(ctx)
172
173 if global.DisablePreopt {
174 return true
175 }
176
177 if inList(moduleName(ctx), global.DisablePreoptModules) {
Colin Crossdc2da912019-01-05 22:13:05 -0800178 return true
179 }
180
Jiakai Zhang389a6472021-12-14 18:54:06 +0000181 isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx))
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000182 if isApexVariant(ctx) {
183 // Don't preopt APEX variant module unless the module is an APEX system server jar and we are
184 // building the entire system image.
Jiakai Zhang389a6472021-12-14 18:54:06 +0000185 if !isApexSystemServerJar || ctx.Config().UnbundledBuild() {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000186 return true
187 }
188 } else {
189 // Don't preopt the platform variant of an APEX system server jar to avoid conflicts.
Jiakai Zhang389a6472021-12-14 18:54:06 +0000190 if isApexSystemServerJar {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000191 return true
192 }
Yo Chiangdbdf8f92020-01-09 19:00:27 +0800193 }
194
Colin Cross43f08db2018-11-12 10:13:39 -0800195 // TODO: contains no java code
196
197 return false
198}
199
Martin Stjernholm6d415272020-01-31 17:10:36 +0000200func dexpreoptToolDepsMutator(ctx android.BottomUpMutatorContext) {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000201 if d, ok := ctx.Module().(DexpreopterInterface); !ok || d.dexpreoptDisabled(ctx) {
Martin Stjernholm6d415272020-01-31 17:10:36 +0000202 return
203 }
204 dexpreopt.RegisterToolDeps(ctx)
205}
206
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000207func (d *dexpreopter) odexOnSystemOther(ctx android.ModuleContext, installPath android.InstallPath) bool {
208 return dexpreopt.OdexOnSystemOtherByName(moduleName(ctx), android.InstallPathToOnDevicePath(ctx, installPath), dexpreopt.GetGlobalConfig(ctx))
209}
210
211// Returns the install path of the dex jar of a module.
212//
213// Do not rely on `ApexInfo.ApexVariationName` because it can be something like "apex1000", rather
214// than the `name` in the path `/apex/<name>` as suggested in its comment.
215//
216// This function is on a best-effort basis. It cannot handle the case where an APEX jar is not a
217// system server jar, which is fine because we currently only preopt system server jars for APEXes.
218func (d *dexpreopter) getInstallPath(
219 ctx android.ModuleContext, defaultInstallPath android.InstallPath) android.InstallPath {
220 global := dexpreopt.GetGlobalConfig(ctx)
Jiakai Zhang389a6472021-12-14 18:54:06 +0000221 if global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx)) {
222 dexLocation := dexpreopt.GetSystemServerDexLocation(ctx, global, moduleName(ctx))
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000223 return android.PathForModuleInPartitionInstall(ctx, "", strings.TrimPrefix(dexLocation, "/"))
224 }
225 if !d.dexpreoptDisabled(ctx) && isApexVariant(ctx) &&
226 filepath.Base(defaultInstallPath.PartitionDir()) != "apex" {
227 ctx.ModuleErrorf("unable to get the install path of the dex jar for dexpreopt")
228 }
229 return defaultInstallPath
Nicolas Geoffrayfa6e9ec2019-02-12 13:12:16 +0000230}
231
Paul Duffin612e6102021-02-02 13:38:13 +0000232func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.WritablePath) {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000233 global := dexpreopt.GetGlobalConfig(ctx)
234
Martin Stjernholm6d415272020-01-31 17:10:36 +0000235 // TODO(b/148690468): The check on d.installPath is to bail out in cases where
236 // the dexpreopter struct hasn't been fully initialized before we're called,
237 // e.g. in aar.go. This keeps the behaviour that dexpreopting is effectively
238 // disabled, even if installable is true.
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000239 if d.installPath.Base() == "." {
240 return
241 }
242
243 dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath)
244
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000245 providesUsesLib := moduleName(ctx)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000246 if ulib, ok := ctx.Module().(ProvidesUsesLib); ok {
247 name := ulib.ProvidesUsesLib()
248 if name != nil {
249 providesUsesLib = *name
250 }
251 }
252
Jeongik Cha4b073cd2021-06-08 11:35:00 +0900253 // If it is test, make config files regardless of its dexpreopt setting.
Jeongik Chac6246672021-04-08 00:00:19 +0900254 // The config files are required for apps defined in make which depend on the lib.
Jeongik Cha4b073cd2021-06-08 11:35:00 +0900255 if d.isTest && d.dexpreoptDisabled(ctx) {
Jaewoong Jung4b97a562020-12-17 09:43:28 -0800256 return
Nicolas Geoffrayfa6e9ec2019-02-12 13:12:16 +0000257 }
258
Jiakai Zhang389a6472021-12-14 18:54:06 +0000259 isSystemServerJar := global.AllSystemServerJars(ctx).ContainsJar(moduleName(ctx))
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000260
Colin Cross44df5812019-02-15 23:06:46 -0800261 bootImage := defaultBootImageConfig(ctx)
Jiakai Zhang02669e82021-09-11 03:44:06 +0000262 dexFiles, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp)
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000263
David Srbeckyc177ebe2020-02-18 20:43:06 +0000264 targets := ctx.MultiTargets()
265 if len(targets) == 0 {
Colin Cross43f08db2018-11-12 10:13:39 -0800266 // assume this is a java library, dexpreopt for all arches for now
267 for _, target := range ctx.Config().Targets[android.Android] {
dimitry1f33e402019-03-26 12:39:31 +0100268 if target.NativeBridge == android.NativeBridgeDisabled {
David Srbeckyc177ebe2020-02-18 20:43:06 +0000269 targets = append(targets, target)
dimitry1f33e402019-03-26 12:39:31 +0100270 }
Colin Cross43f08db2018-11-12 10:13:39 -0800271 }
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000272 if isSystemServerJar && !d.isSDKLibrary {
Colin Cross43f08db2018-11-12 10:13:39 -0800273 // If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
David Srbeckyc177ebe2020-02-18 20:43:06 +0000274 targets = targets[:1]
Colin Cross43f08db2018-11-12 10:13:39 -0800275 }
276 }
Colin Cross43f08db2018-11-12 10:13:39 -0800277
David Srbeckyc177ebe2020-02-18 20:43:06 +0000278 var archs []android.ArchType
Colin Cross69f59a32019-02-15 10:39:37 -0800279 var images android.Paths
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +0000280 var imagesDeps []android.OutputPaths
David Srbeckyc177ebe2020-02-18 20:43:06 +0000281 for _, target := range targets {
282 archs = append(archs, target.Arch.ArchType)
283 variant := bootImage.getVariant(target)
Jeongik Chaa5969092021-05-07 18:53:21 +0900284 images = append(images, variant.imagePathOnHost)
David Srbeckyc177ebe2020-02-18 20:43:06 +0000285 imagesDeps = append(imagesDeps, variant.imagesDeps)
Colin Crossc7e40aa2019-02-08 21:37:00 -0800286 }
David Srbeckyab994982020-03-30 17:24:13 +0100287 // The image locations for all Android variants are identical.
Jeongik Cha4dda75e2021-04-27 23:56:44 +0900288 hostImageLocations, deviceImageLocations := bootImage.getAnyAndroidVariant().imageLocations()
Colin Crossc7e40aa2019-02-08 21:37:00 -0800289
Colin Cross43f08db2018-11-12 10:13:39 -0800290 var profileClassListing android.OptionalPath
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100291 var profileBootListing android.OptionalPath
Colin Cross43f08db2018-11-12 10:13:39 -0800292 profileIsTextListing := false
293 if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) {
294 // If dex_preopt.profile_guided is not set, default it based on the existence of the
295 // dexprepot.profile option or the profile class listing.
296 if String(d.dexpreoptProperties.Dex_preopt.Profile) != "" {
297 profileClassListing = android.OptionalPathForPath(
298 android.PathForModuleSrc(ctx, String(d.dexpreoptProperties.Dex_preopt.Profile)))
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100299 profileBootListing = android.ExistentPathForSource(ctx,
300 ctx.ModuleDir(), String(d.dexpreoptProperties.Dex_preopt.Profile)+"-boot")
Colin Cross43f08db2018-11-12 10:13:39 -0800301 profileIsTextListing = true
Dan Willemsen78d51b02020-06-24 16:33:31 -0700302 } else if global.ProfileDir != "" {
Colin Cross43f08db2018-11-12 10:13:39 -0800303 profileClassListing = android.ExistentPathForSource(ctx,
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000304 global.ProfileDir, moduleName(ctx)+".prof")
Colin Cross43f08db2018-11-12 10:13:39 -0800305 }
306 }
307
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000308 // Full dexpreopt config, used to create dexpreopt build rules.
Martin Stjernholm8d80cee2020-01-31 17:44:54 +0000309 dexpreoptConfig := &dexpreopt.ModuleConfig{
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000310 Name: moduleName(ctx),
Victor Hsiehd181c8b2019-01-29 13:00:33 -0800311 DexLocation: dexLocation,
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000312 BuildPath: android.PathForModuleOut(ctx, "dexpreopt", moduleName(ctx)+".jar").OutputPath,
Colin Cross69f59a32019-02-15 10:39:37 -0800313 DexPath: dexJarFile,
Jeongik Cha33a3a812021-04-15 09:12:49 +0900314 ManifestPath: android.OptionalPathForPath(d.manifestFile),
Victor Hsiehd181c8b2019-01-29 13:00:33 -0800315 UncompressedDex: d.uncompressedDex,
316 HasApkLibraries: false,
317 PreoptFlags: nil,
Colin Cross43f08db2018-11-12 10:13:39 -0800318
Colin Cross69f59a32019-02-15 10:39:37 -0800319 ProfileClassListing: profileClassListing,
Colin Cross43f08db2018-11-12 10:13:39 -0800320 ProfileIsTextListing: profileIsTextListing,
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100321 ProfileBootListing: profileBootListing,
Colin Cross43f08db2018-11-12 10:13:39 -0800322
Ulya Trafimovich8c35fcf2021-02-17 16:23:28 +0000323 EnforceUsesLibrariesStatusFile: dexpreopt.UsesLibrariesStatusFile(ctx),
324 EnforceUsesLibraries: d.enforceUsesLibs,
325 ProvidesUsesLibrary: providesUsesLib,
326 ClassLoaderContexts: d.classLoaderContexts,
Colin Cross43f08db2018-11-12 10:13:39 -0800327
Jeongik Cha4dda75e2021-04-27 23:56:44 +0900328 Archs: archs,
329 DexPreoptImagesDeps: imagesDeps,
330 DexPreoptImageLocationsOnHost: hostImageLocations,
331 DexPreoptImageLocationsOnDevice: deviceImageLocations,
Colin Cross43f08db2018-11-12 10:13:39 -0800332
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000333 PreoptBootClassPathDexFiles: dexFiles.Paths(),
Vladimir Marko40139d62020-02-06 15:14:29 +0000334 PreoptBootClassPathDexLocations: dexLocations,
Colin Cross800fe132019-02-11 14:21:24 -0800335
Colin Cross43f08db2018-11-12 10:13:39 -0800336 PreoptExtractedApk: false,
337
338 NoCreateAppImage: !BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, true),
339 ForceCreateAppImage: BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, false),
340
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700341 PresignedPrebuilt: d.isPresignedPrebuilt,
Colin Cross43f08db2018-11-12 10:13:39 -0800342 }
343
Jeongik Chac6246672021-04-08 00:00:19 +0900344 d.configPath = android.PathForModuleOut(ctx, "dexpreopt", "dexpreopt.config")
345 dexpreopt.WriteModuleConfig(ctx, dexpreoptConfig, d.configPath)
346
347 if d.dexpreoptDisabled(ctx) {
348 return
349 }
350
351 globalSoong := dexpreopt.GetGlobalSoongConfig(ctx)
352
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000353 dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, globalSoong, global, dexpreoptConfig)
Colin Cross43f08db2018-11-12 10:13:39 -0800354 if err != nil {
355 ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error())
Jaewoong Jung4b97a562020-12-17 09:43:28 -0800356 return
Colin Cross43f08db2018-11-12 10:13:39 -0800357 }
358
Colin Crossf1a035e2020-11-16 17:32:30 -0800359 dexpreoptRule.Build("dexpreopt", "dexpreopt")
Colin Cross43f08db2018-11-12 10:13:39 -0800360
Jiakai Zhang389a6472021-12-14 18:54:06 +0000361 isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx))
362
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700363 for _, install := range dexpreoptRule.Installs() {
364 // Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
365 installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
366 installBase := filepath.Base(install.To)
367 arch := filepath.Base(installDir)
368 installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir)
369
Jiakai Zhang389a6472021-12-14 18:54:06 +0000370 if isApexSystemServerJar {
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700371 // APEX variants of java libraries are hidden from Make, so their dexpreopt
372 // outputs need special handling. Currently, for APEX variants of java
373 // libraries, only those in the system server classpath are handled here.
374 // Preopting of boot classpath jars in the ART APEX are handled in
375 // java/dexpreopt_bootjars.go, and other APEX jars are not preopted.
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000376 // The installs will be handled by Make as sub-modules of the java library.
377 d.builtInstalledForApex = append(d.builtInstalledForApex, dexpreopterInstall{
378 name: arch + "-" + installBase,
379 moduleName: moduleName(ctx),
380 outputPathOnHost: install.From,
381 installDirOnDevice: installPath,
382 installFileOnDevice: installBase,
383 })
Colin Crossfa9bfcd2021-11-10 16:42:38 -0800384 } else if !d.preventInstall {
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700385 ctx.InstallFile(installPath, installBase, install.From)
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000386 }
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700387 }
388
Jiakai Zhang389a6472021-12-14 18:54:06 +0000389 if !isApexSystemServerJar {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000390 d.builtInstalled = dexpreoptRule.Installs().String()
391 }
392}
393
394func (d *dexpreopter) DexpreoptBuiltInstalledForApex() []dexpreopterInstall {
395 return d.builtInstalledForApex
396}
397
398func (d *dexpreopter) AndroidMkEntriesForApex() []android.AndroidMkEntries {
399 var entries []android.AndroidMkEntries
400 for _, install := range d.builtInstalledForApex {
Jiakai Zhang6decef92022-01-12 17:56:19 +0000401 entries = append(entries, install.ToMakeEntries())
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000402 }
403 return entries
Colin Cross43f08db2018-11-12 10:13:39 -0800404}