Merge changes I0918f2fa,I3fc6ff91,I7adc97cb,I674a5fa1,I22c45cbf into main
* changes: Change the profile path on host. Extract duplicate code to common helper functions. Fix dumpOatRules. Remove Modules() from BootclasspathFragmentApexContentInfo. Fix some tests for dexpreopt and remove unnecessary tests.
This commit is contained in:
@@ -77,7 +77,7 @@ func addDependencyOntoApexVariants(ctx android.BottomUpMutatorContext, propertyN
|
||||
// Use gatherApexModulePairDepsWithTag to retrieve the dependencies.
|
||||
func addDependencyOntoApexModulePair(ctx android.BottomUpMutatorContext, apex string, name string, tag blueprint.DependencyTag) {
|
||||
var variations []blueprint.Variation
|
||||
if apex != "platform" && apex != "system_ext" {
|
||||
if !android.IsConfiguredJarForPlatform(apex) {
|
||||
// Pick the correct apex variant.
|
||||
variations = []blueprint.Variation{
|
||||
{Mutator: "apex", Variation: apex},
|
||||
|
@@ -389,10 +389,6 @@ var BootclasspathFragmentApexContentInfoProvider = blueprint.NewProvider(Bootcla
|
||||
// BootclasspathFragmentApexContentInfo contains the bootclasspath_fragments contributions to the
|
||||
// apex contents.
|
||||
type BootclasspathFragmentApexContentInfo struct {
|
||||
// The configured modules, will be empty if this is from a bootclasspath_fragment that does not
|
||||
// set image_name: "art".
|
||||
modules android.ConfiguredJarList
|
||||
|
||||
// Map from the base module name (without prebuilt_ prefix) of a fragment's contents module to the
|
||||
// hidden API encoded dex jar path.
|
||||
contentModuleDexJarPaths bootDexJarByModule
|
||||
@@ -405,10 +401,6 @@ type BootclasspathFragmentApexContentInfo struct {
|
||||
profileInstallPathInApex string
|
||||
}
|
||||
|
||||
func (i BootclasspathFragmentApexContentInfo) Modules() android.ConfiguredJarList {
|
||||
return i.modules
|
||||
}
|
||||
|
||||
// DexBootJarPathForContentModule returns the path to the dex boot jar for specified module.
|
||||
//
|
||||
// The dex boot jar is one which has had hidden API encoding performed on it.
|
||||
@@ -597,7 +589,6 @@ func (b *BootclasspathFragmentModule) provideApexContentInfo(ctx android.ModuleC
|
||||
}
|
||||
|
||||
if imageConfig != nil {
|
||||
info.modules = imageConfig.modules
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
if !global.DisableGenerateProfile {
|
||||
info.profilePathOnHost = bootImageFiles.profile
|
||||
|
@@ -40,6 +40,12 @@ func TestBootclasspathFragment_UnknownImageName(t *testing.T) {
|
||||
image_name: "unknown",
|
||||
contents: ["foo"],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["foo.java"],
|
||||
installable: true,
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -53,6 +59,11 @@ func TestPrebuiltBootclasspathFragment_UnknownImageName(t *testing.T) {
|
||||
image_name: "unknown",
|
||||
contents: ["foo"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "foo",
|
||||
jars: ["foo.jar"],
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -72,6 +83,18 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T
|
||||
"apex",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["foo.java"],
|
||||
installable: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["bar.java"],
|
||||
installable: true,
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -92,6 +115,18 @@ func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testin
|
||||
"apex2",
|
||||
],
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "foo",
|
||||
srcs: ["foo.java"],
|
||||
installable: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "bar",
|
||||
srcs: ["bar.java"],
|
||||
installable: true,
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
|
@@ -505,8 +505,7 @@ func (d *dexpreoptBootJars) GenerateSingletonBuildActions(ctx android.SingletonC
|
||||
// No module has enabled dexpreopting, so we assume there will be no boot image to make.
|
||||
return
|
||||
}
|
||||
archType := ctx.Config().Targets[android.Android][0].Arch.ArchType
|
||||
d.dexpreoptConfigForMake = android.PathForOutput(ctx, toDexpreoptDirName(archType), "dexpreopt.config")
|
||||
d.dexpreoptConfigForMake = android.PathForOutput(ctx, getDexpreoptDirName(ctx), "dexpreopt.config")
|
||||
writeGlobalConfigForMake(ctx, d.dexpreoptConfigForMake)
|
||||
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
@@ -885,11 +884,7 @@ const failureMessage = `ERROR: Dex2oat failed to compile a boot image.
|
||||
It is likely that the boot classpath is inconsistent.
|
||||
Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.`
|
||||
|
||||
func bootImageProfileRule(ctx android.ModuleContext, image *bootImageConfig) android.WritablePath {
|
||||
if !image.isProfileGuided() {
|
||||
return nil
|
||||
}
|
||||
|
||||
func bootImageProfileRuleCommon(ctx android.ModuleContext, name string, dexFiles android.Paths, dexLocations []string) android.WritablePath {
|
||||
globalSoong := dexpreopt.GetGlobalSoongConfig(ctx)
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
|
||||
@@ -916,28 +911,39 @@ func bootImageProfileRule(ctx android.ModuleContext, image *bootImageConfig) and
|
||||
if path := android.ExistentPathForSource(ctx, extraProfile); path.Valid() {
|
||||
profiles = append(profiles, path.Path())
|
||||
}
|
||||
bootImageProfile := image.dir.Join(ctx, "boot-image-profile.txt")
|
||||
bootImageProfile := android.PathForModuleOut(ctx, name, "boot-image-profile.txt")
|
||||
rule.Command().Text("cat").Inputs(profiles).Text(">").Output(bootImageProfile)
|
||||
|
||||
profile := image.dir.Join(ctx, "boot.prof")
|
||||
profile := android.PathForModuleOut(ctx, name, "boot.prof")
|
||||
|
||||
rule.Command().
|
||||
Text(`ANDROID_LOG_TAGS="*:e"`).
|
||||
Tool(globalSoong.Profman).
|
||||
Flag("--output-profile-type=boot").
|
||||
FlagWithInput("--create-profile-from=", bootImageProfile).
|
||||
FlagForEachInput("--apk=", image.dexPathsDeps.Paths()).
|
||||
FlagForEachArg("--dex-location=", image.getAnyAndroidVariant().dexLocationsDeps).
|
||||
FlagForEachInput("--apk=", dexFiles).
|
||||
FlagForEachArg("--dex-location=", dexLocations).
|
||||
FlagWithOutput("--reference-profile-file=", profile)
|
||||
|
||||
rule.Build("bootJarsProfile_"+name, "profile boot jars "+name)
|
||||
|
||||
return profile
|
||||
}
|
||||
|
||||
func bootImageProfileRule(ctx android.ModuleContext, image *bootImageConfig) android.WritablePath {
|
||||
if !image.isProfileGuided() {
|
||||
return nil
|
||||
}
|
||||
|
||||
profile := bootImageProfileRuleCommon(ctx, image.name, image.dexPathsDeps.Paths(), image.getAnyAndroidVariant().dexLocationsDeps)
|
||||
|
||||
if image == defaultBootImageConfig(ctx) {
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
rule.Install(profile, "/system/etc/boot-image.prof")
|
||||
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
|
||||
image.profileLicenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile())
|
||||
}
|
||||
|
||||
rule.Build("bootJarsProfile", "profile boot jars")
|
||||
|
||||
return profile
|
||||
}
|
||||
|
||||
@@ -976,6 +982,8 @@ func bootFrameworkProfileRule(ctx android.ModuleContext, image *bootImageConfig)
|
||||
|
||||
func dumpOatRules(ctx android.ModuleContext, image *bootImageConfig) {
|
||||
var allPhonies android.Paths
|
||||
name := image.name
|
||||
global := dexpreopt.GetGlobalConfig(ctx)
|
||||
for _, image := range image.variants {
|
||||
arch := image.target.Arch.ArchType
|
||||
suffix := arch.String()
|
||||
@@ -984,36 +992,39 @@ func dumpOatRules(ctx android.ModuleContext, image *bootImageConfig) {
|
||||
suffix = "host-" + suffix
|
||||
}
|
||||
// Create a rule to call oatdump.
|
||||
output := android.PathForOutput(ctx, "boot."+suffix+".oatdump.txt")
|
||||
output := android.PathForOutput(ctx, name+"."+suffix+".oatdump.txt")
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
imageLocationsOnHost, _ := image.imageLocations()
|
||||
rule.Command().
|
||||
cmd := rule.Command().
|
||||
BuiltTool("oatdump").
|
||||
FlagWithInputList("--runtime-arg -Xbootclasspath:", image.dexPathsDeps.Paths(), ":").
|
||||
FlagWithList("--runtime-arg -Xbootclasspath-locations:", image.dexLocationsDeps, ":").
|
||||
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())
|
||||
if global.EnableUffdGc && image.target.Os == android.Android {
|
||||
cmd.Flag("--runtime-arg").Flag("-Xgc:CMC")
|
||||
}
|
||||
rule.Build("dump-oat-"+name+"-"+suffix, "dump oat "+name+" "+arch.String())
|
||||
|
||||
// Create a phony rule that depends on the output file and prints the path.
|
||||
phony := android.PathForPhony(ctx, "dump-oat-boot-"+suffix)
|
||||
phony := android.PathForPhony(ctx, "dump-oat-"+name+"-"+suffix)
|
||||
rule = android.NewRuleBuilder(pctx, ctx)
|
||||
rule.Command().
|
||||
Implicit(output).
|
||||
ImplicitOutput(phony).
|
||||
Text("echo").FlagWithArg("Output in ", output.String())
|
||||
rule.Build("phony-dump-oat-boot-"+suffix, "dump oat boot "+arch.String())
|
||||
rule.Build("phony-dump-oat-"+name+"-"+suffix, "dump oat "+name+" "+arch.String())
|
||||
|
||||
allPhonies = append(allPhonies, phony)
|
||||
}
|
||||
|
||||
phony := android.PathForPhony(ctx, "dump-oat-boot")
|
||||
phony := android.PathForPhony(ctx, "dump-oat-"+name)
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: android.Phony,
|
||||
Output: phony,
|
||||
Inputs: allPhonies,
|
||||
Description: "dump-oat-boot",
|
||||
Description: "dump-oat-"+name,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -105,8 +105,7 @@ func genBootImageConfigRaw(ctx android.PathContext) map[string]*bootImageConfig
|
||||
func genBootImageConfigs(ctx android.PathContext) map[string]*bootImageConfig {
|
||||
return ctx.Config().Once(bootImageConfigKey, func() interface{} {
|
||||
targets := dexpreoptTargets(ctx)
|
||||
archType := ctx.Config().Targets[android.Android][0].Arch.ArchType
|
||||
deviceDir := android.PathForOutput(ctx, toDexpreoptDirName(archType))
|
||||
deviceDir := android.PathForOutput(ctx, getDexpreoptDirName(ctx))
|
||||
|
||||
configs := genBootImageConfigRaw(ctx)
|
||||
|
||||
@@ -218,8 +217,7 @@ var updatableBootConfigKey = android.NewOnceKey("apexBootConfig")
|
||||
func GetApexBootConfig(ctx android.PathContext) apexBootConfig {
|
||||
return ctx.Config().Once(updatableBootConfigKey, func() interface{} {
|
||||
apexBootJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars
|
||||
archType := ctx.Config().Targets[android.Android][0].Arch.ArchType
|
||||
dir := android.PathForOutput(ctx, toDexpreoptDirName(archType), "apex_bootjars")
|
||||
dir := android.PathForOutput(ctx, getDexpreoptDirName(ctx), "apex_bootjars")
|
||||
dexPaths := apexBootJars.BuildPaths(ctx, dir)
|
||||
dexPathsByModuleName := apexBootJars.BuildPathsByModule(ctx, dir)
|
||||
|
||||
@@ -258,6 +256,11 @@ func dexpreoptConfigMakevars(ctx android.MakeVarsContext) {
|
||||
ctx.Strict("DEXPREOPT_BOOT_JARS_MODULES", strings.Join(defaultBootImageConfig(ctx).modules.CopyOfApexJarPairs(), ":"))
|
||||
}
|
||||
|
||||
func toDexpreoptDirName(arch android.ArchType) string {
|
||||
return "dexpreopt_" + arch.String()
|
||||
func getDexpreoptDirName(ctx android.PathContext) string {
|
||||
prefix := "dexpreopt_"
|
||||
targets := ctx.Config().Targets[android.Android]
|
||||
if len(targets) > 0 {
|
||||
return prefix+targets[0].Arch.ArchType.String()
|
||||
}
|
||||
return prefix+"unknown_target"
|
||||
}
|
||||
|
@@ -44,18 +44,18 @@ var PrepareApexBootJarConfigs = FixtureConfigureApexBootJars(
|
||||
|
||||
var PrepareApexBootJarConfigsAndModules = android.GroupFixturePreparers(
|
||||
PrepareApexBootJarConfigs,
|
||||
prepareApexBootJarModule("com.android.foo", "framework-foo"),
|
||||
prepareApexBootJarModule("com.android.bar", "framework-bar"),
|
||||
PrepareApexBootJarModule("com.android.foo", "framework-foo"),
|
||||
PrepareApexBootJarModule("com.android.bar", "framework-bar"),
|
||||
)
|
||||
|
||||
var ApexBootJarFragmentsForPlatformBootclasspath = fmt.Sprintf(`
|
||||
{
|
||||
apex: "%[1]s",
|
||||
module: "%[1]s-bootclasspathfragment",
|
||||
module: "%[1]s-bootclasspath-fragment",
|
||||
},
|
||||
{
|
||||
apex: "%[2]s",
|
||||
module: "%[2]s-bootclasspathfragment",
|
||||
module: "%[2]s-bootclasspath-fragment",
|
||||
},
|
||||
`, "com.android.foo", "com.android.bar")
|
||||
|
||||
@@ -64,15 +64,22 @@ var ApexBootJarDexJarPaths = []string{
|
||||
"out/soong/.intermediates/packages/modules/com.android.foo/framework-foo/android_common_apex10000/aligned/framework-foo.jar",
|
||||
}
|
||||
|
||||
func prepareApexBootJarModule(apexName string, moduleName string) android.FixturePreparer {
|
||||
func PrepareApexBootJarModule(apexName string, moduleName string) android.FixturePreparer {
|
||||
moduleSourceDir := fmt.Sprintf("packages/modules/%s", apexName)
|
||||
fragmentName := apexName+"-bootclasspath-fragment"
|
||||
imageNameProp := ""
|
||||
if apexName == "com.android.art" {
|
||||
fragmentName = "art-bootclasspath-fragment"
|
||||
imageNameProp = `image_name: "art",`
|
||||
}
|
||||
|
||||
return android.GroupFixturePreparers(
|
||||
android.FixtureAddTextFile(moduleSourceDir+"/Android.bp", fmt.Sprintf(`
|
||||
apex {
|
||||
name: "%[1]s",
|
||||
key: "%[1]s.key",
|
||||
bootclasspath_fragments: [
|
||||
"%[1]s-bootclasspathfragment",
|
||||
"%[3]s",
|
||||
],
|
||||
updatable: false,
|
||||
}
|
||||
@@ -84,7 +91,8 @@ func prepareApexBootJarModule(apexName string, moduleName string) android.Fixtur
|
||||
}
|
||||
|
||||
bootclasspath_fragment {
|
||||
name: "%[1]s-bootclasspathfragment",
|
||||
name: "%[3]s",
|
||||
%[4]s
|
||||
contents: ["%[2]s"],
|
||||
apex_available: ["%[1]s"],
|
||||
hidden_api: {
|
||||
@@ -100,7 +108,7 @@ func prepareApexBootJarModule(apexName string, moduleName string) android.Fixtur
|
||||
compile_dex: true,
|
||||
apex_available: ["%[1]s"],
|
||||
}
|
||||
`, apexName, moduleName)),
|
||||
`, apexName, moduleName, fragmentName, imageNameProp)),
|
||||
android.FixtureMergeMockFs(android.MockFS{
|
||||
fmt.Sprintf("%s/apex_manifest.json", moduleSourceDir): nil,
|
||||
fmt.Sprintf("%s/%s.avbpubkey", moduleSourceDir, apexName): nil,
|
||||
@@ -192,7 +200,7 @@ func CheckArtBootImageConfig(t *testing.T, result *android.TestResult) {
|
||||
// getArtImageConfig gets the ART bootImageConfig that was created during the test.
|
||||
func getArtImageConfig(result *android.TestResult) *bootImageConfig {
|
||||
pathCtx := &android.TestPathContext{TestResult: result}
|
||||
imageConfig := artBootImageConfig(pathCtx)
|
||||
imageConfig := genBootImageConfigs(pathCtx)["art"]
|
||||
return imageConfig
|
||||
}
|
||||
|
||||
@@ -806,7 +814,7 @@ func checkFrameworkBootImageConfig(t *testing.T, result *android.TestResult, mut
|
||||
},
|
||||
profileInstalls: []normalizedInstall{
|
||||
{from: "out/soong/dexpreopt_arm64/dex_bootjars/boot.bprof", to: "/system/etc/boot-image.bprof"},
|
||||
{from: "out/soong/dexpreopt_arm64/dex_bootjars/boot.prof", to: "/system/etc/boot-image.prof"},
|
||||
{from: "out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/boot/boot.prof", to: "/system/etc/boot-image.prof"},
|
||||
},
|
||||
profileLicenseMetadataFile: expectedLicenseMetadataFile,
|
||||
}
|
||||
@@ -1136,7 +1144,6 @@ func nestedCheckBootImageConfig(t *testing.T, imageConfig *bootImageConfig, expe
|
||||
android.AssertPathRelativeToTopEquals(t, "dir", expected.dir, imageConfig.dir)
|
||||
android.AssertPathRelativeToTopEquals(t, "symbolsDir", expected.symbolsDir, imageConfig.symbolsDir)
|
||||
android.AssertStringEquals(t, "installDir", expected.installDir, imageConfig.installDir)
|
||||
android.AssertStringEquals(t, "profileInstallPathInApex", expected.profileInstallPathInApex, imageConfig.profileInstallPathInApex)
|
||||
android.AssertDeepEquals(t, "modules", expected.modules, imageConfig.modules)
|
||||
android.AssertPathsRelativeToTopEquals(t, "dexPaths", expected.dexPaths, imageConfig.dexPaths.Paths())
|
||||
android.AssertPathsRelativeToTopEquals(t, "dexPathsDeps", expected.dexPathsDeps, imageConfig.dexPathsDeps.Paths())
|
||||
@@ -1238,7 +1245,7 @@ DEXPREOPT_IMAGE_LOCATIONS_ON_HOSTart=out/soong/dexpreopt_arm64/dex_artjars/andro
|
||||
DEXPREOPT_IMAGE_LOCATIONS_ON_HOSTboot=out/soong/dexpreopt_arm64/dex_bootjars/android/system/framework/boot.art
|
||||
DEXPREOPT_IMAGE_LOCATIONS_ON_HOSTmainline=out/soong/dexpreopt_arm64/dex_bootjars/android/system/framework/boot.art:out/soong/dexpreopt_arm64/dex_mainlinejars/android/system/framework/boot-framework-foo.art
|
||||
DEXPREOPT_IMAGE_NAMES=art boot mainline
|
||||
DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED=out/soong/dexpreopt_arm64/dex_bootjars/boot.bprof:/system/etc/boot-image.bprof out/soong/dexpreopt_arm64/dex_bootjars/boot.prof:/system/etc/boot-image.prof
|
||||
DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED=out/soong/dexpreopt_arm64/dex_bootjars/boot.bprof:/system/etc/boot-image.bprof out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/boot/boot.prof:/system/etc/boot-image.prof
|
||||
DEXPREOPT_IMAGE_PROFILE_LICENSE_METADATA=out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/meta_lic
|
||||
DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_art_arm=out/soong/dexpreopt_arm64/dex_artjars_unstripped/android/apex/art_boot_images/javalib/arm/boot.oat:/apex/art_boot_images/javalib/arm/boot.oat out/soong/dexpreopt_arm64/dex_artjars_unstripped/android/apex/art_boot_images/javalib/arm/boot-core2.oat:/apex/art_boot_images/javalib/arm/boot-core2.oat
|
||||
DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_art_arm64=out/soong/dexpreopt_arm64/dex_artjars_unstripped/android/apex/art_boot_images/javalib/arm64/boot.oat:/apex/art_boot_images/javalib/arm64/boot.oat out/soong/dexpreopt_arm64/dex_artjars_unstripped/android/apex/art_boot_images/javalib/arm64/boot-core2.oat:/apex/art_boot_images/javalib/arm64/boot-core2.oat
|
||||
|
@@ -166,7 +166,7 @@ func isModuleInConfiguredList(ctx android.BaseModuleContext, module android.Modu
|
||||
|
||||
// Now match the apex part of the boot image configuration.
|
||||
requiredApex := configuredBootJars.Apex(index)
|
||||
if requiredApex == "platform" || requiredApex == "system_ext" {
|
||||
if android.IsConfiguredJarForPlatform(requiredApex) {
|
||||
if len(apexInfo.InApexVariants) != 0 {
|
||||
// A platform variant is required but this is for an apex so ignore it.
|
||||
return false
|
||||
|
Reference in New Issue
Block a user