Change depVisitor to use providers instead of type-asserting to
interfaces directly, the next step is to change it to use ModuleProxy
once IsDepInSameApex is ready.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I13a4e256a26dbf7f9b3b746d628ac8f68b4e598e
diff --git a/android/base_module_context.go b/android/base_module_context.go
index 4b90083..cdee96f 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -88,6 +88,11 @@
// This method shouldn't be used directly, prefer the type-safe android.OtherModuleProvider instead.
otherModuleProvider(m blueprint.Module, provider blueprint.AnyProviderKey) (any, bool)
+ // OtherModuleHasProvider returns true if the module has the given provider set. This
+ // can avoid copying the provider if the caller only cares about the existence of
+ // the provider.
+ OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool
+
// OtherModuleIsAutoGenerated returns true if the module is auto generated by another module
// instead of being defined in Android.bp file.
OtherModuleIsAutoGenerated(m blueprint.Module) bool
@@ -297,6 +302,10 @@
return b.bp.OtherModuleProvider(getWrappedModule(m), provider)
}
+func (b *baseModuleContext) OtherModuleHasProvider(m blueprint.Module, provider blueprint.AnyProviderKey) bool {
+ return b.bp.OtherModuleHasProvider(getWrappedModule(m), provider)
+}
+
func (b *baseModuleContext) OtherModuleIsAutoGenerated(m blueprint.Module) bool {
return b.bp.OtherModuleIsAutoGenerated(m)
}
diff --git a/android/module.go b/android/module.go
index 0ffb6cb..c4a8377 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1908,12 +1908,17 @@
// is used to avoid adding install or packaging dependencies into libraries provided
// by apexes.
UninstallableApexPlatformVariant bool
- HideFromMake bool
- SkipInstall bool
- IsStubsModule bool
- Host bool
MinSdkVersionSupported ApiLevel
ModuleWithMinSdkVersionCheck bool
+ // Tests if this module can be installed to APEX as a file. For example, this would return
+ // true for shared libs while return false for static libs because static libs are not
+ // installable module (but it can still be mutated for APEX)
+ IsInstallableToApex bool
+ HideFromMake bool
+ SkipInstall bool
+ IsStubsModule bool
+ Host bool
+ IsApexModule bool
}
type ApiLevelOrPlatform struct {
@@ -2252,7 +2257,6 @@
ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt,
Target: m.commonProperties.CompileTarget,
SkipAndroidMkProcessing: shouldSkipAndroidMkProcessing(ctx, m),
- BaseModuleName: m.BaseModuleName(),
UninstallableApexPlatformVariant: m.commonProperties.UninstallableApexPlatformVariant,
HideFromMake: m.commonProperties.HideFromMake,
SkipInstall: m.commonProperties.SkipInstall,
@@ -2295,6 +2299,8 @@
commonData.NotAvailableForPlatform = am.NotAvailableForPlatform()
commonData.NotInPlatform = am.NotInPlatform()
commonData.MinSdkVersionSupported = am.MinSdkVersionSupported(ctx)
+ commonData.IsInstallableToApex = am.IsInstallableToApex()
+ commonData.IsApexModule = true
}
if _, ok := m.module.(ModuleWithMinSdkVersionCheck); ok {
@@ -2304,6 +2310,9 @@
if st, ok := m.module.(StubsAvailableModule); ok {
commonData.IsStubsModule = st.IsStubsModule()
}
+ if mm, ok := m.module.(interface{ BaseModuleName() string }); ok {
+ commonData.BaseModuleName = mm.BaseModuleName()
+ }
SetProvider(ctx, CommonModuleInfoKey, commonData)
if p, ok := m.module.(PrebuiltInterface); ok && p.Prebuilt() != nil {
SetProvider(ctx, PrebuiltModuleInfoProvider, PrebuiltModuleInfo{
diff --git a/android/vintf_fragment.go b/android/vintf_fragment.go
index 49cf999..4a29fee 100644
--- a/android/vintf_fragment.go
+++ b/android/vintf_fragment.go
@@ -14,6 +14,8 @@
package android
+import "github.com/google/blueprint"
+
type vintfFragmentProperties struct {
// Vintf fragment XML file.
Src string `android:"path"`
@@ -37,6 +39,12 @@
ctx.RegisterModuleType("vintf_fragment", vintfLibraryFactory)
}
+type VintfFragmentInfo struct {
+ OutputFile Path
+}
+
+var VintfFragmentInfoProvider = blueprint.NewProvider[VintfFragmentInfo]()
+
// vintf_fragment module processes vintf fragment file and installs under etc/vintf/manifest.
// Vintf fragment files formerly listed in vintf_fragment property would be transformed into
// this module type.
@@ -68,6 +76,10 @@
m.outputFilePath = processedVintfFragment
ctx.InstallFile(m.installDirPath, processedVintfFragment.Base(), processedVintfFragment)
+
+ SetProvider(ctx, VintfFragmentInfoProvider, VintfFragmentInfo{
+ OutputFile: m.OutputFile(),
+ })
}
func (m *VintfFragmentModule) OutputFile() Path {