Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 1 | // 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 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
| 18 | "path/filepath" |
Colin Cross | c9a4c36 | 2019-02-26 21:13:48 -0800 | [diff] [blame] | 19 | "sort" |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 20 | "strings" |
| 21 | |
| 22 | "android/soong/android" |
| 23 | "android/soong/dexpreopt" |
| 24 | |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 25 | "github.com/google/blueprint/proptools" |
| 26 | ) |
| 27 | |
| 28 | func init() { |
| 29 | android.RegisterSingletonType("dex_bootjars", dexpreoptBootJarsFactory) |
| 30 | } |
| 31 | |
| 32 | // The image "location" is a symbolic path that with multiarchitecture |
| 33 | // support doesn't really exist on the device. Typically it is |
| 34 | // /system/framework/boot.art and should be the same for all supported |
| 35 | // architectures on the device. The concrete architecture specific |
| 36 | // content actually ends up in a "filename" that contains an |
| 37 | // architecture specific directory name such as arm, arm64, mips, |
| 38 | // mips64, x86, x86_64. |
| 39 | // |
| 40 | // Here are some example values for an x86_64 / x86 configuration: |
| 41 | // |
| 42 | // bootImages["x86_64"] = "out/soong/generic_x86_64/dex_bootjars/system/framework/x86_64/boot.art" |
| 43 | // dexpreopt.PathToLocation(bootImages["x86_64"], "x86_64") = "out/soong/generic_x86_64/dex_bootjars/system/framework/boot.art" |
| 44 | // |
| 45 | // bootImages["x86"] = "out/soong/generic_x86_64/dex_bootjars/system/framework/x86/boot.art" |
| 46 | // dexpreopt.PathToLocation(bootImages["x86"])= "out/soong/generic_x86_64/dex_bootjars/system/framework/boot.art" |
| 47 | // |
| 48 | // The location is passed as an argument to the ART tools like dex2oat instead of the real path. The ART tools |
| 49 | // will then reconstruct the real path, so the rules must have a dependency on the real path. |
| 50 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 51 | type bootImageConfig struct { |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 52 | // Whether this image is an extension. |
| 53 | extension bool |
| 54 | |
| 55 | // Image name (used in directory names and ninja rule names). |
| 56 | name string |
| 57 | |
| 58 | // Basename of the image: the resulting filenames are <stem>[-<jar>].{art,oat,vdex}. |
| 59 | stem string |
| 60 | |
| 61 | // Output directory for the image files. |
| 62 | dir android.OutputPath |
| 63 | |
| 64 | // Output directory for the image files with debug symbols. |
| 65 | symbolsDir android.OutputPath |
| 66 | |
| 67 | // Subdirectory where the image files are installed. |
| 68 | installSubdir string |
| 69 | |
| 70 | // Targets for which the image is generated. |
| 71 | targets []android.Target |
| 72 | |
| 73 | // The names of jars that constitute this image. |
| 74 | modules []string |
| 75 | |
| 76 | // The "locations" of jars. |
| 77 | dexLocations []string // for this image |
| 78 | dexLocationsDeps []string // for the dependency images and in this image |
| 79 | |
| 80 | // File paths to jars. |
| 81 | dexPaths android.WritablePaths // for this image |
| 82 | dexPathsDeps android.WritablePaths // for the dependency images and in this image |
| 83 | |
| 84 | // The "locations" of the dependency images and in this image. |
| 85 | imageLocations []string |
| 86 | |
| 87 | // Paths to image files (grouped by target). |
| 88 | images map[android.ArchType]android.OutputPath // first image file |
| 89 | imagesDeps map[android.ArchType]android.OutputPaths // all files |
| 90 | |
| 91 | // File path to a zip archive with all image files (or nil, if not needed). |
| 92 | zip android.WritablePath |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 93 | } |
| 94 | |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 95 | func (image bootImageConfig) moduleName(idx int) string { |
| 96 | // Dexpreopt on the boot class path produces multiple files. The first dex file |
| 97 | // is converted into 'name'.art (to match the legacy assumption that 'name'.art |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 98 | // exists), and the rest are converted to 'name'-<jar>.art. |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 99 | m := image.modules[idx] |
| 100 | name := image.stem |
| 101 | if idx != 0 || image.extension { |
| 102 | name += "-" + stemOf(m) |
| 103 | } |
| 104 | return name |
| 105 | } |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 106 | |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 107 | func (image bootImageConfig) firstModuleNameOrStem() string { |
| 108 | if len(image.modules) > 0 { |
| 109 | return image.moduleName(0) |
| 110 | } else { |
| 111 | return image.stem |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.OutputPath, exts ...string) android.OutputPaths { |
| 116 | ret := make(android.OutputPaths, 0, len(image.modules)*len(exts)) |
| 117 | for i := range image.modules { |
| 118 | name := image.moduleName(i) |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 119 | for _, ext := range exts { |
| 120 | ret = append(ret, dir.Join(ctx, name+ext)) |
| 121 | } |
| 122 | } |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 123 | return ret |
| 124 | } |
| 125 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 126 | type bootImage struct { |
| 127 | bootImageConfig |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 128 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 129 | installs map[android.ArchType]android.RuleBuilderInstalls |
| 130 | vdexInstalls map[android.ArchType]android.RuleBuilderInstalls |
| 131 | unstrippedInstalls map[android.ArchType]android.RuleBuilderInstalls |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 132 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 133 | profileInstalls android.RuleBuilderInstalls |
| 134 | } |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 135 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 136 | func newBootImage(ctx android.PathContext, config bootImageConfig) *bootImage { |
| 137 | image := &bootImage{ |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 138 | bootImageConfig: config, |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 139 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 140 | installs: make(map[android.ArchType]android.RuleBuilderInstalls), |
| 141 | vdexInstalls: make(map[android.ArchType]android.RuleBuilderInstalls), |
| 142 | unstrippedInstalls: make(map[android.ArchType]android.RuleBuilderInstalls), |
| 143 | } |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 144 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 145 | return image |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | func concat(lists ...[]string) []string { |
| 149 | var size int |
| 150 | for _, l := range lists { |
| 151 | size += len(l) |
| 152 | } |
| 153 | ret := make([]string, 0, size) |
| 154 | for _, l := range lists { |
| 155 | ret = append(ret, l...) |
| 156 | } |
| 157 | return ret |
| 158 | } |
| 159 | |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 160 | func dexpreoptBootJarsFactory() android.Singleton { |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 161 | return &dexpreoptBootJars{} |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | func skipDexpreoptBootJars(ctx android.PathContext) bool { |
Ulya Trafimovich | acb33e0 | 2019-11-01 17:57:29 +0000 | [diff] [blame] | 165 | if dexpreoptGlobalConfig(ctx).DisablePreopt { |
| 166 | return true |
| 167 | } |
| 168 | |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 169 | if ctx.Config().UnbundledBuild() { |
| 170 | return true |
| 171 | } |
| 172 | |
| 173 | if len(ctx.Config().Targets[android.Android]) == 0 { |
| 174 | // Host-only build |
| 175 | return true |
| 176 | } |
| 177 | |
| 178 | return false |
| 179 | } |
| 180 | |
Ulyana Trafimovich | 3fae766 | 2019-12-11 10:31:32 +0000 | [diff] [blame] | 181 | func skipDexpreoptArtBootJars(ctx android.BuilderContext) bool { |
| 182 | // with EMMA_INSTRUMENT_FRAMEWORK=true ART boot class path libraries have dependencies on framework, |
| 183 | // therefore dexpreopt ART libraries cannot be dexpreopted in isolation => no ART boot image |
| 184 | return ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") |
| 185 | } |
| 186 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 187 | type dexpreoptBootJars struct { |
| 188 | defaultBootImage *bootImage |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 189 | otherImages []*bootImage |
Colin Cross | 2d00f0d | 2019-05-09 21:50:00 -0700 | [diff] [blame] | 190 | |
| 191 | dexpreoptConfigForMake android.WritablePath |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 192 | } |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 193 | |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 194 | // Accessor function for the apex package. Returns nil if dexpreopt is disabled. |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 195 | func DexpreoptedArtApexJars(ctx android.BuilderContext) map[android.ArchType]android.OutputPaths { |
Ulyana Trafimovich | 3fae766 | 2019-12-11 10:31:32 +0000 | [diff] [blame] | 196 | if skipDexpreoptBootJars(ctx) || skipDexpreoptArtBootJars(ctx) { |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 197 | return nil |
| 198 | } |
| 199 | return artBootImageConfig(ctx).imagesDeps |
| 200 | } |
| 201 | |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 202 | // dexpreoptBoot singleton rules |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 203 | func (d *dexpreoptBootJars) GenerateBuildActions(ctx android.SingletonContext) { |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 204 | if skipDexpreoptBootJars(ctx) { |
| 205 | return |
| 206 | } |
| 207 | |
Colin Cross | 2d00f0d | 2019-05-09 21:50:00 -0700 | [diff] [blame] | 208 | d.dexpreoptConfigForMake = android.PathForOutput(ctx, ctx.Config().DeviceName(), "dexpreopt.config") |
| 209 | writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake) |
| 210 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 211 | global := dexpreoptGlobalConfig(ctx) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 212 | |
| 213 | // Skip recompiling the boot image for the second sanitization phase. We'll get separate paths |
| 214 | // and invalidate first-stage artifacts which are crucial to SANITIZE_LITE builds. |
| 215 | // Note: this is technically incorrect. Compiled code contains stack checks which may depend |
| 216 | // on ASAN settings. |
| 217 | if len(ctx.Config().SanitizeDevice()) == 1 && |
| 218 | ctx.Config().SanitizeDevice()[0] == "address" && |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 219 | global.SanitizeLite { |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 220 | return |
| 221 | } |
| 222 | |
Lingfeng Yang | 54191fa | 2019-12-19 16:40:09 +0000 | [diff] [blame] | 223 | // Always create the default boot image first, to get a unique profile rule for all images. |
| 224 | d.defaultBootImage = buildBootImage(ctx, defaultBootImageConfig(ctx)) |
Ulya Trafimovich | 48b3b3c | 2019-12-13 13:34:06 +0000 | [diff] [blame] | 225 | if !skipDexpreoptArtBootJars(ctx) { |
Lingfeng Yang | 54191fa | 2019-12-19 16:40:09 +0000 | [diff] [blame] | 226 | // Create boot image for the ART apex (build artifacts are accessed via the global boot image config). |
Ulya Trafimovich | 48b3b3c | 2019-12-13 13:34:06 +0000 | [diff] [blame] | 227 | d.otherImages = append(d.otherImages, buildBootImage(ctx, artBootImageConfig(ctx))) |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 228 | } |
Lingfeng Yang | 54191fa | 2019-12-19 16:40:09 +0000 | [diff] [blame] | 229 | if global.GenerateApexImage { |
| 230 | // Create boot images for the JIT-zygote experiment. |
| 231 | d.otherImages = append(d.otherImages, buildBootImage(ctx, apexBootImageConfig(ctx))) |
| 232 | } |
Colin Cross | c9a4c36 | 2019-02-26 21:13:48 -0800 | [diff] [blame] | 233 | |
| 234 | dumpOatRules(ctx, d.defaultBootImage) |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | // buildBootImage takes a bootImageConfig, creates rules to build it, and returns a *bootImage. |
| 238 | func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootImage { |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 239 | image := newBootImage(ctx, config) |
| 240 | |
| 241 | bootDexJars := make(android.Paths, len(image.modules)) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 242 | ctx.VisitAllModules(func(module android.Module) { |
| 243 | // Collect dex jar paths for the modules listed above. |
Colin Cross | 42be761 | 2019-02-21 18:12:14 -0800 | [diff] [blame] | 244 | if j, ok := module.(interface{ DexJar() android.Path }); ok { |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 245 | name := ctx.ModuleName(module) |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 246 | if i := android.IndexList(name, image.modules); i != -1 { |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 247 | bootDexJars[i] = j.DexJar() |
| 248 | } |
| 249 | } |
| 250 | }) |
| 251 | |
| 252 | var missingDeps []string |
| 253 | // Ensure all modules were converted to paths |
| 254 | for i := range bootDexJars { |
| 255 | if bootDexJars[i] == nil { |
| 256 | if ctx.Config().AllowMissingDependencies() { |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 257 | missingDeps = append(missingDeps, image.modules[i]) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 258 | bootDexJars[i] = android.PathForOutput(ctx, "missing") |
| 259 | } else { |
| 260 | ctx.Errorf("failed to find dex jar path for module %q", |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 261 | image.modules[i]) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | // The path to bootclasspath dex files needs to be known at module GenerateAndroidBuildAction time, before |
| 267 | // the bootclasspath modules have been compiled. Copy the dex jars there so the module rules that have |
| 268 | // already been set up can find them. |
| 269 | for i := range bootDexJars { |
| 270 | ctx.Build(pctx, android.BuildParams{ |
| 271 | Rule: android.Cp, |
| 272 | Input: bootDexJars[i], |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 273 | Output: image.dexPaths[i], |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 274 | }) |
| 275 | } |
| 276 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 277 | profile := bootImageProfileRule(ctx, image, missingDeps) |
Nicolas Geoffray | e710242 | 2019-07-24 13:19:29 +0100 | [diff] [blame] | 278 | bootFrameworkProfileRule(ctx, image, missingDeps) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 279 | |
Colin Cross | df8eebe | 2019-04-09 15:29:41 -0700 | [diff] [blame] | 280 | var allFiles android.Paths |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 281 | for _, target := range image.targets { |
| 282 | files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps) |
| 283 | allFiles = append(allFiles, files.Paths()...) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 284 | } |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 285 | |
Colin Cross | df8eebe | 2019-04-09 15:29:41 -0700 | [diff] [blame] | 286 | if image.zip != nil { |
| 287 | rule := android.NewRuleBuilder() |
| 288 | rule.Command(). |
Colin Cross | ee94d6a | 2019-07-08 17:08:34 -0700 | [diff] [blame] | 289 | BuiltTool(ctx, "soong_zip"). |
Colin Cross | df8eebe | 2019-04-09 15:29:41 -0700 | [diff] [blame] | 290 | FlagWithOutput("-o ", image.zip). |
| 291 | FlagWithArg("-C ", image.dir.String()). |
| 292 | FlagWithInputList("-f ", allFiles, " -f ") |
| 293 | |
| 294 | rule.Build(pctx, ctx, "zip_"+image.name, "zip "+image.name+" image") |
| 295 | } |
| 296 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 297 | return image |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 298 | } |
| 299 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 300 | func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage, |
Colin Cross | df8eebe | 2019-04-09 15:29:41 -0700 | [diff] [blame] | 301 | arch android.ArchType, profile android.Path, missingDeps []string) android.WritablePaths { |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 302 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 303 | global := dexpreoptGlobalConfig(ctx) |
| 304 | |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 305 | symbolsDir := image.symbolsDir.Join(ctx, image.installSubdir, arch.String()) |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 306 | symbolsFile := symbolsDir.Join(ctx, image.stem+".oat") |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 307 | outputDir := image.dir.Join(ctx, image.installSubdir, arch.String()) |
| 308 | outputPath := outputDir.Join(ctx, image.stem+".oat") |
| 309 | oatLocation := dexpreopt.PathToLocation(outputPath, arch) |
| 310 | imagePath := outputPath.ReplaceExtension(ctx, "art") |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 311 | |
| 312 | rule := android.NewRuleBuilder() |
| 313 | rule.MissingDeps(missingDeps) |
| 314 | |
| 315 | rule.Command().Text("mkdir").Flag("-p").Flag(symbolsDir.String()) |
| 316 | rule.Command().Text("rm").Flag("-f"). |
| 317 | Flag(symbolsDir.Join(ctx, "*.art").String()). |
| 318 | Flag(symbolsDir.Join(ctx, "*.oat").String()). |
| 319 | Flag(symbolsDir.Join(ctx, "*.invocation").String()) |
| 320 | rule.Command().Text("rm").Flag("-f"). |
| 321 | Flag(outputDir.Join(ctx, "*.art").String()). |
| 322 | Flag(outputDir.Join(ctx, "*.oat").String()). |
| 323 | Flag(outputDir.Join(ctx, "*.invocation").String()) |
| 324 | |
| 325 | cmd := rule.Command() |
| 326 | |
| 327 | extraFlags := ctx.Config().Getenv("ART_BOOT_IMAGE_EXTRA_ARGS") |
| 328 | if extraFlags == "" { |
| 329 | // Use ANDROID_LOG_TAGS to suppress most logging by default... |
| 330 | cmd.Text(`ANDROID_LOG_TAGS="*:e"`) |
| 331 | } else { |
| 332 | // ...unless the boot image is generated specifically for testing, then allow all logging. |
| 333 | cmd.Text(`ANDROID_LOG_TAGS="*:v"`) |
| 334 | } |
| 335 | |
| 336 | invocationPath := outputPath.ReplaceExtension(ctx, "invocation") |
| 337 | |
Martin Stjernholm | c52aaf1 | 2020-01-06 23:11:37 +0000 | [diff] [blame^] | 338 | cmd.Tool(global.SoongConfig.Dex2oat). |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 339 | Flag("--avoid-storing-invocation"). |
Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 340 | FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath). |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 341 | Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatImageXms). |
| 342 | Flag("--runtime-arg").FlagWithArg("-Xmx", global.Dex2oatImageXmx) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 343 | |
Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 344 | if profile != nil { |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 345 | cmd.FlagWithArg("--compiler-filter=", "speed-profile") |
Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 346 | cmd.FlagWithInput("--profile-file=", profile) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 347 | } |
| 348 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 349 | if global.DirtyImageObjects.Valid() { |
| 350 | cmd.FlagWithInput("--dirty-image-objects=", global.DirtyImageObjects.Path()) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 351 | } |
| 352 | |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 353 | if image.extension { |
| 354 | artImage := artBootImageConfig(ctx).images[arch] |
| 355 | cmd. |
| 356 | Flag("--runtime-arg").FlagWithInputList("-Xbootclasspath:", image.dexPathsDeps.Paths(), ":"). |
| 357 | Flag("--runtime-arg").FlagWithList("-Xbootclasspath-locations:", image.dexLocationsDeps, ":"). |
| 358 | FlagWithArg("--boot-image=", dexpreopt.PathToLocation(artImage, arch)).Implicit(artImage) |
| 359 | } else { |
| 360 | cmd.FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress()) |
| 361 | } |
| 362 | |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 363 | cmd. |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 364 | FlagForEachInput("--dex-file=", image.dexPaths.Paths()). |
| 365 | FlagForEachArg("--dex-location=", image.dexLocations). |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 366 | Flag("--generate-debug-info"). |
| 367 | Flag("--generate-build-id"). |
Mathieu Chartier | 54fd807 | 2019-07-26 13:50:04 -0700 | [diff] [blame] | 368 | Flag("--image-format=lz4hc"). |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 369 | FlagWithArg("--oat-symbols=", symbolsFile.String()). |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 370 | Flag("--strip"). |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 371 | FlagWithArg("--oat-file=", outputPath.String()). |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 372 | FlagWithArg("--oat-location=", oatLocation). |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 373 | FlagWithArg("--image=", imagePath.String()). |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 374 | FlagWithArg("--instruction-set=", arch.String()). |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 375 | FlagWithArg("--instruction-set-variant=", global.CpuVariant[arch]). |
| 376 | FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]). |
| 377 | FlagWithArg("--android-root=", global.EmptyDirectory). |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 378 | FlagWithArg("--no-inline-from=", "core-oj.jar"). |
| 379 | Flag("--abort-on-hard-verifier-error") |
| 380 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 381 | if global.BootFlags != "" { |
| 382 | cmd.Flag(global.BootFlags) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | if extraFlags != "" { |
| 386 | cmd.Flag(extraFlags) |
| 387 | } |
| 388 | |
Colin Cross | 0b9f31f | 2019-02-28 11:00:01 -0800 | [diff] [blame] | 389 | cmd.Textf(`|| ( echo %s ; false )`, proptools.ShellEscape(failureMessage)) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 390 | |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 391 | installDir := filepath.Join("/", image.installSubdir, arch.String()) |
| 392 | vdexInstallDir := filepath.Join("/", image.installSubdir) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 393 | |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 394 | var vdexInstalls android.RuleBuilderInstalls |
| 395 | var unstrippedInstalls android.RuleBuilderInstalls |
| 396 | |
Colin Cross | df8eebe | 2019-04-09 15:29:41 -0700 | [diff] [blame] | 397 | var zipFiles android.WritablePaths |
| 398 | |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 399 | for _, artOrOat := range image.moduleFiles(ctx, outputDir, ".art", ".oat") { |
| 400 | cmd.ImplicitOutput(artOrOat) |
| 401 | zipFiles = append(zipFiles, artOrOat) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 402 | |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 403 | // Install the .oat and .art files |
| 404 | rule.Install(artOrOat, filepath.Join(installDir, artOrOat.Base())) |
| 405 | } |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 406 | |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 407 | for _, vdex := range image.moduleFiles(ctx, outputDir, ".vdex") { |
| 408 | cmd.ImplicitOutput(vdex) |
| 409 | zipFiles = append(zipFiles, vdex) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 410 | |
| 411 | // The vdex files are identical between architectures, install them to a shared location. The Make rules will |
| 412 | // only use the install rules for one architecture, and will create symlinks into the architecture-specific |
| 413 | // directories. |
| 414 | vdexInstalls = append(vdexInstalls, |
Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 415 | android.RuleBuilderInstall{vdex, filepath.Join(vdexInstallDir, vdex.Base())}) |
Dan Willemsen | 0f41678 | 2019-06-13 21:44:53 +0000 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | for _, unstrippedOat := range image.moduleFiles(ctx, symbolsDir, ".oat") { |
| 419 | cmd.ImplicitOutput(unstrippedOat) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 420 | |
| 421 | // Install the unstripped oat files. The Make rules will put these in $(TARGET_OUT_UNSTRIPPED) |
| 422 | unstrippedInstalls = append(unstrippedInstalls, |
Colin Cross | 69f59a3 | 2019-02-15 10:39:37 -0800 | [diff] [blame] | 423 | android.RuleBuilderInstall{unstrippedOat, filepath.Join(installDir, unstrippedOat.Base())}) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 424 | } |
| 425 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 426 | rule.Build(pctx, ctx, image.name+"JarsDexpreopt_"+arch.String(), "dexpreopt "+image.name+" jars "+arch.String()) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 427 | |
| 428 | // save output and installed files for makevars |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 429 | image.installs[arch] = rule.Installs() |
| 430 | image.vdexInstalls[arch] = vdexInstalls |
| 431 | image.unstrippedInstalls[arch] = unstrippedInstalls |
Colin Cross | df8eebe | 2019-04-09 15:29:41 -0700 | [diff] [blame] | 432 | |
| 433 | return zipFiles |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | const failureMessage = `ERROR: Dex2oat failed to compile a boot image. |
| 437 | It is likely that the boot classpath is inconsistent. |
| 438 | Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.` |
| 439 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 440 | func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath { |
Nicolas Geoffray | 27c7cc6 | 2019-02-24 16:04:52 +0000 | [diff] [blame] | 441 | global := dexpreoptGlobalConfig(ctx) |
| 442 | |
Mathieu Chartier | 6adeee1 | 2019-06-26 10:01:36 -0700 | [diff] [blame] | 443 | if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { |
Nicolas Geoffray | 27c7cc6 | 2019-02-24 16:04:52 +0000 | [diff] [blame] | 444 | return nil |
| 445 | } |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 446 | profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} { |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 447 | defaultProfile := "frameworks/base/config/boot-image-profile.txt" |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 448 | |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 449 | rule := android.NewRuleBuilder() |
| 450 | rule.MissingDeps(missingDeps) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 451 | |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 452 | var bootImageProfile android.Path |
| 453 | if len(global.BootImageProfiles) > 1 { |
| 454 | combinedBootImageProfile := image.dir.Join(ctx, "boot-image-profile.txt") |
| 455 | rule.Command().Text("cat").Inputs(global.BootImageProfiles).Text(">").Output(combinedBootImageProfile) |
| 456 | bootImageProfile = combinedBootImageProfile |
| 457 | } else if len(global.BootImageProfiles) == 1 { |
| 458 | bootImageProfile = global.BootImageProfiles[0] |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 459 | } else if path := android.ExistentPathForSource(ctx, defaultProfile); path.Valid() { |
| 460 | bootImageProfile = path.Path() |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 461 | } else { |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 462 | // No profile (not even a default one, which is the case on some branches |
| 463 | // like master-art-host that don't have frameworks/base). |
| 464 | // Return nil and continue without profile. |
| 465 | return nil |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 466 | } |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 467 | |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 468 | profile := image.dir.Join(ctx, "boot.prof") |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 469 | |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 470 | rule.Command(). |
| 471 | Text(`ANDROID_LOG_TAGS="*:e"`). |
Martin Stjernholm | c52aaf1 | 2020-01-06 23:11:37 +0000 | [diff] [blame^] | 472 | Tool(global.SoongConfig.Profman). |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 473 | FlagWithInput("--create-profile-from=", bootImageProfile). |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 474 | FlagForEachInput("--apk=", image.dexPathsDeps.Paths()). |
| 475 | FlagForEachArg("--dex-location=", image.dexLocationsDeps). |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 476 | FlagWithOutput("--reference-profile-file=", profile) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 477 | |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 478 | rule.Install(profile, "/system/etc/boot-image.prof") |
| 479 | |
| 480 | rule.Build(pctx, ctx, "bootJarsProfile", "profile boot jars") |
| 481 | |
| 482 | image.profileInstalls = rule.Installs() |
| 483 | |
| 484 | return profile |
Ulyana Trafimovich | de53441 | 2019-11-08 10:51:01 +0000 | [diff] [blame] | 485 | }) |
| 486 | if profile == nil { |
| 487 | return nil // wrap nil into a typed pointer with value nil |
| 488 | } |
| 489 | return profile.(android.WritablePath) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 490 | } |
| 491 | |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 492 | var bootImageProfileRuleKey = android.NewOnceKey("bootImageProfileRule") |
| 493 | |
Nicolas Geoffray | e710242 | 2019-07-24 13:19:29 +0100 | [diff] [blame] | 494 | func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath { |
| 495 | global := dexpreoptGlobalConfig(ctx) |
| 496 | |
| 497 | if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { |
| 498 | return nil |
| 499 | } |
| 500 | return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} { |
Nicolas Geoffray | e710242 | 2019-07-24 13:19:29 +0100 | [diff] [blame] | 501 | rule := android.NewRuleBuilder() |
| 502 | rule.MissingDeps(missingDeps) |
| 503 | |
| 504 | // Some branches like master-art-host don't have frameworks/base, so manually |
| 505 | // handle the case that the default is missing. Those branches won't attempt to build the profile rule, |
| 506 | // and if they do they'll get a missing deps error. |
| 507 | defaultProfile := "frameworks/base/config/boot-profile.txt" |
| 508 | path := android.ExistentPathForSource(ctx, defaultProfile) |
| 509 | var bootFrameworkProfile android.Path |
| 510 | if path.Valid() { |
| 511 | bootFrameworkProfile = path.Path() |
| 512 | } else { |
| 513 | missingDeps = append(missingDeps, defaultProfile) |
| 514 | bootFrameworkProfile = android.PathForOutput(ctx, "missing") |
| 515 | } |
| 516 | |
| 517 | profile := image.dir.Join(ctx, "boot.bprof") |
| 518 | |
| 519 | rule.Command(). |
| 520 | Text(`ANDROID_LOG_TAGS="*:e"`). |
Martin Stjernholm | c52aaf1 | 2020-01-06 23:11:37 +0000 | [diff] [blame^] | 521 | Tool(global.SoongConfig.Profman). |
Nicolas Geoffray | e710242 | 2019-07-24 13:19:29 +0100 | [diff] [blame] | 522 | Flag("--generate-boot-profile"). |
| 523 | FlagWithInput("--create-profile-from=", bootFrameworkProfile). |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 524 | FlagForEachInput("--apk=", image.dexPathsDeps.Paths()). |
| 525 | FlagForEachArg("--dex-location=", image.dexLocationsDeps). |
Nicolas Geoffray | e710242 | 2019-07-24 13:19:29 +0100 | [diff] [blame] | 526 | FlagWithOutput("--reference-profile-file=", profile) |
| 527 | |
| 528 | rule.Install(profile, "/system/etc/boot-image.bprof") |
| 529 | rule.Build(pctx, ctx, "bootFrameworkProfile", "profile boot framework jars") |
| 530 | image.profileInstalls = append(image.profileInstalls, rule.Installs()...) |
| 531 | |
| 532 | return profile |
| 533 | }).(android.WritablePath) |
| 534 | } |
| 535 | |
| 536 | var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule") |
| 537 | |
Colin Cross | c9a4c36 | 2019-02-26 21:13:48 -0800 | [diff] [blame] | 538 | func dumpOatRules(ctx android.SingletonContext, image *bootImage) { |
| 539 | var archs []android.ArchType |
| 540 | for arch := range image.images { |
| 541 | archs = append(archs, arch) |
| 542 | } |
| 543 | sort.Slice(archs, func(i, j int) bool { return archs[i].String() < archs[j].String() }) |
| 544 | |
| 545 | var allPhonies android.Paths |
| 546 | for _, arch := range archs { |
| 547 | // Create a rule to call oatdump. |
| 548 | output := android.PathForOutput(ctx, "boot."+arch.String()+".oatdump.txt") |
| 549 | rule := android.NewRuleBuilder() |
| 550 | rule.Command(). |
| 551 | // TODO: for now, use the debug version for better error reporting |
Colin Cross | ee94d6a | 2019-07-08 17:08:34 -0700 | [diff] [blame] | 552 | BuiltTool(ctx, "oatdumpd"). |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 553 | FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":"). |
| 554 | FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":"). |
Ulya Trafimovich | 163664a | 2019-12-06 13:42:21 +0000 | [diff] [blame] | 555 | FlagWithArg("--image=", strings.Join(image.imageLocations, ":")).Implicits(image.imagesDeps[arch].Paths()). |
Colin Cross | c9a4c36 | 2019-02-26 21:13:48 -0800 | [diff] [blame] | 556 | FlagWithOutput("--output=", output). |
| 557 | FlagWithArg("--instruction-set=", arch.String()) |
| 558 | rule.Build(pctx, ctx, "dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String()) |
| 559 | |
| 560 | // Create a phony rule that depends on the output file and prints the path. |
| 561 | phony := android.PathForPhony(ctx, "dump-oat-boot-"+arch.String()) |
| 562 | rule = android.NewRuleBuilder() |
| 563 | rule.Command(). |
| 564 | Implicit(output). |
| 565 | ImplicitOutput(phony). |
| 566 | Text("echo").FlagWithArg("Output in ", output.String()) |
| 567 | rule.Build(pctx, ctx, "phony-dump-oat-boot-"+arch.String(), "dump oat boot "+arch.String()) |
| 568 | |
| 569 | allPhonies = append(allPhonies, phony) |
| 570 | } |
| 571 | |
| 572 | phony := android.PathForPhony(ctx, "dump-oat-boot") |
| 573 | ctx.Build(pctx, android.BuildParams{ |
| 574 | Rule: android.Phony, |
| 575 | Output: phony, |
| 576 | Inputs: allPhonies, |
| 577 | Description: "dump-oat-boot", |
| 578 | }) |
| 579 | |
| 580 | } |
| 581 | |
Colin Cross | 2d00f0d | 2019-05-09 21:50:00 -0700 | [diff] [blame] | 582 | func writeGlobalConfigForMake(ctx android.SingletonContext, path android.WritablePath) { |
| 583 | data := dexpreoptGlobalConfigRaw(ctx).data |
| 584 | |
| 585 | ctx.Build(pctx, android.BuildParams{ |
| 586 | Rule: android.WriteFile, |
| 587 | Output: path, |
| 588 | Args: map[string]string{ |
| 589 | "content": string(data), |
| 590 | }, |
| 591 | }) |
| 592 | } |
| 593 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 594 | // Export paths for default boot image to Make |
| 595 | func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { |
Colin Cross | 2d00f0d | 2019-05-09 21:50:00 -0700 | [diff] [blame] | 596 | if d.dexpreoptConfigForMake != nil { |
| 597 | ctx.Strict("DEX_PREOPT_CONFIG_FOR_MAKE", d.dexpreoptConfigForMake.String()) |
Martin Stjernholm | c52aaf1 | 2020-01-06 23:11:37 +0000 | [diff] [blame^] | 598 | ctx.Strict("DEX_PREOPT_SOONG_CONFIG_FOR_MAKE", android.PathForOutput(ctx, "dexpreopt_soong.config").String()) |
Colin Cross | 2d00f0d | 2019-05-09 21:50:00 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 601 | image := d.defaultBootImage |
| 602 | if image != nil { |
Colin Cross | 44df581 | 2019-02-15 23:06:46 -0800 | [diff] [blame] | 603 | ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String()) |
Ulya Trafimovich | 4d2eeed | 2019-11-08 10:54:21 +0000 | [diff] [blame] | 604 | ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPathsDeps.Strings(), " ")) |
| 605 | ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocationsDeps, " ")) |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 606 | |
| 607 | var imageNames []string |
| 608 | for _, current := range append(d.otherImages, image) { |
| 609 | imageNames = append(imageNames, current.name) |
Colin Cross | 91268c6 | 2019-04-11 14:07:04 -0700 | [diff] [blame] | 610 | var arches []android.ArchType |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 611 | for arch, _ := range current.images { |
Colin Cross | 91268c6 | 2019-04-11 14:07:04 -0700 | [diff] [blame] | 612 | arches = append(arches, arch) |
| 613 | } |
| 614 | |
| 615 | sort.Slice(arches, func(i, j int) bool { return arches[i].String() < arches[j].String() }) |
| 616 | |
| 617 | for _, arch := range arches { |
Ulya Trafimovich | 3391a1e | 2020-01-03 17:33:17 +0000 | [diff] [blame] | 618 | sfx := current.name + "_" + arch.String() |
| 619 | ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+sfx, current.vdexInstalls[arch].String()) |
| 620 | ctx.Strict("DEXPREOPT_IMAGE_"+sfx, current.images[arch].String()) |
| 621 | ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(current.imagesDeps[arch].Strings(), " ")) |
| 622 | ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, current.installs[arch].String()) |
| 623 | ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, current.unstrippedInstalls[arch].String()) |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 624 | } |
Colin Cross | 31bf00d | 2019-12-04 13:16:01 -0800 | [diff] [blame] | 625 | |
Ulya Trafimovich | 3391a1e | 2020-01-03 17:33:17 +0000 | [diff] [blame] | 626 | ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(current.imageLocations, ":")) |
Colin Cross | 31bf00d | 2019-12-04 13:16:01 -0800 | [diff] [blame] | 627 | ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String()) |
Nicolas Geoffray | 72892f1 | 2019-02-22 15:34:40 +0000 | [diff] [blame] | 628 | } |
| 629 | ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " ")) |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 630 | } |
Colin Cross | 800fe13 | 2019-02-11 14:21:24 -0800 | [diff] [blame] | 631 | } |