Refactor around apex aconfig files
We can iterate over the collection of apex file. Bug: n/a Test: m nothing --no-skip-soong-tests Change-Id: Ibe567d3b251c54d656793dc443eb68fb9137f42f
This commit is contained in:
45
apex/apex.go
45
apex/apex.go
@@ -1937,8 +1937,6 @@ type visitorContext struct {
|
|||||||
|
|
||||||
// visitor skips these from this list of module names
|
// visitor skips these from this list of module names
|
||||||
unwantedTransitiveDeps []string
|
unwantedTransitiveDeps []string
|
||||||
|
|
||||||
aconfigFiles []android.Path
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) {
|
func (vctx *visitorContext) normalizeFileInfo(mctx android.ModuleContext) {
|
||||||
@@ -2005,7 +2003,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
fi := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
|
fi := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs)
|
||||||
fi.isJniLib = isJniLib
|
fi.isJniLib = isJniLib
|
||||||
vctx.filesInfo = append(vctx.filesInfo, fi)
|
vctx.filesInfo = append(vctx.filesInfo, fi)
|
||||||
addAconfigFiles(vctx, ctx, child)
|
|
||||||
// Collect the list of stub-providing libs except:
|
// Collect the list of stub-providing libs except:
|
||||||
// - VNDK libs are only for vendors
|
// - VNDK libs are only for vendors
|
||||||
// - bootstrap bionic libs are treated as provided by system
|
// - bootstrap bionic libs are treated as provided by system
|
||||||
@@ -2017,7 +2014,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
fi := apexFileForRustLibrary(ctx, ch)
|
fi := apexFileForRustLibrary(ctx, ch)
|
||||||
fi.isJniLib = isJniLib
|
fi.isJniLib = isJniLib
|
||||||
vctx.filesInfo = append(vctx.filesInfo, fi)
|
vctx.filesInfo = append(vctx.filesInfo, fi)
|
||||||
addAconfigFiles(vctx, ctx, child)
|
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
|
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
|
||||||
@@ -2026,11 +2022,9 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
switch ch := child.(type) {
|
switch ch := child.(type) {
|
||||||
case *cc.Module:
|
case *cc.Module:
|
||||||
vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, ch))
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, ch))
|
||||||
addAconfigFiles(vctx, ctx, child)
|
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
case *rust.Module:
|
case *rust.Module:
|
||||||
vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch))
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, ch))
|
||||||
addAconfigFiles(vctx, ctx, child)
|
|
||||||
return true // track transitive dependencies
|
return true // track transitive dependencies
|
||||||
default:
|
default:
|
||||||
ctx.PropertyErrorf("binaries",
|
ctx.PropertyErrorf("binaries",
|
||||||
@@ -2070,7 +2064,6 @@ 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("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
|
||||||
@@ -2079,14 +2072,11 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
switch ap := child.(type) {
|
switch ap := child.(type) {
|
||||||
case *java.AndroidApp:
|
case *java.AndroidApp:
|
||||||
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
|
vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, ap)...)
|
||||||
addAconfigFiles(vctx, ctx, child)
|
|
||||||
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() {
|
||||||
@@ -2100,7 +2090,6 @@ 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)
|
||||||
}
|
}
|
||||||
@@ -2132,7 +2121,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
for _, etcFile := range filesToCopy {
|
for _, etcFile := range filesToCopy {
|
||||||
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile))
|
vctx.filesInfo = append(vctx.filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, etcFile))
|
||||||
}
|
}
|
||||||
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)
|
||||||
}
|
}
|
||||||
@@ -2147,7 +2135,6 @@ 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 {
|
||||||
ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
|
ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
|
||||||
@@ -2227,7 +2214,6 @@ 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 {
|
||||||
if !android.IsDepInSameApex(ctx, am, am) {
|
if !android.IsDepInSameApex(ctx, am, am) {
|
||||||
@@ -2237,7 +2223,6 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
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.IsHeaderDepTag(depTag) {
|
} else if cc.IsHeaderDepTag(depTag) {
|
||||||
@@ -2260,7 +2245,6 @@ 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) {
|
||||||
@@ -2279,7 +2263,6 @@ 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",
|
||||||
@@ -2294,7 +2277,6 @@ 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",
|
||||||
@@ -2312,17 +2294,24 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAconfigFiles(vctx *visitorContext, ctx android.ModuleContext, module blueprint.Module) {
|
func collectAconfigFiles(ctx android.ModuleContext, apexFiles []apexFile) android.Paths {
|
||||||
if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigPropagatingProviderKey); ok {
|
var aconfigFiles android.Paths
|
||||||
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
|
for _, file := range apexFiles {
|
||||||
vctx.aconfigFiles = append(vctx.aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...)
|
if file.module == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if dep, ok := android.OtherModuleProvider(ctx, file.module, android.AconfigPropagatingProviderKey); ok {
|
||||||
|
if len(dep.AconfigFiles) > 0 && dep.AconfigFiles[ctx.ModuleName()] != nil {
|
||||||
|
aconfigFiles = append(aconfigFiles, dep.AconfigFiles[ctx.ModuleName()]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
validationFlag := ctx.DeviceConfig().AconfigContainerValidation()
|
||||||
|
if validationFlag == "error" || validationFlag == "warning" {
|
||||||
|
android.VerifyAconfigBuildMode(ctx, ctx.ModuleName(), file.module, validationFlag == "error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return android.FirstUniquePaths(aconfigFiles)
|
||||||
validationFlag := ctx.DeviceConfig().AconfigContainerValidation()
|
|
||||||
if validationFlag == "error" || validationFlag == "warning" {
|
|
||||||
android.VerifyAconfigBuildMode(ctx, ctx.ModuleName(), module, validationFlag == "error")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *apexBundle) shouldCheckDuplicate(ctx android.ModuleContext) bool {
|
func (a *apexBundle) shouldCheckDuplicate(ctx android.ModuleContext) bool {
|
||||||
@@ -2406,7 +2395,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
// 3) some fields in apexBundle struct are configured
|
// 3) some fields in apexBundle struct are configured
|
||||||
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
a.installDir = android.PathForModuleInstall(ctx, "apex")
|
||||||
a.filesInfo = vctx.filesInfo
|
a.filesInfo = vctx.filesInfo
|
||||||
a.aconfigFiles = android.FirstUniquePaths(vctx.aconfigFiles)
|
a.aconfigFiles = collectAconfigFiles(ctx, a.filesInfo)
|
||||||
|
|
||||||
a.setPayloadFsType(ctx)
|
a.setPayloadFsType(ctx)
|
||||||
a.setSystemLibLink(ctx)
|
a.setSystemLibLink(ctx)
|
||||||
|
Reference in New Issue
Block a user