Revert "Set the appropriate deps property for the soong generated fs modules"
This reverts commit dc6492f01bbfb4a0f3e10efe6fa8e7cb5a876982.
Reason for revert: Breaking targets in post submit
Change-Id: I50e80f1f6634db6cec42aba7f2262275b6ec8b88
diff --git a/android/neverallow.go b/android/neverallow.go
index 600175d..e93763b 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -60,7 +60,6 @@
AddNeverAllowRules(createCcStubsRule())
AddNeverAllowRules(createProhibitHeaderOnlyRule())
AddNeverAllowRules(createLimitNdkExportRule()...)
- AddNeverAllowRules(createFilesystemIsAutoGeneratedRule())
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -276,14 +275,6 @@
}
}
-func createFilesystemIsAutoGeneratedRule() Rule {
- return NeverAllow().
- NotIn("build/soong/fsgen").
- ModuleType("filesystem", "android_system_image").
- WithMatcher("is_auto_generated", isSetMatcherInstance).
- Because("is_auto_generated property is only allowed for filesystem modules in build/soong/fsgen directory")
-}
-
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index caec8c7..192c924 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -359,21 +359,6 @@
`headers_only can only be used for generating framework-minus-apex headers for non-updatable modules`,
},
},
- // Test for the rule restricting use of is_auto_generated
- {
- name: `"is_auto_generated" outside allowed directory`,
- fs: map[string][]byte{
- "a/b/Android.bp": []byte(`
- filesystem {
- name: "baaz",
- is_auto_generated: true,
- }
- `),
- },
- expectedErrors: []string{
- `is_auto_generated property is only allowed for filesystem modules in build/soong/fsgen directory`,
- },
- },
}
var prepareForNeverAllowTest = GroupFixturePreparers(
@@ -382,7 +367,6 @@
ctx.RegisterModuleType("java_library", newMockJavaLibraryModule)
ctx.RegisterModuleType("java_library_host", newMockJavaLibraryModule)
ctx.RegisterModuleType("java_device_for_host", newMockJavaLibraryModule)
- ctx.RegisterModuleType("filesystem", newMockFilesystemModule)
}),
)
diff --git a/android/visibility_test.go b/android/visibility_test.go
index 277be0f..1a2eeca 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -2098,9 +2098,8 @@
}
type mockFilesystemModuleProperties struct {
- Partition_type *string
- Deps []string
- Is_auto_generated *bool
+ Partition_type *string
+ Deps []string
}
type mockFilesystemModule struct {
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 7d3b8e1..1e816a7 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -145,10 +145,6 @@
Unchecked_module *bool `blueprint:"mutated"`
Erofs ErofsProperties
-
- // Determines if the module is auto-generated from Soong or not. If the module is
- // auto-generated, its deps are exempted from visibility enforcement.
- Is_auto_generated *bool
}
// Additional properties required to generate erofs FS partitions.
@@ -183,29 +179,13 @@
android.InitDefaultableModule(module)
}
-type depTag struct {
+var dependencyTag = struct {
blueprint.BaseDependencyTag
android.PackagingItemAlwaysDepTag
-}
-
-var dependencyTag = depTag{}
-
-type depTagWithVisibilityEnforcementBypass struct {
- depTag
-}
-
-var _ android.ExcludeFromVisibilityEnforcementTag = (*depTagWithVisibilityEnforcementBypass)(nil)
-
-func (t depTagWithVisibilityEnforcementBypass) ExcludeFromVisibilityEnforcement() {}
-
-var dependencyTagWithVisibilityEnforcementBypass = depTagWithVisibilityEnforcementBypass{}
+}{}
func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) {
- if proptools.Bool(f.properties.Is_auto_generated) {
- f.AddDeps(ctx, dependencyTagWithVisibilityEnforcementBypass)
- } else {
- f.AddDeps(ctx, dependencyTag)
- }
+ f.AddDeps(ctx, dependencyTag)
}
type fsType int
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 8acc74c..ed0c390 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -43,52 +43,36 @@
func RegisterCollectFileSystemDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("fs_collect_deps", collectDepsMutator).MutatesGlobalState()
- ctx.BottomUp("fs_set_deps", setDepsMutator)
}
var fsDepsMutex = sync.Mutex{}
var collectFsDepsOnceKey = android.NewOnceKey("CollectFsDeps")
var depCandidatesOnceKey = android.NewOnceKey("DepCandidates")
-// List of partitions that the filesystem_creator module currently generates the partition
-var soongGeneratedPartitions = []string{"system"}
-
-// Map of partition module name to its partition that may be generated by Soong.
-// Note that it is not guaranteed that all modules returned by this function are successfully
-// created.
-func getAllSoongGeneratedPartitionNames(config android.Config) map[string]string {
- ret := map[string]string{}
- for _, partition := range soongGeneratedPartitions {
- ret[generatedModuleNameForPartition(config, partition)] = partition
- }
- return ret
-}
-
func collectDepsMutator(mctx android.BottomUpMutatorContext) {
// These additional deps are added according to the cuttlefish system image bp.
fsDeps := mctx.Config().Once(collectFsDepsOnceKey, func() interface{} {
- deps := map[string][]string{
- "system": {
- "com.android.apex.cts.shim.v1_prebuilt",
- "dex_bootjars",
- "framework_compatibility_matrix.device.xml",
- "idc_data",
- "init.environ.rc-soong",
- "keychars_data",
- "keylayout_data",
- "libclang_rt.asan",
- "libcompiler_rt",
- "libdmabufheap",
- "libgsi",
- "llndk.libraries.txt",
- "logpersist.start",
- "preloaded-classes",
- "public.libraries.android.txt",
- "update_engine_sideload",
- },
+ deps := []string{
+ "android_vintf_manifest",
+ "com.android.apex.cts.shim.v1_prebuilt",
+ "dex_bootjars",
+ "framework_compatibility_matrix.device.xml",
+ "idc_data",
+ "init.environ.rc-soong",
+ "keychars_data",
+ "keylayout_data",
+ "libclang_rt.asan",
+ "libcompiler_rt",
+ "libdmabufheap",
+ "libgsi",
+ "llndk.libraries.txt",
+ "logpersist.start",
+ "preloaded-classes",
+ "public.libraries.android.txt",
+ "update_engine_sideload",
}
return &deps
- }).(*map[string][]string)
+ }).(*[]string)
depCandidates := mctx.Config().Once(depCandidatesOnceKey, func() interface{} {
partitionVars := mctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
@@ -98,30 +82,10 @@
m := mctx.Module()
if slices.Contains(*depCandidates, m.Name()) {
- installPartition := getInstallPartition(m, mctx.DeviceConfig())
- fsDepsMutex.Lock()
- if _, ok := (*fsDeps)[installPartition]; !ok {
- (*fsDeps)[installPartition] = make([]string, 0)
- }
- if m.Enabled(mctx) {
- (*fsDeps)[installPartition] = append((*fsDeps)[installPartition], m.Name())
- }
- fsDepsMutex.Unlock()
- }
-}
-
-type depsStruct struct {
- Deps []string
-}
-
-func setDepsMutator(mctx android.BottomUpMutatorContext) {
- fsDeps := mctx.Config().Get(collectFsDepsOnceKey).(*map[string][]string)
- soongGeneratedPartitionMap := getAllSoongGeneratedPartitionNames(mctx.Config())
- m := mctx.Module()
- if partition, ok := soongGeneratedPartitionMap[m.Name()]; ok {
- deps := (*fsDeps)[partition]
- if err := proptools.AppendMatchingProperties(m.GetProperties(), &depsStruct{Deps: deps}, nil); err != nil {
- mctx.ModuleErrorf(err.Error())
+ if installInSystem(mctx, m) {
+ fsDepsMutex.Lock()
+ *fsDeps = append(*fsDeps, m.Name())
+ fsDepsMutex.Unlock()
}
}
}
@@ -150,7 +114,7 @@
}
func (f *filesystemCreator) createInternalModules(ctx android.LoadHookContext) {
- for _, partitionType := range soongGeneratedPartitions {
+ for _, partitionType := range []string{"system"} {
if f.createPartition(ctx, partitionType) {
f.properties.Generated_partition_types = append(f.properties.Generated_partition_types, partitionType)
} else {
@@ -160,7 +124,7 @@
f.createDeviceModule(ctx)
}
-func generatedModuleName(cfg android.Config, suffix string) string {
+func (f *filesystemCreator) generatedModuleName(cfg android.Config, suffix string) string {
prefix := "soong"
if cfg.HasDeviceProduct() {
prefix = cfg.DeviceProduct()
@@ -168,21 +132,21 @@
return fmt.Sprintf("%s_generated_%s", prefix, suffix)
}
-func generatedModuleNameForPartition(cfg android.Config, partitionType string) string {
- return generatedModuleName(cfg, fmt.Sprintf("%s_image", partitionType))
+func (f *filesystemCreator) generatedModuleNameForPartition(cfg android.Config, partitionType string) string {
+ return f.generatedModuleName(cfg, fmt.Sprintf("%s_image", partitionType))
}
func (f *filesystemCreator) createDeviceModule(ctx android.LoadHookContext) {
baseProps := &struct {
Name *string
}{
- Name: proptools.StringPtr(generatedModuleName(ctx.Config(), "device")),
+ Name: proptools.StringPtr(f.generatedModuleName(ctx.Config(), "device")),
}
// Currently, only the system partition module is created.
partitionProps := &filesystem.PartitionNameProperties{}
if android.InList("system", f.properties.Generated_partition_types) {
- partitionProps.System_partition_name = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system"))
+ partitionProps.System_partition_name = proptools.StringPtr(f.generatedModuleNameForPartition(ctx.Config(), "system"))
}
ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps)
@@ -194,7 +158,7 @@
baseProps := &struct {
Name *string
}{
- Name: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), partitionType)),
+ Name: proptools.StringPtr(f.generatedModuleNameForPartition(ctx.Config(), partitionType)),
}
fsProps := &filesystem.FilesystemProperties{}
@@ -231,8 +195,6 @@
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
- fsProps.Is_auto_generated = proptools.BoolPtr(true)
-
// Identical to that of the generic_system_image
fsProps.Fsverity.Inputs = []string{
"etc/boot-image.prof",
@@ -267,7 +229,7 @@
}
func (f *filesystemCreator) createDiffTest(ctx android.ModuleContext, partitionType string) android.Path {
- partitionModuleName := generatedModuleNameForPartition(ctx.Config(), partitionType)
+ partitionModuleName := f.generatedModuleNameForPartition(ctx.Config(), partitionType)
systemImage := ctx.GetDirectDepWithTag(partitionModuleName, generatedFilesystemDepTag)
filesystemInfo, ok := android.OtherModuleProvider(ctx, systemImage, filesystem.FilesystemProvider)
if !ok {
@@ -311,7 +273,7 @@
func (f *filesystemCreator) DepsMutator(ctx android.BottomUpMutatorContext) {
for _, partitionType := range f.properties.Generated_partition_types {
- ctx.AddDependency(ctx.Module(), generatedFilesystemDepTag, generatedModuleNameForPartition(ctx.Config(), partitionType))
+ ctx.AddDependency(ctx.Module(), generatedFilesystemDepTag, f.generatedModuleNameForPartition(ctx.Config(), partitionType))
}
}
@@ -336,8 +298,11 @@
ctx.Phony("soong_generated_filesystem_tests", diffTestFiles...)
}
-func getInstallPartition(m android.Module, config android.DeviceConfig) string {
- return m.PartitionTag(config)
+func installInSystem(ctx android.BottomUpMutatorContext, m android.Module) bool {
+ return m.PartitionTag(ctx.DeviceConfig()) == "system" && !m.InstallInData() &&
+ !m.InstallInTestcases() && !m.InstallInSanitizerDir() && !m.InstallInVendorRamdisk() &&
+ !m.InstallInDebugRamdisk() && !m.InstallInRecovery() && !m.InstallInOdm() &&
+ !m.InstallInVendor()
}
// TODO: assemble baseProps and fsProps here
@@ -347,9 +312,9 @@
return ""
}
- deps := ctx.Config().Get(collectFsDepsOnceKey).(*map[string][]string)
+ deps := ctx.Config().Get(collectFsDepsOnceKey).(*[]string)
depProps := &android.PackagingProperties{
- Deps: android.NewSimpleConfigurable(android.SortedUniqueStrings((*deps)[partitionType])),
+ Deps: android.NewSimpleConfigurable(android.SortedUniqueStrings(*deps)),
}
result, err := proptools.RepackProperties([]interface{}{depProps})
diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go
index f96bdce..554b66b 100644
--- a/fsgen/filesystem_creator_test.go
+++ b/fsgen/filesystem_creator_test.go
@@ -17,7 +17,6 @@
import (
"android/soong/android"
"android/soong/filesystem"
- "android/soong/java"
"testing"
"github.com/google/blueprint/proptools"
@@ -29,7 +28,6 @@
result := android.GroupFixturePreparers(
android.PrepareForIntegrationTestWithAndroid,
android.PrepareForTestWithAndroidBuildComponents,
- android.PrepareForTestWithAllowMissingDependencies,
filesystem.PrepareForTestWithFilesystemBuildComponents,
prepareForTestWithFsgenBuildComponents,
android.FixtureModifyConfig(func(config android.Config) {
@@ -88,55 +86,3 @@
proptools.String(fooSystem.FsProps().Type),
)
}
-
-func TestFileSystemCreatorSetPartitionDeps(t *testing.T) {
- result := android.GroupFixturePreparers(
- android.PrepareForIntegrationTestWithAndroid,
- android.PrepareForTestWithAndroidBuildComponents,
- android.PrepareForTestWithAllowMissingDependencies,
- filesystem.PrepareForTestWithFilesystemBuildComponents,
- prepareForTestWithFsgenBuildComponents,
- java.PrepareForTestWithJavaBuildComponents,
- java.PrepareForTestWithJavaDefaultModules,
- android.FixtureModifyConfig(func(config android.Config) {
- config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"bar", "baz"}
- config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
- map[string]android.PartitionQualifiedVariablesType{
- "system": {
- BoardFileSystemType: "ext4",
- },
- }
- }),
- android.FixtureMergeMockFs(android.MockFS{
- "external/avb/test/data/testkey_rsa4096.pem": nil,
- "build/soong/fsgen/Android.bp": []byte(`
- soong_filesystem_creator {
- name: "foo",
- }
- `),
- }),
- ).RunTestWithBp(t, `
- java_library {
- name: "bar",
- srcs: ["A.java"],
- }
- java_library {
- name: "baz",
- srcs: ["A.java"],
- product_specific: true,
- }
- `)
-
- android.AssertBoolEquals(
- t,
- "Generated system image expected to depend on system partition installed \"bar\"",
- true,
- java.CheckModuleHasDependency(t, result.TestContext, "test_product_generated_system_image", "android_common", "bar"),
- )
- android.AssertBoolEquals(
- t,
- "Generated system image expected to not depend on product partition installed \"baz\"",
- false,
- java.CheckModuleHasDependency(t, result.TestContext, "test_product_generated_system_image", "android_common", "baz"),
- )
-}