Merge "Some tweaks to the aconfig flag collection logic" into main am: 6c2cd90232 am: 4782aa50bf

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2983533

Change-Id: I91948e96a5df217441135f631040e80a060197d7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yu Liu
2024-02-29 18:28:28 +00:00
committed by Automerger Merge Worker
3 changed files with 29 additions and 16 deletions

View File

@@ -2072,8 +2072,10 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
return true // track transitive dependencies return true // track transitive dependencies
case *java.AndroidAppImport: case *java.AndroidAppImport:
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
addAconfigFiles(vctx, ctx, child)
case *java.AndroidTestHelperApp: case *java.AndroidTestHelperApp:
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...) vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
addAconfigFiles(vctx, ctx, child)
case *java.AndroidAppSet: case *java.AndroidAppSet:
appDir := "app" appDir := "app"
if ap.Privileged() { if ap.Privileged() {
@@ -2087,6 +2089,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap) af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(), appDirName, appSet, ap)
af.certificate = java.PresignedCertificate af.certificate = java.PresignedCertificate
vctx.filesInfo = append(vctx.filesInfo, af) vctx.filesInfo = append(vctx.filesInfo, af)
addAconfigFiles(vctx, ctx, child)
default: default:
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName) ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
} }
@@ -2115,6 +2118,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
case prebuiltTag: case prebuiltTag:
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok { if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
addAconfigFiles(vctx, ctx, child)
} else { } else {
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName) ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc module", depName)
} }
@@ -2138,6 +2142,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
af := apexFileForExecutable(ctx, ccTest) af := apexFileForExecutable(ctx, ccTest)
af.class = nativeTest af.class = nativeTest
vctx.filesInfo = append(vctx.filesInfo, af) vctx.filesInfo = append(vctx.filesInfo, af)
addAconfigFiles(vctx, ctx, child)
} }
return true // track transitive dependencies return true // track transitive dependencies
} else { } else {
@@ -2223,11 +2228,13 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
} }
vctx.filesInfo = append(vctx.filesInfo, af) vctx.filesInfo = append(vctx.filesInfo, af)
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies return true // track transitive dependencies
} else if rm, ok := child.(*rust.Module); ok { } else if rm, ok := child.(*rust.Module); ok {
af := apexFileForRustLibrary(ctx, rm) af := apexFileForRustLibrary(ctx, rm)
af.transitiveDep = true af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af) vctx.filesInfo = append(vctx.filesInfo, af)
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies return true // track transitive dependencies
} }
} else if cc.IsTestPerSrcDepTag(depTag) { } else if cc.IsTestPerSrcDepTag(depTag) {
@@ -2256,6 +2263,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
af := apexFileForRustLibrary(ctx, rustm) af := apexFileForRustLibrary(ctx, rustm)
af.transitiveDep = true af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af) vctx.filesInfo = append(vctx.filesInfo, af)
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies return true // track transitive dependencies
} }
} else if rust.IsRlibDepTag(depTag) { } else if rust.IsRlibDepTag(depTag) {
@@ -2274,6 +2282,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
return false return false
} }
vctx.filesInfo = append(vctx.filesInfo, af) vctx.filesInfo = append(vctx.filesInfo, af)
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies return true // track transitive dependencies
default: default:
ctx.PropertyErrorf("bootclasspath_fragments", ctx.PropertyErrorf("bootclasspath_fragments",
@@ -2288,6 +2297,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil { if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil {
vctx.filesInfo = append(vctx.filesInfo, *profileAf) vctx.filesInfo = append(vctx.filesInfo, *profileAf)
} }
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies return true // track transitive dependencies
default: default:
ctx.PropertyErrorf("systemserverclasspath_fragments", ctx.PropertyErrorf("systemserverclasspath_fragments",

View File

@@ -11128,10 +11128,10 @@ func TestAconfigFilesJavaDeps(t *testing.T) {
t.Fatalf("Expected 5 commands, got %d in:\n%s", len(copyCmds), s) t.Fatalf("Expected 5 commands, got %d in:\n%s", len(copyCmds), s)
} }
ensureMatches(t, copyCmds[4], "^cp -f .*/aconfig_flags.pb .*/image.apex$") ensureMatches(t, copyCmds[4], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$")
ensureMatches(t, copyCmds[5], "^cp -f .*/package.map .*/image.apex$") ensureMatches(t, copyCmds[5], "^cp -f .*/package.map .*/image.apex/etc$")
ensureMatches(t, copyCmds[6], "^cp -f .*/flag.map .*/image.apex$") ensureMatches(t, copyCmds[6], "^cp -f .*/flag.map .*/image.apex/etc$")
ensureMatches(t, copyCmds[7], "^cp -f .*/flag.val .*/image.apex$") ensureMatches(t, copyCmds[7], "^cp -f .*/flag.val .*/image.apex/etc$")
inputs := []string{ inputs := []string{
"my_aconfig_declarations_foo/intermediate.pb", "my_aconfig_declarations_foo/intermediate.pb",
@@ -11252,10 +11252,10 @@ func TestAconfigFilesJavaAndCcDeps(t *testing.T) {
t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s) t.Fatalf("Expected 12 commands, got %d in:\n%s", len(copyCmds), s)
} }
ensureMatches(t, copyCmds[8], "^cp -f .*/aconfig_flags.pb .*/image.apex$") ensureMatches(t, copyCmds[8], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$")
ensureMatches(t, copyCmds[9], "^cp -f .*/package.map .*/image.apex$") ensureMatches(t, copyCmds[9], "^cp -f .*/package.map .*/image.apex/etc$")
ensureMatches(t, copyCmds[10], "^cp -f .*/flag.map .*/image.apex$") ensureMatches(t, copyCmds[10], "^cp -f .*/flag.map .*/image.apex/etc$")
ensureMatches(t, copyCmds[11], "^cp -f .*/flag.val .*/image.apex$") ensureMatches(t, copyCmds[11], "^cp -f .*/flag.val .*/image.apex/etc$")
inputs := []string{ inputs := []string{
"my_aconfig_declarations_foo/intermediate.pb", "my_aconfig_declarations_foo/intermediate.pb",
@@ -11393,13 +11393,15 @@ func TestAconfigFilesRustDeps(t *testing.T) {
t.Fatalf("Expected 26 commands, got %d in:\n%s", len(copyCmds), s) t.Fatalf("Expected 26 commands, got %d in:\n%s", len(copyCmds), s)
} }
ensureMatches(t, copyCmds[22], "^cp -f .*/aconfig_flags.pb .*/image.apex$") ensureMatches(t, copyCmds[22], "^cp -f .*/aconfig_flags.pb .*/image.apex/etc$")
ensureMatches(t, copyCmds[23], "^cp -f .*/package.map .*/image.apex$") ensureMatches(t, copyCmds[23], "^cp -f .*/package.map .*/image.apex/etc$")
ensureMatches(t, copyCmds[24], "^cp -f .*/flag.map .*/image.apex$") ensureMatches(t, copyCmds[24], "^cp -f .*/flag.map .*/image.apex/etc$")
ensureMatches(t, copyCmds[25], "^cp -f .*/flag.val .*/image.apex$") ensureMatches(t, copyCmds[25], "^cp -f .*/flag.val .*/image.apex/etc$")
inputs := []string{ inputs := []string{
"my_aconfig_declarations_foo/intermediate.pb", "my_aconfig_declarations_foo/intermediate.pb",
"my_aconfig_declarations_bar/intermediate.pb",
"my_aconfig_declarations_baz/intermediate.pb",
"my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb", "my_rust_binary/android_arm64_armv8-a_apex10000/myapex/aconfig_merged.pb",
} }
VerifyAconfigRule(t, &mod, "combine_aconfig_declarations", inputs, "android_common_myapex/aconfig_flags.pb", "", "") VerifyAconfigRule(t, &mod, "combine_aconfig_declarations", inputs, "android_common_myapex/aconfig_flags.pb", "", "")

View File

@@ -645,6 +645,7 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin") prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin")
defaultReadOnlyFiles := []string{"apex_manifest.json", "apex_manifest.pb"} defaultReadOnlyFiles := []string{"apex_manifest.json", "apex_manifest.pb"}
aconfigDest := imageDir.Join(ctx, "etc").String()
if len(a.aconfigFiles) > 0 { if len(a.aconfigFiles) > 0 {
apexAconfigFile := android.PathForModuleOut(ctx, "aconfig_flags.pb") apexAconfigFile := android.PathForModuleOut(ctx, "aconfig_flags.pb")
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
@@ -657,9 +658,9 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
}, },
}) })
copyCommands = append(copyCommands, "cp -f "+apexAconfigFile.String()+" "+imageDir.String()) copyCommands = append(copyCommands, "cp -f "+apexAconfigFile.String()+" "+aconfigDest)
implicitInputs = append(implicitInputs, apexAconfigFile) implicitInputs = append(implicitInputs, apexAconfigFile)
defaultReadOnlyFiles = append(defaultReadOnlyFiles, apexAconfigFile.Base()) defaultReadOnlyFiles = append(defaultReadOnlyFiles, "etc/"+apexAconfigFile.Base())
for _, info := range createStorageInfo { for _, info := range createStorageInfo {
outputFile := android.PathForModuleOut(ctx, info.Output_file) outputFile := android.PathForModuleOut(ctx, info.Output_file)
@@ -675,9 +676,9 @@ func (a *apexBundle) buildApex(ctx android.ModuleContext) {
}, },
}) })
copyCommands = append(copyCommands, "cp -f "+outputFile.String()+" "+imageDir.String()) copyCommands = append(copyCommands, "cp -f "+outputFile.String()+" "+aconfigDest)
implicitInputs = append(implicitInputs, outputFile) implicitInputs = append(implicitInputs, outputFile)
defaultReadOnlyFiles = append(defaultReadOnlyFiles, outputFile.Base()) defaultReadOnlyFiles = append(defaultReadOnlyFiles, "etc/"+outputFile.Base())
} }
} }