Merge "Allow sdk snapshot to contain source module type" am: f08e7c444c
am: 5a0a87eb16
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1702366 Change-Id: I5d3cf9ae686c564a7193e49fbc0c2d50bdd84c8c
This commit is contained in:
@@ -405,6 +405,10 @@ type SdkMemberType interface {
|
|||||||
// the module is not allowed in whichever sdk property it was added.
|
// the module is not allowed in whichever sdk property it was added.
|
||||||
IsInstance(module Module) bool
|
IsInstance(module Module) bool
|
||||||
|
|
||||||
|
// UsesSourceModuleTypeInSnapshot returns true when the AddPrebuiltModule() method returns a
|
||||||
|
// source module type.
|
||||||
|
UsesSourceModuleTypeInSnapshot() bool
|
||||||
|
|
||||||
// Add a prebuilt module that the sdk will populate.
|
// Add a prebuilt module that the sdk will populate.
|
||||||
//
|
//
|
||||||
// The sdk module code generates the snapshot as follows:
|
// The sdk module code generates the snapshot as follows:
|
||||||
@@ -451,6 +455,11 @@ type SdkMemberTypeBase struct {
|
|||||||
PropertyName string
|
PropertyName string
|
||||||
SupportsSdk bool
|
SupportsSdk bool
|
||||||
HostOsDependent bool
|
HostOsDependent bool
|
||||||
|
|
||||||
|
// When set to true UseSourceModuleTypeInSnapshot indicates that the member type creates a source
|
||||||
|
// module type in its SdkMemberType.AddPrebuiltModule() method. That prevents the sdk snapshot
|
||||||
|
// code from automatically adding a prefer: true flag.
|
||||||
|
UseSourceModuleTypeInSnapshot bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *SdkMemberTypeBase) SdkPropertyName() string {
|
func (b *SdkMemberTypeBase) SdkPropertyName() string {
|
||||||
@@ -465,6 +474,10 @@ func (b *SdkMemberTypeBase) IsHostOsDependent() bool {
|
|||||||
return b.HostOsDependent
|
return b.HostOsDependent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *SdkMemberTypeBase) UsesSourceModuleTypeInSnapshot() bool {
|
||||||
|
return b.UseSourceModuleTypeInSnapshot
|
||||||
|
}
|
||||||
|
|
||||||
// Encapsulates the information about registered SdkMemberTypes.
|
// Encapsulates the information about registered SdkMemberTypes.
|
||||||
type SdkMemberTypesRegistry struct {
|
type SdkMemberTypesRegistry struct {
|
||||||
// The list of types sorted by property name.
|
// The list of types sorted by property name.
|
||||||
|
@@ -1370,17 +1370,20 @@ func (s *sdk) createMemberSnapshot(ctx *memberContext, member *sdkMember, bpModu
|
|||||||
|
|
||||||
memberType := member.memberType
|
memberType := member.memberType
|
||||||
|
|
||||||
// Set the prefer based on the environment variable. This is a temporary work around to allow a
|
// Do not add the prefer property if the member snapshot module is a source module type.
|
||||||
// snapshot to be created that sets prefer: true.
|
if !memberType.UsesSourceModuleTypeInSnapshot() {
|
||||||
// TODO(b/174997203): Remove once the ability to select the modules to prefer can be done
|
// Set the prefer based on the environment variable. This is a temporary work around to allow a
|
||||||
// dynamically at build time not at snapshot generation time.
|
// snapshot to be created that sets prefer: true.
|
||||||
prefer := ctx.sdkMemberContext.Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_PREFER")
|
// TODO(b/174997203): Remove once the ability to select the modules to prefer can be done
|
||||||
|
// dynamically at build time not at snapshot generation time.
|
||||||
|
prefer := ctx.sdkMemberContext.Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_PREFER")
|
||||||
|
|
||||||
// Set prefer. Setting this to false is not strictly required as that is the default but it does
|
// Set prefer. Setting this to false is not strictly required as that is the default but it does
|
||||||
// provide a convenient hook to post-process the generated Android.bp file, e.g. in tests to
|
// provide a convenient hook to post-process the generated Android.bp file, e.g. in tests to
|
||||||
// check the behavior when a prebuilt is preferred. It also makes it explicit what the default
|
// check the behavior when a prebuilt is preferred. It also makes it explicit what the default
|
||||||
// behavior is for the module.
|
// behavior is for the module.
|
||||||
bpModule.insertAfter("name", "prefer", prefer)
|
bpModule.insertAfter("name", "prefer", prefer)
|
||||||
|
}
|
||||||
|
|
||||||
// Group the variants by os type.
|
// Group the variants by os type.
|
||||||
variantsByOsType := make(map[android.OsType][]android.Module)
|
variantsByOsType := make(map[android.OsType][]android.Module)
|
||||||
|
Reference in New Issue
Block a user