Merge "bp2build of libraries with stubs should handle non-implementation deps"
This commit is contained in:
@@ -1080,43 +1080,13 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
|
||||
la.resolveTargetApexProp(ctx, props)
|
||||
|
||||
if axis == bazel.NoConfigAxis || (axis == bazel.OsConfigurationAxis && config == bazel.OsAndroid) {
|
||||
// If a dependency in la.implementationDynamicDeps has stubs, its stub variant should be
|
||||
// used when the dependency is linked in a APEX. The dependencies in NoConfigAxis and
|
||||
// OsConfigurationAxis/OsAndroid are grouped by having stubs or not, so Bazel select()
|
||||
// statement can be used to choose source/stub variants of them.
|
||||
depsWithStubs := []bazel.Label{}
|
||||
for _, l := range sharedDeps.implementation.Includes {
|
||||
dep, _ := ctx.ModuleFromName(l.OriginalModuleName)
|
||||
if m, ok := dep.(*Module); ok && m.HasStubsVariants() {
|
||||
depsWithStubs = append(depsWithStubs, l)
|
||||
}
|
||||
}
|
||||
if len(depsWithStubs) > 0 {
|
||||
implDynamicDeps := bazel.SubtractBazelLabelList(sharedDeps.implementation, bazel.MakeLabelList(depsWithStubs))
|
||||
la.implementationDynamicDeps.SetSelectValue(axis, config, implDynamicDeps)
|
||||
|
||||
stubLibLabels := []bazel.Label{}
|
||||
for _, l := range depsWithStubs {
|
||||
l.Label = l.Label + stubsSuffix
|
||||
stubLibLabels = append(stubLibLabels, l)
|
||||
}
|
||||
inApexSelectValue := la.implementationDynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
|
||||
nonApexSelectValue := la.implementationDynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex)
|
||||
defaultSelectValue := la.implementationDynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey)
|
||||
if axis == bazel.NoConfigAxis {
|
||||
(&inApexSelectValue).Append(bazel.MakeLabelList(stubLibLabels))
|
||||
(&nonApexSelectValue).Append(bazel.MakeLabelList(depsWithStubs))
|
||||
(&defaultSelectValue).Append(bazel.MakeLabelList(depsWithStubs))
|
||||
la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.FirstUniqueBazelLabelList(inApexSelectValue))
|
||||
la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, bazel.FirstUniqueBazelLabelList(nonApexSelectValue))
|
||||
la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, bazel.FirstUniqueBazelLabelList(defaultSelectValue))
|
||||
} else if config == bazel.OsAndroid {
|
||||
(&inApexSelectValue).Append(bazel.MakeLabelList(stubLibLabels))
|
||||
(&nonApexSelectValue).Append(bazel.MakeLabelList(depsWithStubs))
|
||||
la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.FirstUniqueBazelLabelList(inApexSelectValue))
|
||||
la.implementationDynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, bazel.FirstUniqueBazelLabelList(nonApexSelectValue))
|
||||
}
|
||||
}
|
||||
// If a dependency in la.implementationDynamicDeps or la.dynamicDeps has stubs, its
|
||||
// stub variant should be used when the dependency is linked in a APEX. The
|
||||
// dependencies in NoConfigAxis and OsConfigurationAxis/OsAndroid are grouped by
|
||||
// having stubs or not, so Bazel select() statement can be used to choose
|
||||
// source/stub variants of them.
|
||||
setStubsForDynamicDeps(ctx, axis, config, sharedDeps.export, &la.dynamicDeps, 0)
|
||||
setStubsForDynamicDeps(ctx, axis, config, sharedDeps.implementation, &la.implementationDynamicDeps, 1)
|
||||
}
|
||||
|
||||
if !BoolDefault(props.Pack_relocations, packRelocationsDefault) {
|
||||
@@ -1173,6 +1143,43 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
|
||||
}
|
||||
}
|
||||
|
||||
func setStubsForDynamicDeps(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis,
|
||||
config string, dynamicLibs bazel.LabelList, dynamicDeps *bazel.LabelListAttribute, ind int) {
|
||||
depsWithStubs := []bazel.Label{}
|
||||
for _, l := range dynamicLibs.Includes {
|
||||
dep, _ := ctx.ModuleFromName(l.OriginalModuleName)
|
||||
if m, ok := dep.(*Module); ok && m.HasStubsVariants() {
|
||||
depsWithStubs = append(depsWithStubs, l)
|
||||
}
|
||||
}
|
||||
if len(depsWithStubs) > 0 {
|
||||
implDynamicDeps := bazel.SubtractBazelLabelList(dynamicLibs, bazel.MakeLabelList(depsWithStubs))
|
||||
dynamicDeps.SetSelectValue(axis, config, implDynamicDeps)
|
||||
|
||||
stubLibLabels := []bazel.Label{}
|
||||
for _, l := range depsWithStubs {
|
||||
l.Label = l.Label + stubsSuffix
|
||||
stubLibLabels = append(stubLibLabels, l)
|
||||
}
|
||||
inApexSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex)
|
||||
nonApexSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex)
|
||||
defaultSelectValue := dynamicDeps.SelectValue(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey)
|
||||
if axis == bazel.NoConfigAxis {
|
||||
(&inApexSelectValue).Append(bazel.MakeLabelList(stubLibLabels))
|
||||
(&nonApexSelectValue).Append(bazel.MakeLabelList(depsWithStubs))
|
||||
(&defaultSelectValue).Append(bazel.MakeLabelList(depsWithStubs))
|
||||
dynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.FirstUniqueBazelLabelList(inApexSelectValue))
|
||||
dynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, bazel.FirstUniqueBazelLabelList(nonApexSelectValue))
|
||||
dynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.ConditionsDefaultConfigKey, bazel.FirstUniqueBazelLabelList(defaultSelectValue))
|
||||
} else if config == bazel.OsAndroid {
|
||||
(&inApexSelectValue).Append(bazel.MakeLabelList(stubLibLabels))
|
||||
(&nonApexSelectValue).Append(bazel.MakeLabelList(depsWithStubs))
|
||||
dynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndInApex, bazel.FirstUniqueBazelLabelList(inApexSelectValue))
|
||||
dynamicDeps.SetSelectValue(bazel.OsAndInApexAxis, bazel.AndroidAndNonApex, bazel.FirstUniqueBazelLabelList(nonApexSelectValue))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (la *linkerAttributes) convertStripProps(ctx android.BazelConversionPathContext, module *Module) {
|
||||
bp2BuildPropParseHelper(ctx, module, &StripProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
|
||||
if stripProperties, ok := props.(*StripProperties); ok {
|
||||
|
Reference in New Issue
Block a user