From 48203e3dee2be5a5432af1b76be6a3b58ca02933 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Fri, 2 Jun 2023 23:42:21 +0100 Subject: [PATCH] Add an allowlist for modules that have broken optional_uses_libs. Bug: 282877248 Test: m nothing Change-Id: I1afe9d523af0633f0428d4c15e1417db1dae4e93 --- android/config.go | 4 ++++ android/variable.go | 2 ++ java/app.go | 2 +- java/app_test.go | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/android/config.go b/android/config.go index 14fc04d11..236d1c152 100644 --- a/android/config.go +++ b/android/config.go @@ -1925,6 +1925,10 @@ func (c *deviceConfig) BuildBrokenInputDir(name string) bool { return InList(name, c.config.productVariables.BuildBrokenInputDirModules) } +func (c *config) BuildWarningBadOptionalUsesLibsAllowlist() []string { + return c.productVariables.BuildWarningBadOptionalUsesLibsAllowlist +} + func (c *deviceConfig) GenruleSandboxing() bool { return Bool(c.config.productVariables.GenruleSandboxing) } diff --git a/android/variable.go b/android/variable.go index 972663bb0..9fb25371f 100644 --- a/android/variable.go +++ b/android/variable.go @@ -449,6 +449,8 @@ type productVariables struct { BuildBrokenVendorPropertyNamespace bool `json:",omitempty"` BuildBrokenInputDirModules []string `json:",omitempty"` + BuildWarningBadOptionalUsesLibsAllowlist []string `json:",omitempty"` + BuildDebugfsRestrictionsEnabled bool `json:",omitempty"` RequiresInsecureExecmemForSwiftshader bool `json:",omitempty"` diff --git a/java/app.go b/java/app.go index 58580d420..3e4c8cf5a 100755 --- a/java/app.go +++ b/java/app.go @@ -1396,7 +1396,7 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps boo func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string { optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool { 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) } return exists diff --git a/java/app_test.go b/java/app_test.go index 5aed17876..cf7d17490 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2644,6 +2644,9 @@ func TestUsesLibraries(t *testing.T) { prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"), + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.BuildWarningBadOptionalUsesLibsAllowlist = []string{"app", "prebuilt"} + }), ).RunTestWithBp(t, bp) app := result.ModuleForTests("app", "android_common")