diff options
author | 2024-11-27 00:50:30 +0000 | |
---|---|---|
committer | 2024-11-27 00:50:30 +0000 | |
commit | 23be5bb233c2fc118e8e58b59e8875bef289e771 (patch) | |
tree | 492ddee95ad349f701ffb7f0c7fcbfb96f6c2dff | |
parent | 6dbff039219e5186db651968ed924412005e5a0a (diff) |
Reland^2 : Do not allow vintf_fragments for modules installed in the filesystem"
Soong defined filesystem does not have any logic to handle
vintf_fragments items, so those item should be used with vintf_fragment
modules instead. This change checks if there is any module installed in
the Soong defined filesystem and defines vintf_fragments property, and
raises error for those modules.
Bug: 322089980
Change-Id: Idd4c406c90571a07ff2cabd5629073d338af795c
Test: There is no diff between vintf manifests of generic_system_image and aosp_cf_x86_64_phone
-rw-r--r-- | android/module.go | 5 | ||||
-rw-r--r-- | android/module_proxy.go | 6 | ||||
-rw-r--r-- | filesystem/filesystem.go | 48 | ||||
-rw-r--r-- | filesystem/system_image.go | 4 |
4 files changed, 63 insertions, 0 deletions
diff --git a/android/module.go b/android/module.go index ce995ad77..686a90ef0 100644 --- a/android/module.go +++ b/android/module.go @@ -117,6 +117,7 @@ type Module interface { HostRequiredModuleNames() []string TargetRequiredModuleNames() []string VintfFragmentModuleNames(ctx ConfigurableEvaluatorContext) []string + VintfFragments(ctx ConfigurableEvaluatorContext) []string ConfigurableEvaluator(ctx ConfigurableEvaluatorContext) proptools.ConfigurableEvaluator @@ -1626,6 +1627,10 @@ func (m *ModuleBase) VintfFragmentModuleNames(ctx ConfigurableEvaluatorContext) return m.base().commonProperties.Vintf_fragment_modules.GetOrDefault(m.ConfigurableEvaluator(ctx), nil) } +func (m *ModuleBase) VintfFragments(ctx ConfigurableEvaluatorContext) []string { + return m.base().commonProperties.Vintf_fragments.GetOrDefault(m.ConfigurableEvaluator(ctx), nil) +} + func (m *ModuleBase) generateVariantTarget(ctx *moduleContext) { namespacePrefix := ctx.Namespace().id if namespacePrefix != "" { diff --git a/android/module_proxy.go b/android/module_proxy.go index 1f9679926..30459b9cd 100644 --- a/android/module_proxy.go +++ b/android/module_proxy.go @@ -9,6 +9,8 @@ type ModuleProxy struct { module blueprint.ModuleProxy } +var _ Module = (*ModuleProxy)(nil) + func (m ModuleProxy) Name() string { return m.module.Name() } @@ -225,3 +227,7 @@ func (m ModuleProxy) DecodeMultilib(ctx ConfigContext) (string, string) { func (m ModuleProxy) Overrides() []string { panic("method is not implemented on ModuleProxy") } + +func (m ModuleProxy) VintfFragments(ctx ConfigurableEvaluatorContext) []string { + panic("method is not implemented on ModuleProxy") +} diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index c34677060..c471da170 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -71,6 +71,10 @@ type filesystemBuilder interface { // For example, GSI system.img contains system_ext and product artifacts and their // relPathInPackage need to be rebased to system/system_ext and system/system_product. ModifyPackagingSpec(spec *android.PackagingSpec) + + // Function to check if the filesystem should not use `vintf_fragments` property, + // but use `vintf_fragment` module type instead + ShouldUseVintfFragmentModuleOnly() bool } var _ filesystemBuilder = (*filesystem)(nil) @@ -325,6 +329,9 @@ var pctx = android.NewPackageContext("android/soong/filesystem") func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { validatePartitionType(ctx, f) + if f.filesystemBuilder.ShouldUseVintfFragmentModuleOnly() { + f.validateVintfFragments(ctx) + } switch f.fsType(ctx) { case ext4Type, erofsType, f2fsType: f.output = f.buildImageUsingBuildImage(ctx) @@ -353,6 +360,43 @@ func (f *filesystem) GenerateAndroidBuildActions(ctx android.ModuleContext) { } } +func (f *filesystem) validateVintfFragments(ctx android.ModuleContext) { + visitedModule := map[string]bool{} + packagingSpecs := f.gatherFilteredPackagingSpecs(ctx) + + moduleInFileSystem := func(mod android.Module) bool { + for _, ps := range android.OtherModuleProviderOrDefault( + ctx, mod, android.InstallFilesProvider).PackagingSpecs { + if _, ok := packagingSpecs[ps.RelPathInPackage()]; ok { + return true + } + } + return false + } + + ctx.WalkDeps(func(child, parent android.Module) bool { + if visitedModule[child.Name()] { + return false + } + if !moduleInFileSystem(child) { + visitedModule[child.Name()] = true + return true + } + if vintfFragments := child.VintfFragments(ctx); vintfFragments != nil { + ctx.PropertyErrorf( + "vintf_fragments", + "Module %s is referenced by soong-defined filesystem %s with property vintf_fragments(%s) in use."+ + " Use vintf_fragment_modules property instead.", + child.Name(), + f.BaseModuleName(), + strings.Join(vintfFragments, ", "), + ) + } + visitedModule[child.Name()] = true + return true + }) +} + func (f *filesystem) appendToEntry(ctx android.ModuleContext, installedFile android.Path) { partitionBaseDir := android.PathForModuleOut(ctx, "root", f.partitionName()).String() + "/" @@ -757,6 +801,10 @@ func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *a f.appendToEntry(ctx, output) } +func (f *filesystem) ShouldUseVintfFragmentModuleOnly() bool { + return false +} + type partition interface { PartitionType() string } diff --git a/filesystem/system_image.go b/filesystem/system_image.go index d03eab45b..60a513346 100644 --- a/filesystem/system_image.go +++ b/filesystem/system_image.go @@ -63,3 +63,7 @@ func (s *systemImage) FilterPackagingSpec(ps android.PackagingSpec) bool { (ps.Partition() == "system" || ps.Partition() == "root" || strings.HasPrefix(ps.Partition(), "system/")) } + +func (s *systemImage) ShouldUseVintfFragmentModuleOnly() bool { + return true +} |