diff options
author | 2021-04-27 23:56:44 +0900 | |
---|---|---|
committer | 2021-05-15 00:29:49 +0900 | |
commit | 4dda75e73e3e52e11b1cd37af33645fcfe5ed980 (patch) | |
tree | 930a34f728c5073e2bfaaad369d384b2fec466ba /java | |
parent | 015a0afe07cd5ed38ec72af5ae6059c247e5f841 (diff) |
Add usesTargetFiles option in dexpreopt_gen
For running dex2oat on the target_files, the paths should be use the
device install path instead of the path starting with $(OUT).
So add usesTargetFiles option and basePath option which indicates
extracted path. With those options, the path is replaced with
$(basePath)/$(device path)
And also, add DexPreoptImageDeviceLocations in the config which refers
to the boot image path(without arch) on the device. Because
DexPreoptImage related device path was missing.
Bug: 158843648
Test: dexpreopt_gen -usesTargetFiles -basePath (extract path) and then
check if paths in the generated shell script are based on on-device
path.
Change-Id: I9667fadbf3b7c6f770e0d1bcbee5d67c1ecd8a3d
Diffstat (limited to 'java')
-rw-r--r-- | java/dexpreopt.go | 9 | ||||
-rw-r--r-- | java/dexpreopt_bootjars.go | 22 | ||||
-rw-r--r-- | java/dexpreopt_config.go | 32 |
3 files changed, 37 insertions, 26 deletions
diff --git a/java/dexpreopt.go b/java/dexpreopt.go index 8d23ad6bd..2e46d74fa 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -184,7 +184,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr imagesDeps = append(imagesDeps, variant.imagesDeps) } // The image locations for all Android variants are identical. - hostImageLocations := bootImage.getAnyAndroidVariant().imageLocations() + hostImageLocations, deviceImageLocations := bootImage.getAnyAndroidVariant().imageLocations() var profileClassListing android.OptionalPath var profileBootListing android.OptionalPath @@ -224,9 +224,10 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr ProvidesUsesLibrary: providesUsesLib, ClassLoaderContexts: d.classLoaderContexts, - Archs: archs, - DexPreoptImagesDeps: imagesDeps, - DexPreoptImageLocationsOnHost: hostImageLocations, + Archs: archs, + DexPreoptImagesDeps: imagesDeps, + DexPreoptImageLocationsOnHost: hostImageLocations, + DexPreoptImageLocationsOnDevice: deviceImageLocations, PreoptBootClassPathDexFiles: dexFiles.Paths(), PreoptBootClassPathDexLocations: dexLocations, diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index ce68c4856..45d4fe979 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -244,6 +244,9 @@ type bootImageConfig struct { // Subdirectory where the image files are installed. installDirOnHost string + // Subdirectory where the image files on device are installed. + installDirOnDevice string + // A list of (location, jar) pairs for the Java modules in this image. modules android.ConfiguredJarList @@ -273,8 +276,9 @@ type bootImageVariant struct { dexLocationsDeps []string // for the dependency images and in this image // Paths to image files. - imagePathOnHost android.OutputPath // first image file - imagesDeps android.OutputPaths // all files + imagePathOnHost android.OutputPath // first image file path on host + imagePathOnDevice string // first image file path on device + imagesDeps android.OutputPaths // all files // Only for extensions, paths to the primary boot images. primaryImages android.OutputPath @@ -361,11 +365,12 @@ func (image bootImageConfig) moduleFiles(ctx android.PathContext, dir android.Ou // The location is passed as an argument to the ART tools like dex2oat instead of the real path. // ART tools will then reconstruct the architecture-specific real path. // -func (image *bootImageVariant) imageLocations() (imageLocations []string) { +func (image *bootImageVariant) imageLocations() (imageLocationsOnHost []string, imageLocationsOnDevice []string) { if image.extends != nil { - imageLocations = image.extends.getVariant(image.target).imageLocations() + imageLocationsOnHost, imageLocationsOnDevice = image.extends.getVariant(image.target).imageLocations() } - return append(imageLocations, dexpreopt.PathToLocation(image.imagePathOnHost, image.target.Arch.ArchType)) + return append(imageLocationsOnHost, dexpreopt.PathToLocation(image.imagePathOnHost, image.target.Arch.ArchType)), + append(imageLocationsOnDevice, dexpreopt.PathStringToLocation(image.imagePathOnDevice, image.target.Arch.ArchType)) } func dexpreoptBootJarsFactory() android.SingletonModule { @@ -873,12 +878,13 @@ func dumpOatRules(ctx android.ModuleContext, image *bootImageConfig) { // Create a rule to call oatdump. output := android.PathForOutput(ctx, "boot."+suffix+".oatdump.txt") rule := android.NewRuleBuilder(pctx, ctx) + imageLocationsOnHost, _ := image.imageLocations() rule.Command(). // TODO: for now, use the debug version for better error reporting BuiltTool("oatdumpd"). FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":"). FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":"). - FlagWithArg("--image=", strings.Join(image.imageLocations(), ":")).Implicits(image.imagesDeps.Paths()). + FlagWithArg("--image=", strings.Join(imageLocationsOnHost, ":")).Implicits(image.imagesDeps.Paths()). FlagWithOutput("--output=", output). FlagWithArg("--instruction-set=", arch.String()) rule.Build("dump-oat-boot-"+suffix, "dump oat boot "+arch.String()) @@ -948,8 +954,8 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, variant.installs.String()) ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, variant.unstrippedInstalls.String()) } - imageLocations := current.getAnyAndroidVariant().imageLocations() - ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(imageLocations, ":")) + imageLocationsOnHost, _ := current.getAnyAndroidVariant().imageLocations() + ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(imageLocationsOnHost, ":")) ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String()) } ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " ")) diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index 7fb0444c2..37248609d 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -84,25 +84,28 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig { frameworkModules := global.BootJars.RemoveList(artModules) artDirOnHost := "apex/art_boot_images/javalib" + artDirOnDevice := "apex/com.android.art/javalib" frameworkSubdir := "system/framework" // ART config for the primary boot image in the ART apex. // It includes the Core Libraries. artCfg := bootImageConfig{ - name: artBootImageName, - stem: "boot", - installDirOnHost: artDirOnHost, - modules: artModules, + name: artBootImageName, + stem: "boot", + installDirOnHost: artDirOnHost, + installDirOnDevice: artDirOnDevice, + modules: artModules, } // Framework config for the boot image extension. // It includes framework libraries and depends on the ART config. frameworkCfg := bootImageConfig{ - extends: &artCfg, - name: frameworkBootImageName, - stem: "boot", - installDirOnHost: frameworkSubdir, - modules: frameworkModules, + extends: &artCfg, + name: frameworkBootImageName, + stem: "boot", + installDirOnHost: frameworkSubdir, + installDirOnDevice: frameworkSubdir, + modules: frameworkModules, } configs := map[string]*bootImageConfig{ @@ -131,11 +134,12 @@ func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig { arch := target.Arch.ArchType imageDir := c.dir.Join(ctx, target.Os.String(), c.installDirOnHost, arch.String()) variant := &bootImageVariant{ - bootImageConfig: c, - target: target, - imagePathOnHost: imageDir.Join(ctx, imageName), - imagesDeps: c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex"), - dexLocations: c.modules.DevicePaths(ctx.Config(), target.Os), + bootImageConfig: c, + target: target, + imagePathOnHost: imageDir.Join(ctx, imageName), + imagePathOnDevice: filepath.Join("/", c.installDirOnDevice, arch.String(), imageName), + imagesDeps: c.moduleFiles(ctx, imageDir, ".art", ".oat", ".vdex"), + dexLocations: c.modules.DevicePaths(ctx.Config(), target.Os), } variant.dexLocationsDeps = variant.dexLocations c.variants = append(c.variants, variant) |