Remove memberMutator and use DepsMutator instead
Previously, the memberMutator was responsible for adding dependencies from the sdk to its members. It could not just implement DepsMutator() as it had to be run before the memberDepsMutator which itself had to be run before the depsMutator. As the memberDepsMutator has been removed by a previous change this change removes the memberMutator and just performs that functionality in the standard DepsMutator(BottomMutatorContext) method. Bug: 260237150 Test: m nothing BUILD_NUMBER=fixed packages/modules/common/build/mainline_modules_sdks.sh # Run the above before and after this change and compare the # out/dist/*mainline-sdks directory contents to ensure that there are no # changes. Change-Id: I264bdeee84f2349e30e5c24dd4861e945640d020
This commit is contained in:
parent
0e2a5bc075
commit
2156abe252
1 changed files with 25 additions and 33 deletions
58
sdk/sdk.go
58
sdk/sdk.go
|
@ -37,7 +37,6 @@ func init() {
|
|||
func registerSdkBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("sdk", SdkModuleFactory)
|
||||
ctx.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory)
|
||||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||
}
|
||||
|
||||
type sdk struct {
|
||||
|
@ -274,13 +273,6 @@ func (d *dependencyContext) RequiresTrait(name string, trait android.SdkMemberTr
|
|||
|
||||
var _ android.SdkDependencyContext = (*dependencyContext)(nil)
|
||||
|
||||
// RegisterPreDepsMutators registers pre-deps mutators to support modules implementing SdkAware
|
||||
// interface and the sdk module type. This function has been made public to be called by tests
|
||||
// outside of the sdk package
|
||||
func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("SdkMember", memberMutator).Parallel()
|
||||
}
|
||||
|
||||
type dependencyTag struct {
|
||||
blueprint.BaseDependencyTag
|
||||
}
|
||||
|
@ -290,35 +282,35 @@ func (t dependencyTag) ExcludeFromApexContents() {}
|
|||
|
||||
var _ android.ExcludeFromApexContentsTag = dependencyTag{}
|
||||
|
||||
// Step 1: create dependencies from an SDK module to its members.
|
||||
func memberMutator(mctx android.BottomUpMutatorContext) {
|
||||
if s, ok := mctx.Module().(*sdk); ok {
|
||||
// Add dependencies from enabled and non CommonOS variants to the sdk member variants.
|
||||
if s.Enabled() && !s.IsCommonOSVariant() {
|
||||
ctx := s.newDependencyContext(mctx)
|
||||
for _, memberListProperty := range s.memberTypeListProperties() {
|
||||
if memberListProperty.getter == nil {
|
||||
continue
|
||||
}
|
||||
names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
|
||||
if len(names) > 0 {
|
||||
memberType := memberListProperty.memberType
|
||||
func (s *sdk) DepsMutator(mctx android.BottomUpMutatorContext) {
|
||||
// Add dependencies from non CommonOS variants to the sdk member variants.
|
||||
if s.IsCommonOSVariant() {
|
||||
return
|
||||
}
|
||||
|
||||
// Verify that the member type supports the specified traits.
|
||||
supportedTraits := memberType.SupportedTraits()
|
||||
for _, name := range names {
|
||||
requiredTraits := ctx.RequiredTraits(name)
|
||||
unsupportedTraits := requiredTraits.Subtract(supportedTraits)
|
||||
if !unsupportedTraits.Empty() {
|
||||
ctx.ModuleErrorf("sdk member %q has traits %s that are unsupported by its member type %q", name, unsupportedTraits, memberType.SdkPropertyName())
|
||||
}
|
||||
}
|
||||
ctx := s.newDependencyContext(mctx)
|
||||
for _, memberListProperty := range s.memberTypeListProperties() {
|
||||
if memberListProperty.getter == nil {
|
||||
continue
|
||||
}
|
||||
names := memberListProperty.getter(s.dynamicMemberTypeListProperties)
|
||||
if len(names) > 0 {
|
||||
memberType := memberListProperty.memberType
|
||||
|
||||
// Add dependencies using the appropriate tag.
|
||||
tag := memberListProperty.dependencyTag
|
||||
memberType.AddDependencies(ctx, tag, names)
|
||||
// Verify that the member type supports the specified traits.
|
||||
supportedTraits := memberType.SupportedTraits()
|
||||
for _, name := range names {
|
||||
requiredTraits := ctx.RequiredTraits(name)
|
||||
unsupportedTraits := requiredTraits.Subtract(supportedTraits)
|
||||
if !unsupportedTraits.Empty() {
|
||||
ctx.ModuleErrorf("sdk member %q has traits %s that are unsupported by its member type %q",
|
||||
name, unsupportedTraits, memberType.SdkPropertyName())
|
||||
}
|
||||
}
|
||||
|
||||
// Add dependencies using the appropriate tag.
|
||||
tag := memberListProperty.dependencyTag
|
||||
memberType.AddDependencies(ctx, tag, names)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue