blob: 3158450a84ee162366f05555b0c134a3aafb6ea0 [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
Colin Cross43f08db2018-11-12 10:13:39 -080060type dexpreopter struct {
61 dexpreoptProperties DexpreoptProperties
62
Colin Cross70dda7e2019-10-01 22:05:35 -070063 installPath android.InstallPath
Jaewoong Jungccbb3932019-04-15 09:48:31 -070064 uncompressedDex bool
65 isSDKLibrary bool
Ulya Trafimovich76b08522021-01-14 17:52:43 +000066 isApp bool
Jaewoong Jungccbb3932019-04-15 09:48:31 -070067 isTest bool
Jaewoong Jungccbb3932019-04-15 09:48:31 -070068 isPresignedPrebuilt bool
Colin Crossfa9bfcd2021-11-10 16:42:38 -080069 preventInstall bool
Colin Cross43f08db2018-11-12 10:13:39 -080070
Ulya Trafimovich8cbc5d22020-11-03 15:15:46 +000071 manifestFile android.Path
Ulya Trafimovich8c35fcf2021-02-17 16:23:28 +000072 statusFile android.WritablePath
Ulya Trafimovich8cbc5d22020-11-03 15:15:46 +000073 enforceUsesLibs bool
74 classLoaderContexts dexpreopt.ClassLoaderContextMap
Colin Cross50ddcc42019-05-16 12:28:22 -070075
Jiakai Zhangca9bc982021-09-09 08:09:41 +000076 // See the `dexpreopt` function for details.
77 builtInstalled string
78 builtInstalledForApex []dexpreopterInstall
Ulya Trafimovich76b08522021-01-14 17:52:43 +000079
Jeongik Chac6246672021-04-08 00:00:19 +090080 // The config is used for two purposes:
81 // - Passing dexpreopt information about libraries from Soong to Make. This is needed when
82 // a <uses-library> is defined in Android.bp, but used in Android.mk (see dex_preopt_config_merger.py).
83 // Note that dexpreopt.config might be needed even if dexpreopt is disabled for the library itself.
84 // - Dexpreopt post-processing (using dexpreopt artifacts from a prebuilt system image to incrementally
85 // dexpreopt another partition).
Ulya Trafimovich76b08522021-01-14 17:52:43 +000086 configPath android.WritablePath
Colin Cross43f08db2018-11-12 10:13:39 -080087}
88
89type DexpreoptProperties struct {
90 Dex_preopt struct {
Nicolas Geoffrayc1bf7242019-10-18 14:51:38 +010091 // If false, prevent dexpreopting. Defaults to true.
Colin Cross43f08db2018-11-12 10:13:39 -080092 Enabled *bool
93
94 // If true, generate an app image (.art file) for this module.
95 App_image *bool
96
97 // If true, use a checked-in profile to guide optimization. Defaults to false unless
98 // a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR
99 // that matches the name of this module, in which case it is defaulted to true.
100 Profile_guided *bool
101
102 // If set, provides the path to profile relative to the Android.bp file. If not set,
103 // defaults to searching for a file that matches the name of this module in the default
104 // profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found.
Colin Crossde4e4e62019-04-26 10:52:32 -0700105 Profile *string `android:"path"`
Colin Cross43f08db2018-11-12 10:13:39 -0800106 }
107}
108
Ulya Trafimovich6cf2c0c2020-04-24 12:15:20 +0100109func init() {
110 dexpreopt.DexpreoptRunningInSoong = true
111}
112
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000113func isApexVariant(ctx android.BaseModuleContext) bool {
114 apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo)
115 return !apexInfo.IsForPlatform()
116}
117
118func moduleName(ctx android.BaseModuleContext) string {
119 // Remove the "prebuilt_" prefix if the module is from a prebuilt because the prefix is not
120 // expected by dexpreopter.
121 return android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName())
122}
123
Martin Stjernholm6d415272020-01-31 17:10:36 +0000124func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
Colin Cross38310bb2021-12-01 10:34:14 -0800125 if !ctx.Device() {
Colin Cross43f08db2018-11-12 10:13:39 -0800126 return true
127 }
128
Colin Cross43f08db2018-11-12 10:13:39 -0800129 if d.isTest {
130 return true
131 }
132
133 if !BoolDefault(d.dexpreoptProperties.Dex_preopt.Enabled, true) {
134 return true
135 }
136
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000137 if !ctx.Module().(DexpreopterInterface).IsInstallable() {
Martin Stjernholm6d415272020-01-31 17:10:36 +0000138 return true
139 }
140
Colin Cross38310bb2021-12-01 10:34:14 -0800141 if !android.IsModulePreferred(ctx.Module()) {
142 return true
143 }
144
145 global := dexpreopt.GetGlobalConfig(ctx)
146
147 if global.DisablePreopt {
148 return true
149 }
150
151 if inList(moduleName(ctx), global.DisablePreoptModules) {
Colin Crossdc2da912019-01-05 22:13:05 -0800152 return true
153 }
154
Jiakai Zhang389a6472021-12-14 18:54:06 +0000155 isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx))
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000156 if isApexVariant(ctx) {
157 // Don't preopt APEX variant module unless the module is an APEX system server jar and we are
158 // building the entire system image.
Jiakai Zhang389a6472021-12-14 18:54:06 +0000159 if !isApexSystemServerJar || ctx.Config().UnbundledBuild() {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000160 return true
161 }
162 } else {
163 // Don't preopt the platform variant of an APEX system server jar to avoid conflicts.
Jiakai Zhang389a6472021-12-14 18:54:06 +0000164 if isApexSystemServerJar {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000165 return true
166 }
Yo Chiangdbdf8f92020-01-09 19:00:27 +0800167 }
168
Colin Cross43f08db2018-11-12 10:13:39 -0800169 // TODO: contains no java code
170
171 return false
172}
173
Martin Stjernholm6d415272020-01-31 17:10:36 +0000174func dexpreoptToolDepsMutator(ctx android.BottomUpMutatorContext) {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000175 if d, ok := ctx.Module().(DexpreopterInterface); !ok || d.dexpreoptDisabled(ctx) {
Martin Stjernholm6d415272020-01-31 17:10:36 +0000176 return
177 }
178 dexpreopt.RegisterToolDeps(ctx)
179}
180
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000181func (d *dexpreopter) odexOnSystemOther(ctx android.ModuleContext, installPath android.InstallPath) bool {
182 return dexpreopt.OdexOnSystemOtherByName(moduleName(ctx), android.InstallPathToOnDevicePath(ctx, installPath), dexpreopt.GetGlobalConfig(ctx))
183}
184
185// Returns the install path of the dex jar of a module.
186//
187// Do not rely on `ApexInfo.ApexVariationName` because it can be something like "apex1000", rather
188// than the `name` in the path `/apex/<name>` as suggested in its comment.
189//
190// This function is on a best-effort basis. It cannot handle the case where an APEX jar is not a
191// system server jar, which is fine because we currently only preopt system server jars for APEXes.
192func (d *dexpreopter) getInstallPath(
193 ctx android.ModuleContext, defaultInstallPath android.InstallPath) android.InstallPath {
194 global := dexpreopt.GetGlobalConfig(ctx)
Jiakai Zhang389a6472021-12-14 18:54:06 +0000195 if global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx)) {
196 dexLocation := dexpreopt.GetSystemServerDexLocation(ctx, global, moduleName(ctx))
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000197 return android.PathForModuleInPartitionInstall(ctx, "", strings.TrimPrefix(dexLocation, "/"))
198 }
199 if !d.dexpreoptDisabled(ctx) && isApexVariant(ctx) &&
200 filepath.Base(defaultInstallPath.PartitionDir()) != "apex" {
201 ctx.ModuleErrorf("unable to get the install path of the dex jar for dexpreopt")
202 }
203 return defaultInstallPath
Nicolas Geoffrayfa6e9ec2019-02-12 13:12:16 +0000204}
205
Paul Duffin612e6102021-02-02 13:38:13 +0000206func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.WritablePath) {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000207 global := dexpreopt.GetGlobalConfig(ctx)
208
Martin Stjernholm6d415272020-01-31 17:10:36 +0000209 // TODO(b/148690468): The check on d.installPath is to bail out in cases where
210 // the dexpreopter struct hasn't been fully initialized before we're called,
211 // e.g. in aar.go. This keeps the behaviour that dexpreopting is effectively
212 // disabled, even if installable is true.
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000213 if d.installPath.Base() == "." {
214 return
215 }
216
217 dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath)
218
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000219 providesUsesLib := moduleName(ctx)
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000220 if ulib, ok := ctx.Module().(ProvidesUsesLib); ok {
221 name := ulib.ProvidesUsesLib()
222 if name != nil {
223 providesUsesLib = *name
224 }
225 }
226
Jeongik Cha4b073cd2021-06-08 11:35:00 +0900227 // If it is test, make config files regardless of its dexpreopt setting.
Jeongik Chac6246672021-04-08 00:00:19 +0900228 // The config files are required for apps defined in make which depend on the lib.
Jeongik Cha4b073cd2021-06-08 11:35:00 +0900229 if d.isTest && d.dexpreoptDisabled(ctx) {
Jaewoong Jung4b97a562020-12-17 09:43:28 -0800230 return
Nicolas Geoffrayfa6e9ec2019-02-12 13:12:16 +0000231 }
232
Jiakai Zhang389a6472021-12-14 18:54:06 +0000233 isSystemServerJar := global.AllSystemServerJars(ctx).ContainsJar(moduleName(ctx))
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000234
Colin Cross44df5812019-02-15 23:06:46 -0800235 bootImage := defaultBootImageConfig(ctx)
Vladimir Marko40139d62020-02-06 15:14:29 +0000236 if global.UseArtImage {
237 bootImage = artBootImageConfig(ctx)
238 }
Colin Cross43f08db2018-11-12 10:13:39 -0800239
Jiakai Zhang02669e82021-09-11 03:44:06 +0000240 dexFiles, dexLocations := bcpForDexpreopt(ctx, global.PreoptWithUpdatableBcp)
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000241
David Srbeckyc177ebe2020-02-18 20:43:06 +0000242 targets := ctx.MultiTargets()
243 if len(targets) == 0 {
Colin Cross43f08db2018-11-12 10:13:39 -0800244 // assume this is a java library, dexpreopt for all arches for now
245 for _, target := range ctx.Config().Targets[android.Android] {
dimitry1f33e402019-03-26 12:39:31 +0100246 if target.NativeBridge == android.NativeBridgeDisabled {
David Srbeckyc177ebe2020-02-18 20:43:06 +0000247 targets = append(targets, target)
dimitry1f33e402019-03-26 12:39:31 +0100248 }
Colin Cross43f08db2018-11-12 10:13:39 -0800249 }
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000250 if isSystemServerJar && !d.isSDKLibrary {
Colin Cross43f08db2018-11-12 10:13:39 -0800251 // 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 +0000252 targets = targets[:1]
Colin Cross43f08db2018-11-12 10:13:39 -0800253 }
254 }
Colin Cross43f08db2018-11-12 10:13:39 -0800255
David Srbeckyc177ebe2020-02-18 20:43:06 +0000256 var archs []android.ArchType
Colin Cross69f59a32019-02-15 10:39:37 -0800257 var images android.Paths
Ulya Trafimovich4d2eeed2019-11-08 10:54:21 +0000258 var imagesDeps []android.OutputPaths
David Srbeckyc177ebe2020-02-18 20:43:06 +0000259 for _, target := range targets {
260 archs = append(archs, target.Arch.ArchType)
261 variant := bootImage.getVariant(target)
Jeongik Chaa5969092021-05-07 18:53:21 +0900262 images = append(images, variant.imagePathOnHost)
David Srbeckyc177ebe2020-02-18 20:43:06 +0000263 imagesDeps = append(imagesDeps, variant.imagesDeps)
Colin Crossc7e40aa2019-02-08 21:37:00 -0800264 }
David Srbeckyab994982020-03-30 17:24:13 +0100265 // The image locations for all Android variants are identical.
Jeongik Cha4dda75e2021-04-27 23:56:44 +0900266 hostImageLocations, deviceImageLocations := bootImage.getAnyAndroidVariant().imageLocations()
Colin Crossc7e40aa2019-02-08 21:37:00 -0800267
Colin Cross43f08db2018-11-12 10:13:39 -0800268 var profileClassListing android.OptionalPath
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100269 var profileBootListing android.OptionalPath
Colin Cross43f08db2018-11-12 10:13:39 -0800270 profileIsTextListing := false
271 if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) {
272 // If dex_preopt.profile_guided is not set, default it based on the existence of the
273 // dexprepot.profile option or the profile class listing.
274 if String(d.dexpreoptProperties.Dex_preopt.Profile) != "" {
275 profileClassListing = android.OptionalPathForPath(
276 android.PathForModuleSrc(ctx, String(d.dexpreoptProperties.Dex_preopt.Profile)))
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100277 profileBootListing = android.ExistentPathForSource(ctx,
278 ctx.ModuleDir(), String(d.dexpreoptProperties.Dex_preopt.Profile)+"-boot")
Colin Cross43f08db2018-11-12 10:13:39 -0800279 profileIsTextListing = true
Dan Willemsen78d51b02020-06-24 16:33:31 -0700280 } else if global.ProfileDir != "" {
Colin Cross43f08db2018-11-12 10:13:39 -0800281 profileClassListing = android.ExistentPathForSource(ctx,
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000282 global.ProfileDir, moduleName(ctx)+".prof")
Colin Cross43f08db2018-11-12 10:13:39 -0800283 }
284 }
285
Ulya Trafimovich76b08522021-01-14 17:52:43 +0000286 // Full dexpreopt config, used to create dexpreopt build rules.
Martin Stjernholm8d80cee2020-01-31 17:44:54 +0000287 dexpreoptConfig := &dexpreopt.ModuleConfig{
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000288 Name: moduleName(ctx),
Victor Hsiehd181c8b2019-01-29 13:00:33 -0800289 DexLocation: dexLocation,
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000290 BuildPath: android.PathForModuleOut(ctx, "dexpreopt", moduleName(ctx)+".jar").OutputPath,
Colin Cross69f59a32019-02-15 10:39:37 -0800291 DexPath: dexJarFile,
Jeongik Cha33a3a812021-04-15 09:12:49 +0900292 ManifestPath: android.OptionalPathForPath(d.manifestFile),
Victor Hsiehd181c8b2019-01-29 13:00:33 -0800293 UncompressedDex: d.uncompressedDex,
294 HasApkLibraries: false,
295 PreoptFlags: nil,
Colin Cross43f08db2018-11-12 10:13:39 -0800296
Colin Cross69f59a32019-02-15 10:39:37 -0800297 ProfileClassListing: profileClassListing,
Colin Cross43f08db2018-11-12 10:13:39 -0800298 ProfileIsTextListing: profileIsTextListing,
Nicolas Geoffraye7102422019-07-24 13:19:29 +0100299 ProfileBootListing: profileBootListing,
Colin Cross43f08db2018-11-12 10:13:39 -0800300
Ulya Trafimovich8c35fcf2021-02-17 16:23:28 +0000301 EnforceUsesLibrariesStatusFile: dexpreopt.UsesLibrariesStatusFile(ctx),
302 EnforceUsesLibraries: d.enforceUsesLibs,
303 ProvidesUsesLibrary: providesUsesLib,
304 ClassLoaderContexts: d.classLoaderContexts,
Colin Cross43f08db2018-11-12 10:13:39 -0800305
Jeongik Cha4dda75e2021-04-27 23:56:44 +0900306 Archs: archs,
307 DexPreoptImagesDeps: imagesDeps,
308 DexPreoptImageLocationsOnHost: hostImageLocations,
309 DexPreoptImageLocationsOnDevice: deviceImageLocations,
Colin Cross43f08db2018-11-12 10:13:39 -0800310
Ulya Trafimovich9023b022021-03-22 16:02:28 +0000311 PreoptBootClassPathDexFiles: dexFiles.Paths(),
Vladimir Marko40139d62020-02-06 15:14:29 +0000312 PreoptBootClassPathDexLocations: dexLocations,
Colin Cross800fe132019-02-11 14:21:24 -0800313
Colin Cross43f08db2018-11-12 10:13:39 -0800314 PreoptExtractedApk: false,
315
316 NoCreateAppImage: !BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, true),
317 ForceCreateAppImage: BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, false),
318
Jaewoong Jungccbb3932019-04-15 09:48:31 -0700319 PresignedPrebuilt: d.isPresignedPrebuilt,
Colin Cross43f08db2018-11-12 10:13:39 -0800320 }
321
Jeongik Chac6246672021-04-08 00:00:19 +0900322 d.configPath = android.PathForModuleOut(ctx, "dexpreopt", "dexpreopt.config")
323 dexpreopt.WriteModuleConfig(ctx, dexpreoptConfig, d.configPath)
324
325 if d.dexpreoptDisabled(ctx) {
326 return
327 }
328
329 globalSoong := dexpreopt.GetGlobalSoongConfig(ctx)
330
Martin Stjernholm75a48d82020-01-10 20:32:59 +0000331 dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, globalSoong, global, dexpreoptConfig)
Colin Cross43f08db2018-11-12 10:13:39 -0800332 if err != nil {
333 ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error())
Jaewoong Jung4b97a562020-12-17 09:43:28 -0800334 return
Colin Cross43f08db2018-11-12 10:13:39 -0800335 }
336
Colin Crossf1a035e2020-11-16 17:32:30 -0800337 dexpreoptRule.Build("dexpreopt", "dexpreopt")
Colin Cross43f08db2018-11-12 10:13:39 -0800338
Jiakai Zhang389a6472021-12-14 18:54:06 +0000339 isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx))
340
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700341 for _, install := range dexpreoptRule.Installs() {
342 // Remove the "/" prefix because the path should be relative to $ANDROID_PRODUCT_OUT.
343 installDir := strings.TrimPrefix(filepath.Dir(install.To), "/")
344 installBase := filepath.Base(install.To)
345 arch := filepath.Base(installDir)
346 installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir)
347
Jiakai Zhang389a6472021-12-14 18:54:06 +0000348 if isApexSystemServerJar {
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700349 // APEX variants of java libraries are hidden from Make, so their dexpreopt
350 // outputs need special handling. Currently, for APEX variants of java
351 // libraries, only those in the system server classpath are handled here.
352 // Preopting of boot classpath jars in the ART APEX are handled in
353 // java/dexpreopt_bootjars.go, and other APEX jars are not preopted.
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000354 // The installs will be handled by Make as sub-modules of the java library.
355 d.builtInstalledForApex = append(d.builtInstalledForApex, dexpreopterInstall{
356 name: arch + "-" + installBase,
357 moduleName: moduleName(ctx),
358 outputPathOnHost: install.From,
359 installDirOnDevice: installPath,
360 installFileOnDevice: installBase,
361 })
Colin Crossfa9bfcd2021-11-10 16:42:38 -0800362 } else if !d.preventInstall {
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700363 ctx.InstallFile(installPath, installBase, install.From)
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000364 }
Colin Cross1d0eb7a2021-11-03 14:08:20 -0700365 }
366
Jiakai Zhang389a6472021-12-14 18:54:06 +0000367 if !isApexSystemServerJar {
Jiakai Zhangca9bc982021-09-09 08:09:41 +0000368 d.builtInstalled = dexpreoptRule.Installs().String()
369 }
370}
371
372func (d *dexpreopter) DexpreoptBuiltInstalledForApex() []dexpreopterInstall {
373 return d.builtInstalledForApex
374}
375
376func (d *dexpreopter) AndroidMkEntriesForApex() []android.AndroidMkEntries {
377 var entries []android.AndroidMkEntries
378 for _, install := range d.builtInstalledForApex {
379 install := install
380 entries = append(entries, android.AndroidMkEntries{
381 Class: "ETC",
382 SubName: install.SubModuleName(),
383 OutputFile: android.OptionalPathForPath(install.outputPathOnHost),
384 ExtraEntries: []android.AndroidMkExtraEntriesFunc{
385 func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
386 entries.SetString("LOCAL_MODULE_PATH", install.installDirOnDevice.ToMakePath().String())
387 entries.SetString("LOCAL_INSTALLED_MODULE_STEM", install.installFileOnDevice)
388 entries.SetString("LOCAL_NOT_AVAILABLE_FOR_PLATFORM", "false")
389 },
390 },
391 })
392 }
393 return entries
Colin Cross43f08db2018-11-12 10:13:39 -0800394}