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