blob: 87d8428d5bddefa94c0711cc3e4417a4947b15ed [file] [log] [blame]
Colin Cross800fe132019-02-11 14:21:24 -08001// Copyright 2019 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 (
18 "path/filepath"
Colin Crossc9a4c362019-02-26 21:13:48 -080019 "sort"
Colin Cross800fe132019-02-11 14:21:24 -080020 "strings"
21
22 "android/soong/android"
23 "android/soong/dexpreopt"
24
25 "github.com/google/blueprint/pathtools"
26 "github.com/google/blueprint/proptools"
27)
28
29func init() {
30 android.RegisterSingletonType("dex_bootjars", dexpreoptBootJarsFactory)
31}
32
33// The image "location" is a symbolic path that with multiarchitecture
34// support doesn't really exist on the device. Typically it is
35// /system/framework/boot.art and should be the same for all supported
36// architectures on the device. The concrete architecture specific
37// content actually ends up in a "filename" that contains an
38// architecture specific directory name such as arm, arm64, mips,
39// mips64, x86, x86_64.
40//
41// Here are some example values for an x86_64 / x86 configuration:
42//
43// bootImages["x86_64"] = "out/soong/generic_x86_64/dex_bootjars/system/framework/x86_64/boot.art"
44// dexpreopt.PathToLocation(bootImages["x86_64"], "x86_64") = "out/soong/generic_x86_64/dex_bootjars/system/framework/boot.art"
45//
46// bootImages["x86"] = "out/soong/generic_x86_64/dex_bootjars/system/framework/x86/boot.art"
47// dexpreopt.PathToLocation(bootImages["x86"])= "out/soong/generic_x86_64/dex_bootjars/system/framework/boot.art"
48//
49// The location is passed as an argument to the ART tools like dex2oat instead of the real path. The ART tools
50// will then reconstruct the real path, so the rules must have a dependency on the real path.
51
Colin Cross44df5812019-02-15 23:06:46 -080052type bootImageConfig struct {
53 name string
54 modules []string
55 dexLocations []string
56 dexPaths android.WritablePaths
57 dir android.OutputPath
58 symbolsDir android.OutputPath
59 images map[android.ArchType]android.OutputPath
Colin Cross800fe132019-02-11 14:21:24 -080060}
61
Colin Cross44df5812019-02-15 23:06:46 -080062type bootImage struct {
63 bootImageConfig
Colin Cross800fe132019-02-11 14:21:24 -080064
Colin Cross44df5812019-02-15 23:06:46 -080065 installs map[android.ArchType]android.RuleBuilderInstalls
66 vdexInstalls map[android.ArchType]android.RuleBuilderInstalls
67 unstrippedInstalls map[android.ArchType]android.RuleBuilderInstalls
Colin Cross800fe132019-02-11 14:21:24 -080068
Colin Cross44df5812019-02-15 23:06:46 -080069 profileInstalls android.RuleBuilderInstalls
70}
Colin Cross800fe132019-02-11 14:21:24 -080071
Colin Cross44df5812019-02-15 23:06:46 -080072func newBootImage(ctx android.PathContext, config bootImageConfig) *bootImage {
73 image := &bootImage{
Nicolas Geoffray72892f12019-02-22 15:34:40 +000074 bootImageConfig: config,
Colin Cross800fe132019-02-11 14:21:24 -080075
Colin Cross44df5812019-02-15 23:06:46 -080076 installs: make(map[android.ArchType]android.RuleBuilderInstalls),
77 vdexInstalls: make(map[android.ArchType]android.RuleBuilderInstalls),
78 unstrippedInstalls: make(map[android.ArchType]android.RuleBuilderInstalls),
79 }
Colin Cross800fe132019-02-11 14:21:24 -080080
Colin Cross44df5812019-02-15 23:06:46 -080081 return image
Colin Cross800fe132019-02-11 14:21:24 -080082}
83
84func concat(lists ...[]string) []string {
85 var size int
86 for _, l := range lists {
87 size += len(l)
88 }
89 ret := make([]string, 0, size)
90 for _, l := range lists {
91 ret = append(ret, l...)
92 }
93 return ret
94}
95
Colin Cross800fe132019-02-11 14:21:24 -080096func dexpreoptBootJarsFactory() android.Singleton {
Colin Cross44df5812019-02-15 23:06:46 -080097 return &dexpreoptBootJars{}
Colin Cross800fe132019-02-11 14:21:24 -080098}
99
100func skipDexpreoptBootJars(ctx android.PathContext) bool {
101 if ctx.Config().UnbundledBuild() {
102 return true
103 }
104
105 if len(ctx.Config().Targets[android.Android]) == 0 {
106 // Host-only build
107 return true
108 }
109
110 return false
111}
112
Colin Cross44df5812019-02-15 23:06:46 -0800113type dexpreoptBootJars struct {
114 defaultBootImage *bootImage
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000115 otherImages []*bootImage
Colin Cross44df5812019-02-15 23:06:46 -0800116}
Colin Cross800fe132019-02-11 14:21:24 -0800117
118// dexpreoptBoot singleton rules
Colin Cross44df5812019-02-15 23:06:46 -0800119func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) {
Colin Cross800fe132019-02-11 14:21:24 -0800120 if skipDexpreoptBootJars(ctx) {
121 return
122 }
123
Colin Cross44df5812019-02-15 23:06:46 -0800124 global := dexpreoptGlobalConfig(ctx)
Colin Cross800fe132019-02-11 14:21:24 -0800125
126 // Skip recompiling the boot image for the second sanitization phase. We'll get separate paths
127 // and invalidate first-stage artifacts which are crucial to SANITIZE_LITE builds.
128 // Note: this is technically incorrect. Compiled code contains stack checks which may depend
129 // on ASAN settings.
130 if len(ctx.Config().SanitizeDevice()) == 1 &&
131 ctx.Config().SanitizeDevice()[0] == "address" &&
Colin Cross44df5812019-02-15 23:06:46 -0800132 global.SanitizeLite {
Colin Cross800fe132019-02-11 14:21:24 -0800133 return
134 }
135
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000136 // Always create the default boot image first, to get a unique profile rule for all images.
Colin Cross44df5812019-02-15 23:06:46 -0800137 d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx))
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000138 if global.GenerateApexImage {
139 d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx)))
140 }
Colin Crossc9a4c362019-02-26 21:13:48 -0800141
142 dumpOatRules(ctx, d.defaultBootImage)
Colin Cross44df5812019-02-15 23:06:46 -0800143}
144
145// buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage.
146func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootImage {
147 global := dexpreoptGlobalConfig(ctx)
148
149 image := newBootImage(ctx, config)
150
151 bootDexJars := make(android.Paths, len(image.modules))
Colin Cross800fe132019-02-11 14:21:24 -0800152
153 ctx.VisitAllModules(func(module android.Module) {
Sam Mortimer73cf7502019-10-07 11:41:14 -0700154 if m, ok := module.(interface{ BootJarProvider() bool }); !ok ||
155 !m.BootJarProvider() {
156 return
157 }
Colin Cross800fe132019-02-11 14:21:24 -0800158 // Collect dex jar paths for the modules listed above.
Colin Cross42be7612019-02-21 18:12:14 -0800159 if j, ok := module.(interface{ DexJar() android.Path }); ok {
Colin Cross800fe132019-02-11 14:21:24 -0800160 name := ctx.ModuleName(module)
Colin Cross44df5812019-02-15 23:06:46 -0800161 if i := android.IndexList(name, image.modules); i != -1 {
Colin Cross800fe132019-02-11 14:21:24 -0800162 bootDexJars[i] = j.DexJar()
163 }
164 }
165 })
166
167 var missingDeps []string
168 // Ensure all modules were converted to paths
169 for i := range bootDexJars {
170 if bootDexJars[i] == nil {
171 if ctx.Config().AllowMissingDependencies() {
Colin Cross44df5812019-02-15 23:06:46 -0800172 missingDeps = append(missingDeps, image.modules[i])
Colin Cross800fe132019-02-11 14:21:24 -0800173 bootDexJars[i] = android.PathForOutput(ctx, "missing")
174 } else {
175 ctx.Errorf("failed to find dex jar path for module %q",
Colin Cross44df5812019-02-15 23:06:46 -0800176 image.modules[i])
Colin Cross800fe132019-02-11 14:21:24 -0800177 }
178 }
179 }
180
181 // The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before
182 // the bootclasspath modules have been compiled. Copy the dex jars there so the module rules that have
183 // already been set up can find them.
184 for i := range bootDexJars {
185 ctx.Build(pctx, android.BuildParams{
186 Rule: android.Cp,
187 Input: bootDexJars[i],
Colin Cross44df5812019-02-15 23:06:46 -0800188 Output: image.dexPaths[i],
Colin Cross800fe132019-02-11 14:21:24 -0800189 })
190 }
191
Colin Cross44df5812019-02-15 23:06:46 -0800192 profile := bootImageProfileRule(ctx, image, missingDeps)
Colin Cross800fe132019-02-11 14:21:24 -0800193
Colin Cross44df5812019-02-15 23:06:46 -0800194 if !global.DisablePreopt {
Colin Cross800fe132019-02-11 14:21:24 -0800195 targets := ctx.Config().Targets[android.Android]
196 if ctx.Config().SecondArchIsTranslated() {
197 targets = targets[:1]
198 }
199
200 for _, target := range targets {
Colin Cross44df5812019-02-15 23:06:46 -0800201 buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
Colin Cross800fe132019-02-11 14:21:24 -0800202 }
203 }
Colin Cross44df5812019-02-15 23:06:46 -0800204
205 return image
Colin Cross800fe132019-02-11 14:21:24 -0800206}
207
Colin Cross44df5812019-02-15 23:06:46 -0800208func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage,
Colin Cross800fe132019-02-11 14:21:24 -0800209 arch android.ArchType, profile android.Path, missingDeps []string) {
210
Colin Cross44df5812019-02-15 23:06:46 -0800211 global := dexpreoptGlobalConfig(ctx)
212
213 symbolsDir := image.symbolsDir.Join(ctx, "system/framework", arch.String())
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000214 symbolsFile := symbolsDir.Join(ctx, image.name+".oat")
Colin Cross44df5812019-02-15 23:06:46 -0800215 outputDir := image.dir.Join(ctx, "system/framework", arch.String())
216 outputPath := image.images[arch]
Colin Cross69f59a32019-02-15 10:39:37 -0800217 oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath, arch), "oat")
Colin Cross800fe132019-02-11 14:21:24 -0800218
219 rule := android.NewRuleBuilder()
220 rule.MissingDeps(missingDeps)
221
222 rule.Command().Text("mkdir").Flag("-p").Flag(symbolsDir.String())
223 rule.Command().Text("rm").Flag("-f").
224 Flag(symbolsDir.Join(ctx, "*.art").String()).
225 Flag(symbolsDir.Join(ctx, "*.oat").String()).
226 Flag(symbolsDir.Join(ctx, "*.invocation").String())
227 rule.Command().Text("rm").Flag("-f").
228 Flag(outputDir.Join(ctx, "*.art").String()).
229 Flag(outputDir.Join(ctx, "*.oat").String()).
230 Flag(outputDir.Join(ctx, "*.invocation").String())
231
232 cmd := rule.Command()
233
234 extraFlags := ctx.Config().Getenv("ART_BOOT_IMAGE_EXTRA_ARGS")
235 if extraFlags == "" {
236 // Use ANDROID_LOG_TAGS to suppress most logging by default...
237 cmd.Text(`ANDROID_LOG_TAGS="*:e"`)
238 } else {
239 // ...unless the boot image is generated specifically for testing, then allow all logging.
240 cmd.Text(`ANDROID_LOG_TAGS="*:v"`)
241 }
242
243 invocationPath := outputPath.ReplaceExtension(ctx, "invocation")
244
Colin Cross44df5812019-02-15 23:06:46 -0800245 cmd.Tool(global.Tools.Dex2oat).
Colin Cross800fe132019-02-11 14:21:24 -0800246 Flag("--avoid-storing-invocation").
Colin Cross69f59a32019-02-15 10:39:37 -0800247 FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath).
Colin Cross44df5812019-02-15 23:06:46 -0800248 Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatImageXms).
249 Flag("--runtime-arg").FlagWithArg("-Xmx", global.Dex2oatImageXmx)
Colin Cross800fe132019-02-11 14:21:24 -0800250
Colin Cross69f59a32019-02-15 10:39:37 -0800251 if profile != nil {
Colin Cross800fe132019-02-11 14:21:24 -0800252 cmd.FlagWithArg("--compiler-filter=", "speed-profile")
Colin Cross69f59a32019-02-15 10:39:37 -0800253 cmd.FlagWithInput("--profile-file=", profile)
Colin Cross44df5812019-02-15 23:06:46 -0800254 } else if global.PreloadedClasses.Valid() {
255 cmd.FlagWithInput("--image-classes=", global.PreloadedClasses.Path())
Colin Cross800fe132019-02-11 14:21:24 -0800256 }
257
Colin Cross44df5812019-02-15 23:06:46 -0800258 if global.DirtyImageObjects.Valid() {
259 cmd.FlagWithInput("--dirty-image-objects=", global.DirtyImageObjects.Path())
Colin Cross800fe132019-02-11 14:21:24 -0800260 }
261
262 cmd.
Colin Cross44df5812019-02-15 23:06:46 -0800263 FlagForEachInput("--dex-file=", image.dexPaths.Paths()).
264 FlagForEachArg("--dex-location=", image.dexLocations).
Colin Cross800fe132019-02-11 14:21:24 -0800265 Flag("--generate-debug-info").
266 Flag("--generate-build-id").
Colin Cross69f59a32019-02-15 10:39:37 -0800267 FlagWithOutput("--oat-symbols=", symbolsFile).
Colin Cross800fe132019-02-11 14:21:24 -0800268 Flag("--strip").
Colin Cross69f59a32019-02-15 10:39:37 -0800269 FlagWithOutput("--oat-file=", outputPath.ReplaceExtension(ctx, "oat")).
Colin Cross800fe132019-02-11 14:21:24 -0800270 FlagWithArg("--oat-location=", oatLocation).
Colin Cross69f59a32019-02-15 10:39:37 -0800271 FlagWithOutput("--image=", outputPath).
Colin Cross800fe132019-02-11 14:21:24 -0800272 FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress()).
273 FlagWithArg("--instruction-set=", arch.String()).
Colin Cross44df5812019-02-15 23:06:46 -0800274 FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]).
275 FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]).
276 FlagWithArg("--android-root=", global.EmptyDirectory).
Colin Cross800fe132019-02-11 14:21:24 -0800277 FlagWithArg("--no-inline-from=", "core-oj.jar").
278 Flag("--abort-on-hard-verifier-error")
279
Colin Cross44df5812019-02-15 23:06:46 -0800280 if global.BootFlags != "" {
281 cmd.Flag(global.BootFlags)
Colin Cross800fe132019-02-11 14:21:24 -0800282 }
283
284 if extraFlags != "" {
285 cmd.Flag(extraFlags)
286 }
287
Colin Cross0b9f31f2019-02-28 11:00:01 -0800288 cmd.Textf(`|| ( echo %s ; false )`, proptools.ShellEscape(failureMessage))
Colin Cross800fe132019-02-11 14:21:24 -0800289
290 installDir := filepath.Join("/system/framework", arch.String())
291 vdexInstallDir := filepath.Join("/system/framework")
292
293 var extraFiles android.WritablePaths
294 var vdexInstalls android.RuleBuilderInstalls
295 var unstrippedInstalls android.RuleBuilderInstalls
296
297 // dex preopt on the bootclasspath produces multiple files. The first dex file
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000298 // is converted into to 'name'.art (to match the legacy assumption that 'name'.art
299 // exists), and the rest are converted to 'name'-<jar>.art.
Colin Cross800fe132019-02-11 14:21:24 -0800300 // In addition, each .art file has an associated .oat and .vdex file, and an
301 // unstripped .oat file
Colin Cross44df5812019-02-15 23:06:46 -0800302 for i, m := range image.modules {
303 name := image.name
Colin Cross800fe132019-02-11 14:21:24 -0800304 if i != 0 {
305 name += "-" + m
306 }
307
308 art := outputDir.Join(ctx, name+".art")
309 oat := outputDir.Join(ctx, name+".oat")
310 vdex := outputDir.Join(ctx, name+".vdex")
311 unstrippedOat := symbolsDir.Join(ctx, name+".oat")
312
313 extraFiles = append(extraFiles, art, oat, vdex, unstrippedOat)
314
315 // Install the .oat and .art files.
Colin Cross69f59a32019-02-15 10:39:37 -0800316 rule.Install(art, filepath.Join(installDir, art.Base()))
317 rule.Install(oat, filepath.Join(installDir, oat.Base()))
Colin Cross800fe132019-02-11 14:21:24 -0800318
319 // The vdex files are identical between architectures, install them to a shared location. The Make rules will
320 // only use the install rules for one architecture, and will create symlinks into the architecture-specific
321 // directories.
322 vdexInstalls = append(vdexInstalls,
Colin Cross69f59a32019-02-15 10:39:37 -0800323 android.RuleBuilderInstall{vdex, filepath.Join(vdexInstallDir, vdex.Base())})
Colin Cross800fe132019-02-11 14:21:24 -0800324
325 // Install the unstripped oat files. The Make rules will put these in $(TARGET_OUT_UNSTRIPPED)
326 unstrippedInstalls = append(unstrippedInstalls,
Colin Cross69f59a32019-02-15 10:39:37 -0800327 android.RuleBuilderInstall{unstrippedOat, filepath.Join(installDir, unstrippedOat.Base())})
Colin Cross800fe132019-02-11 14:21:24 -0800328 }
329
Colin Cross69f59a32019-02-15 10:39:37 -0800330 cmd.ImplicitOutputs(extraFiles)
Colin Cross800fe132019-02-11 14:21:24 -0800331
Colin Cross44df5812019-02-15 23:06:46 -0800332 rule.Build(pctx, ctx, image.name+"JarsDexpreopt_"+arch.String(), "dexpreopt "+image.name+" jars "+arch.String())
Colin Cross800fe132019-02-11 14:21:24 -0800333
334 // save output and installed files for makevars
Colin Cross44df5812019-02-15 23:06:46 -0800335 image.installs[arch] = rule.Installs()
336 image.vdexInstalls[arch] = vdexInstalls
337 image.unstrippedInstalls[arch] = unstrippedInstalls
Colin Cross800fe132019-02-11 14:21:24 -0800338}
339
340const failureMessage = `ERROR: Dex2oat failed to compile a boot image.
341It is likely that the boot classpath is inconsistent.
342Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.`
343
Colin Cross44df5812019-02-15 23:06:46 -0800344func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath {
Nicolas Geoffray27c7cc62019-02-24 16:04:52 +0000345 global := dexpreoptGlobalConfig(ctx)
346
347 if !global.UseProfileForBootImage || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
348 return nil
349 }
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000350 return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000351 tools := global.Tools
Colin Cross800fe132019-02-11 14:21:24 -0800352
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000353 rule := android.NewRuleBuilder()
354 rule.MissingDeps(missingDeps)
Colin Cross800fe132019-02-11 14:21:24 -0800355
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000356 var bootImageProfile android.Path
357 if len(global.BootImageProfiles) > 1 {
358 combinedBootImageProfile := image.dir.Join(ctx, "boot-image-profile.txt")
359 rule.Command().Text("cat").Inputs(global.BootImageProfiles).Text(">").Output(combinedBootImageProfile)
360 bootImageProfile = combinedBootImageProfile
361 } else if len(global.BootImageProfiles) == 1 {
362 bootImageProfile = global.BootImageProfiles[0]
363 } else {
364 // If not set, use the default. Some branches like master-art-host don't have frameworks/base, so manually
365 // handle the case that the default is missing. Those branches won't attempt to build the profile rule,
366 // and if they do they'll get a missing deps error.
367 defaultProfile := "frameworks/base/config/boot-image-profile.txt"
368 path := android.ExistentPathForSource(ctx, defaultProfile)
369 if path.Valid() {
370 bootImageProfile = path.Path()
371 } else {
372 missingDeps = append(missingDeps, defaultProfile)
373 bootImageProfile = android.PathForOutput(ctx, "missing")
374 }
375 }
Colin Cross800fe132019-02-11 14:21:24 -0800376
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000377 profile := image.dir.Join(ctx, "boot.prof")
Colin Cross800fe132019-02-11 14:21:24 -0800378
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000379 rule.Command().
380 Text(`ANDROID_LOG_TAGS="*:e"`).
381 Tool(tools.Profman).
382 FlagWithInput("--create-profile-from=", bootImageProfile).
383 FlagForEachInput("--apk=", image.dexPaths.Paths()).
384 FlagForEachArg("--dex-location=", image.dexLocations).
385 FlagWithOutput("--reference-profile-file=", profile)
Colin Cross800fe132019-02-11 14:21:24 -0800386
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000387 rule.Install(profile, "/system/etc/boot-image.prof")
388
389 rule.Build(pctx, ctx, "bootJarsProfile", "profile boot jars")
390
391 image.profileInstalls = rule.Installs()
392
393 return profile
394 }).(android.WritablePath)
Colin Cross800fe132019-02-11 14:21:24 -0800395}
396
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000397var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule")
398
Colin Crossc9a4c362019-02-26 21:13:48 -0800399func dumpOatRules(ctx android.SingletonContext, image *bootImage) {
400 var archs []android.ArchType
401 for arch := range image.images {
402 archs = append(archs, arch)
403 }
404 sort.Slice(archs, func(i, j int) bool { return archs[i].String() < archs[j].String() })
405
406 var allPhonies android.Paths
407 for _, arch := range archs {
408 // Create a rule to call oatdump.
409 output := android.PathForOutput(ctx, "boot."+arch.String()+".oatdump.txt")
410 rule := android.NewRuleBuilder()
411 rule.Command().
412 // TODO: for now, use the debug version for better error reporting
413 Tool(ctx.Config().HostToolPath(ctx, "oatdumpd")).
414 FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPaths.Paths(), ":").
415 FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocations, ":").
416 FlagWithArg("--image=", dexpreopt.PathToLocation(image.images[arch], arch)).Implicit(image.images[arch]).
417 FlagWithOutput("--output=", output).
418 FlagWithArg("--instruction-set=", arch.String())
419 rule.Build(pctx, ctx, "dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String())
420
421 // Create a phony rule that depends on the output file and prints the path.
422 phony := android.PathForPhony(ctx, "dump-oat-boot-"+arch.String())
423 rule = android.NewRuleBuilder()
424 rule.Command().
425 Implicit(output).
426 ImplicitOutput(phony).
427 Text("echo").FlagWithArg("Output in ", output.String())
428 rule.Build(pctx, ctx, "phony-dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String())
429
430 allPhonies = append(allPhonies, phony)
431 }
432
433 phony := android.PathForPhony(ctx, "dump-oat-boot")
434 ctx.Build(pctx, android.BuildParams{
435 Rule: android.Phony,
436 Output: phony,
437 Inputs: allPhonies,
438 Description: "dump-oat-boot",
439 })
440
441}
442
Colin Cross44df5812019-02-15 23:06:46 -0800443// Export paths for default boot image to Make
444func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) {
445 image := d.defaultBootImage
446 if image != nil {
Colin Cross44df5812019-02-15 23:06:46 -0800447 ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String())
Colin Cross44df5812019-02-15 23:06:46 -0800448 ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPaths.Strings(), " "))
449 ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocations, " "))
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000450
451 var imageNames []string
452 for _, current := range append(d.otherImages, image) {
453 imageNames = append(imageNames, current.name)
Colin Cross1bdf6502019-04-11 14:07:04 -0700454 var arches []android.ArchType
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000455 for arch, _ := range current.images {
Colin Cross1bdf6502019-04-11 14:07:04 -0700456 arches = append(arches, arch)
457 }
458
459 sort.Slice(arches, func(i, j int) bool { return arches[i].String() < arches[j].String() })
460
461 for _, arch := range arches {
Nicolas Geoffray72892f12019-02-22 15:34:40 +0000462 ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.vdexInstalls[arch].String())
463 ctx.Strict("DEXPREOPT_IMAGE_"+current.name+"_"+arch.String(), current.images[arch].String())
464 ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.installs[arch].String())
465 ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.unstrippedInstalls[arch].String())
466 }
467 }
468 ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " "))
Colin Cross800fe132019-02-11 14:21:24 -0800469 }
Colin Cross800fe132019-02-11 14:21:24 -0800470}