Move setting of prefer to createMemberSnapshot
Test: m nothing Change-Id: Iab1c048fe74a5e474f68ce4acc6c1b41381368ca
This commit is contained in:
parent
d8561166eb
commit
83ad956ec4
|
@ -188,6 +188,12 @@ func (s *bpPropertySet) setProperty(name string, value interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *bpPropertySet) removeProperty(name string) {
|
||||||
|
delete(s.properties, name)
|
||||||
|
delete(s.tags, name)
|
||||||
|
_, s.order = android.RemoveFromList(name, s.order)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *bpPropertySet) insertAfter(position string, name string, value interface{}) {
|
func (s *bpPropertySet) insertAfter(position string, name string, value interface{}) {
|
||||||
if s.properties[name] != nil {
|
if s.properties[name] != nil {
|
||||||
panic("Property %q already exists in property set")
|
panic("Property %q already exists in property set")
|
||||||
|
|
|
@ -284,11 +284,6 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
||||||
// to internal members with a unique module name and setting prefer: false.
|
// to internal members with a unique module name and setting prefer: false.
|
||||||
unversionedTransformer := unversionedTransformation{
|
unversionedTransformer := unversionedTransformation{
|
||||||
builder: builder,
|
builder: builder,
|
||||||
// Set the prefer based on the environment variable. This is a temporary work around to allow a
|
|
||||||
// snapshot to be created that sets prefer: true.
|
|
||||||
// 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.Config().IsEnvTrue("SOONG_SDK_SNAPSHOT_PREFER"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, unversioned := range builder.prebuiltOrder {
|
for _, unversioned := range builder.prebuiltOrder {
|
||||||
|
@ -614,6 +609,8 @@ func (t unversionedToVersionedTransformation) transformModule(module *bpModule)
|
||||||
name := module.getValue("name").(string)
|
name := module.getValue("name").(string)
|
||||||
module.setProperty("name", t.builder.versionedSdkMemberName(name, true))
|
module.setProperty("name", t.builder.versionedSdkMemberName(name, true))
|
||||||
module.insertAfter("name", "sdk_member_name", name)
|
module.insertAfter("name", "sdk_member_name", name)
|
||||||
|
// Remove the prefer property if present as versioned modules never need marking with prefer.
|
||||||
|
module.removeProperty("prefer")
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,20 +626,12 @@ func (t unversionedToVersionedTransformation) transformProperty(name string, val
|
||||||
type unversionedTransformation struct {
|
type unversionedTransformation struct {
|
||||||
identityTransformation
|
identityTransformation
|
||||||
builder *snapshotBuilder
|
builder *snapshotBuilder
|
||||||
prefer bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t unversionedTransformation) transformModule(module *bpModule) *bpModule {
|
func (t unversionedTransformation) transformModule(module *bpModule) *bpModule {
|
||||||
// If the module is an internal member then use a unique name for it.
|
// If the module is an internal member then use a unique name for it.
|
||||||
name := module.getValue("name").(string)
|
name := module.getValue("name").(string)
|
||||||
module.setProperty("name", t.builder.unversionedSdkMemberName(name, true))
|
module.setProperty("name", t.builder.unversionedSdkMemberName(name, true))
|
||||||
|
|
||||||
// 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 check
|
|
||||||
// the behavior when a prebuilt is preferred. It also makes it explicit what the default behavior
|
|
||||||
// is for the module.
|
|
||||||
module.insertAfter("name", "prefer", t.prefer)
|
|
||||||
|
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1381,6 +1370,18 @@ 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
|
||||||
|
// snapshot to be created that sets prefer: true.
|
||||||
|
// 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
|
||||||
|
// 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
|
||||||
|
// behavior is for the module.
|
||||||
|
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)
|
||||||
variants := member.Variants()
|
variants := member.Variants()
|
||||||
|
|
Loading…
Reference in New Issue