Add an allowlist for modules that have broken optional_uses_libs.

Bug: 282877248
Test: m nothing
Change-Id: I1afe9d523af0633f0428d4c15e1417db1dae4e93
This commit is contained in:
Jiakai Zhang 2023-06-02 23:42:21 +01:00
parent 82f0e5daae
commit 48203e3dee
4 changed files with 10 additions and 1 deletions

View file

@ -1925,6 +1925,10 @@ func (c *deviceConfig) BuildBrokenInputDir(name string) bool {
return InList(name, c.config.productVariables.BuildBrokenInputDirModules) return InList(name, c.config.productVariables.BuildBrokenInputDirModules)
} }
func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string {
return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist
}
func (c *deviceConfig) GenruleSandboxing() bool { func (c *deviceConfig) GenruleSandboxing() bool {
return Bool(c.config.productVariables.GenruleSandboxing) return Bool(c.config.productVariables.GenruleSandboxing)
} }

View file

@ -449,6 +449,8 @@ type productVariables struct {
BuildBrokenVendorPropertyNamespace bool `json:",omitempty"` BuildBrokenVendorPropertyNamespace bool `json:",omitempty"`
BuildBrokenInputDirModules []string `json:",omitempty"` BuildBrokenInputDirModules []string `json:",omitempty"`
BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"`
BuildDebugfsRestrictionsEnabled bool `json:",omitempty"` BuildDebugfsRestrictionsEnabled bool `json:",omitempty"`
RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"` RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"`

View file

@ -1396,7 +1396,7 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps boo
func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string { func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string {
optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool { optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool {
exists := ctx.OtherModuleExists(s) exists := ctx.OtherModuleExists(s)
if !exists { if !exists && !android.InList(ctx.ModuleName(), ctx.Config().BuildWarningBadOptionalUsesLibsAllowlist()) {
fmt.Printf("Warning: Module '%s' depends on non-existing optional_uses_libs '%s'\n", ctx.ModuleName(), s) fmt.Printf("Warning: Module '%s' depends on non-existing optional_uses_libs '%s'\n", ctx.ModuleName(), s)
} }
return exists return exists

View file

@ -2644,6 +2644,9 @@ func TestUsesLibraries(t *testing.T) {
prepareForJavaTest, prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles, PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"), FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BuildWarningBadOptionalUsesLibsAllowlist = []string{"app", "prebuilt"}
}),
).RunTestWithBp(t, bp) ).RunTestWithBp(t, bp)
app := result.ModuleForTests("app", "android_common") app := result.ModuleForTests("app", "android_common")