diff options
author | 2024-12-10 23:39:24 +0000 | |
---|---|---|
committer | 2024-12-10 23:39:24 +0000 | |
commit | c4179b5f7fc5e6de0ce27d9583ff5edfc93389c0 (patch) | |
tree | fc3ce0b4f1f3daeaea8107dfc169f4e95b85b080 | |
parent | ea96c9fb69fc7c98b7789bf2d18fb398c5223908 (diff) | |
parent | b73c3a6d221523f06d30c15145866056556187d0 (diff) |
Merge "Convert checkApexAvailability to use ModuleProxy." into main
-rw-r--r-- | android/apex.go | 16 | ||||
-rw-r--r-- | android/module_proxy.go | 2 | ||||
-rw-r--r-- | apex/apex.go | 15 | ||||
-rw-r--r-- | apex/apex_test.go | 8 | ||||
-rw-r--r-- | cc/cc.go | 13 | ||||
-rw-r--r-- | cc/library.go | 10 | ||||
-rw-r--r-- | java/base.go | 11 | ||||
-rw-r--r-- | java/sdk_library_internal.go | 11 |
8 files changed, 55 insertions, 31 deletions
diff --git a/android/apex.go b/android/apex.go index f625bafcc..78511f9aa 100644 --- a/android/apex.go +++ b/android/apex.go @@ -77,6 +77,9 @@ type ApexInfo struct { // Returns the value of `apex_available_name` ApexAvailableName string + + // Returns the apex names that this module is available for + ApexAvailableFor []string } // AllApexInfo holds the ApexInfo of all apexes that include this module. @@ -213,6 +216,12 @@ type ApexModule interface { // apex_available property of the module. AvailableFor(what string) bool + // Returns the apexes that are available for this module, valid values include + // "//apex_available:platform", "//apex_available:anyapex" and specific apexes. + // There are some differences between this one and the ApexAvailable on + // ApexModuleBase for cc, java library and sdkLibraryXml. + ApexAvailableFor() []string + // AlwaysRequiresPlatformApexVariant allows the implementing module to determine whether an // APEX mutator should always be created for it. // @@ -320,6 +329,10 @@ func (m *ApexModuleBase) ApexAvailable() []string { return CopyOf(availableToPlatformList) } +func (m *ApexModuleBase) ApexAvailableFor() []string { + return m.ApexAvailable() +} + // Implements ApexModule func (m *ApexModuleBase) BuildForApex(apex ApexInfo) { m.apexInfosLock.Lock() @@ -420,7 +433,7 @@ func CheckAvailableForApex(what string, apex_available []string) bool { // Implements ApexModule func (m *ApexModuleBase) AvailableFor(what string) bool { - return CheckAvailableForApex(what, m.ApexProperties.Apex_available) + return CheckAvailableForApex(what, m.ApexAvailableFor()) } // Implements ApexModule @@ -614,6 +627,7 @@ func MutateApexTransition(ctx BaseModuleContext, variation string) { } else { panic(fmt.Errorf("failed to find apexInfo for incoming variation %q", variation)) } + thisApexInfo.ApexAvailableFor = module.ApexAvailableFor() SetProvider(ctx, ApexInfoProvider, thisApexInfo) } diff --git a/android/module_proxy.go b/android/module_proxy.go index 30459b9cd..8cc8fa1e7 100644 --- a/android/module_proxy.go +++ b/android/module_proxy.go @@ -189,7 +189,7 @@ func (m ModuleProxy) VariablesForTests() map[string]string { } func (m ModuleProxy) String() string { - return m.module.Name() + return m.module.String() } func (m ModuleProxy) qualifiedModuleId(ctx BaseModuleContext) qualifiedModuleName { diff --git a/apex/apex.go b/apex/apex.go index e22cf9ea6..912780dca 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2694,7 +2694,7 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { return } - a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from android.Module, to android.ApexModule, externalDep bool) bool { + a.WalkPayloadDepsProxy(ctx, func(ctx android.BaseModuleContext, from, to android.ModuleProxy, externalDep bool) bool { // As soon as the dependency graph crosses the APEX boundary, don't go further. if externalDep { return false @@ -2711,17 +2711,8 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { fromName := ctx.OtherModuleName(from) toName := ctx.OtherModuleName(to) - // If `to` is not actually in the same APEX as `from` then it does not need - // apex_available and neither do any of its dependencies. - // - // It is ok to call DepIsInSameApex() directly from within WalkPayloadDeps(). - if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { - // As soon as the dependency graph crosses the APEX boundary, don't go - // further. - return false - } - - if to.AvailableFor(apexName) { + if android.CheckAvailableForApex(apexName, + android.OtherModuleProviderOrDefault(ctx, to, android.ApexInfoProvider).ApexAvailableFor) { return true } diff --git a/apex/apex_test.go b/apex/apex_test.go index 282cd1dd3..12cf6a693 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -6353,10 +6353,16 @@ func TestApexAvailable_IndirectDep(t *testing.T) { testApexError(t, `requires "libbaz" that doesn't list the APEX under 'apex_available'.\n\nDependency path: .*via tag apex\.dependencyTag\{"sharedLib"\} .*-> libfoo.*link:shared.* +.*via tag cc\.dependencyTag.* +.*-> libfoo.*link:static.* .*via tag cc\.libraryDependencyTag.*Kind:sharedLibraryDependency.* .*-> libbar.*link:shared.* +.*via tag cc\.dependencyTag.* +.*-> libbar.*link:static.* .*via tag cc\.libraryDependencyTag.*Kind:sharedLibraryDependency.* -.*-> libbaz.*link:shared.*`, ` +.*-> libbaz.*link:shared.* +.*via tag cc\.dependencyTag.* +.*-> libbaz.*link:static.*`, ` apex { name: "myapex", key: "myapex.key", @@ -3689,13 +3689,18 @@ func (c *Module) IsInstallableToApex() bool { } func (c *Module) AvailableFor(what string) bool { + return android.CheckAvailableForApex(what, c.ApexAvailableFor()) +} + +func (c *Module) ApexAvailableFor() []string { + list := c.ApexModuleBase.ApexAvailable() if linker, ok := c.linker.(interface { - availableFor(string) bool + apexAvailable() []string }); ok { - return c.ApexModuleBase.AvailableFor(what) || linker.availableFor(what) - } else { - return c.ApexModuleBase.AvailableFor(what) + list = append(list, linker.apexAvailable()...) } + + return android.FirstUniqueStrings(list) } func (c *Module) EverInstallable() bool { diff --git a/cc/library.go b/cc/library.go index 6485ea364..ebc65efbd 100644 --- a/cc/library.go +++ b/cc/library.go @@ -723,7 +723,7 @@ type libraryInterface interface { // Write LOCAL_ADDITIONAL_DEPENDENCIES for ABI diff androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) - availableFor(string) bool + apexAvailable() []string getAPIListCoverageXMLPath() android.ModuleOutPath @@ -1959,17 +1959,15 @@ func (library *libraryDecorator) isLatestStubVersion() bool { return library.MutatedProperties.IsLatestVersion } -func (library *libraryDecorator) availableFor(what string) bool { +func (library *libraryDecorator) apexAvailable() []string { var list []string if library.static() { list = library.StaticProperties.Static.Apex_available } else if library.shared() { list = library.SharedProperties.Shared.Apex_available } - if len(list) == 0 { - return false - } - return android.CheckAvailableForApex(what, list) + + return list } func (library *libraryDecorator) installable() *bool { diff --git a/java/base.go b/java/base.go index f26404b8c..b579a5d0f 100644 --- a/java/base.go +++ b/java/base.go @@ -838,13 +838,18 @@ func (j *Module) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLev } func (j *Module) AvailableFor(what string) bool { - if what == android.AvailableToPlatform && Bool(j.deviceProperties.Hostdex) { + return android.CheckAvailableForApex(what, j.ApexAvailableFor()) +} + +func (j *Module) ApexAvailableFor() []string { + list := j.ApexModuleBase.ApexAvailable() + if Bool(j.deviceProperties.Hostdex) { // Exception: for hostdex: true libraries, the platform variant is created // even if it's not marked as available to platform. In that case, the platform // variant is used only for the hostdex and not installed to the device. - return true + list = append(list, android.AvailableToPlatform) } - return j.ApexModuleBase.AvailableFor(what) + return android.FirstUniqueStrings(list) } func (j *Module) staticLibs(ctx android.BaseModuleContext) []string { diff --git a/java/sdk_library_internal.go b/java/sdk_library_internal.go index 768e57a11..ec9c160ea 100644 --- a/java/sdk_library_internal.go +++ b/java/sdk_library_internal.go @@ -15,12 +15,13 @@ package java import ( - "android/soong/android" - "android/soong/etc" "fmt" "path" "strings" + "android/soong/android" + "android/soong/etc" + "github.com/google/blueprint/proptools" ) @@ -778,7 +779,11 @@ var _ etc.PrebuiltEtcModule = (*sdkLibraryXml)(nil) // from android.ApexModule func (module *sdkLibraryXml) AvailableFor(what string) bool { - return true + return android.CheckAvailableForApex(what, module.ApexAvailableFor()) +} + +func (module *sdkLibraryXml) ApexAvailableFor() []string { + return []string{android.AvailableToPlatform, android.AvailableToAnyApex} } func (module *sdkLibraryXml) DepsMutator(ctx android.BottomUpMutatorContext) { |