Remove overriden modules from deps of autogenerated filesystem modules
`android_filesystem` supports overrides, but only if the module is
overriden by another module in its deps. For AOSP CF, the autogenerated
system.img contains an additional /bin/charger. The Kati system.img does
not contain this file because it is overriden by a module which is
installed in /vendor.
This CL updates the autogen mutators to remove a module from deps if it
is overriden by another module in PRODUCT_PACKAGES or by a transitve
required module dependency of PRODUCT_PACKAGES
Test: go test ./fsgen
Test: verified that /bin/charger no longer appears in diff_test of
system for aosp_cf_x86_64
Change-Id: Idafa1db07a42519ba3c441f851480b1c6faa63b8
Change-Id: If09050a6fd110d07d975595644dba85c740027e2
diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go
index 484cc38..199eaad 100644
--- a/fsgen/filesystem_creator_test.go
+++ b/fsgen/filesystem_creator_test.go
@@ -217,3 +217,39 @@
"//c/d:bar",
)
}
+
+func TestRemoveOverriddenModulesFromDeps(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ android.PrepareForIntegrationTestWithAndroid,
+ android.PrepareForTestWithAndroidBuildComponents,
+ android.PrepareForTestWithAllowMissingDependencies,
+ prepareForTestWithFsgenBuildComponents,
+ java.PrepareForTestWithJavaBuildComponents,
+ android.FixtureMergeMockFs(android.MockFS{
+ "external/avb/test/data/testkey_rsa4096.pem": nil,
+ "build/soong/fsgen/Android.bp": []byte(`
+ soong_filesystem_creator {
+ name: "foo",
+ }
+ `),
+ }),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.ProductPackages = []string{"libfoo", "libbar"}
+ }),
+ ).RunTestWithBp(t, `
+java_library {
+ name: "libfoo",
+}
+java_library {
+ name: "libbar",
+ required: ["libbaz"],
+}
+java_library {
+ name: "libbaz",
+ overrides: ["libfoo"], // overrides libfoo
+}
+ `)
+ resolvedSystemDeps := result.TestContext.Config().Get(fsGenStateOnceKey).(*FsGenState).fsDeps["system"]
+ _, libFooInDeps := (*resolvedSystemDeps)["libfoo"]
+ android.AssertBoolEquals(t, "libfoo should not appear in deps because it has been overridden by libbaz. The latter is a required dep of libbar, which is listed in PRODUCT_PACKAGES", false, libFooInDeps)
+}