diff options
author | 2025-02-13 02:05:00 +0000 | |
---|---|---|
committer | 2025-02-19 00:18:39 +0000 | |
commit | 0a37d429bcbfdf5110bbfcf14f43764dc01585a4 (patch) | |
tree | acda2280ff7ee8cd210a9696b615297d64c4d5b4 /android | |
parent | 9354e34a7b2ba36b1e611dc0f062416649decbeb (diff) |
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
Diffstat (limited to 'android')
-rw-r--r-- | android/base_module_context.go | 9 | ||||
-rw-r--r-- | android/module.go | 19 | ||||
-rw-r--r-- | android/vintf_fragment.go | 12 |
3 files changed, 35 insertions, 5 deletions
diff --git a/android/base_module_context.go b/android/base_module_context.go index 4b90083be..cdee96f89 100644 --- a/android/base_module_context.go +++ b/android/base_module_context.go @@ -88,6 +88,11 @@ type BaseModuleContext interface { // 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 @@ func (b *baseModuleContext) otherModuleProvider(m blueprint.Module, provider blu 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 0ffb6cb53..c4a83777a 100644 --- a/android/module.go +++ b/android/module.go @@ -1908,12 +1908,17 @@ type CommonModuleInfo struct { // 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 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) 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 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) 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 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) 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 49cf99972..4a29fee87 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 @@ func registerVintfFragmentComponents(ctx RegistrationContext) { 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 @@ func (m *VintfFragmentModule) GenerateAndroidBuildActions(ctx ModuleContext) { m.outputFilePath = processedVintfFragment ctx.InstallFile(m.installDirPath, processedVintfFragment.Base(), processedVintfFragment) + + SetProvider(ctx, VintfFragmentInfoProvider, VintfFragmentInfo{ + OutputFile: m.OutputFile(), + }) } func (m *VintfFragmentModule) OutputFile() Path { |