bp2build apex min_sdk_version w/ soong config var
Previously min_sdk_version did not handle soong config vars
Test: m bp2build and verify com.android.adbd
Change-Id: I48426a8e6e03b61234b77ce7d7ec07b1cab36b7b
diff --git a/apex/apex.go b/apex/apex.go
index e99823b..9485a4b 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -3426,7 +3426,7 @@
Key bazel.LabelAttribute
Certificate bazel.LabelAttribute // used when the certificate prop is a module
Certificate_name bazel.StringAttribute // used when the certificate prop is a string
- Min_sdk_version *string
+ Min_sdk_version bazel.StringAttribute
Updatable bazel.BoolAttribute
Installable bazel.BoolAttribute
Binaries bazel.LabelListAttribute
@@ -3445,6 +3445,10 @@
Native_shared_libs_64 bazel.LabelListAttribute
}
+const (
+ minSdkVersionPropName = "Min_sdk_version"
+)
+
// ConvertWithBp2build performs bp2build conversion of an apex
func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
// We only convert apex and apex_test modules at this time
@@ -3483,11 +3487,19 @@
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.File_contexts))
}
+ productVariableProps := android.ProductVariableProperties(ctx)
// TODO(b/219503907) this would need to be set to a.MinSdkVersionValue(ctx) but
// given it's coming via config, we probably don't want to put it in here.
- var minSdkVersion *string
+ var minSdkVersion bazel.StringAttribute
if a.properties.Min_sdk_version != nil {
- minSdkVersion = a.properties.Min_sdk_version
+ minSdkVersion.SetValue(*a.properties.Min_sdk_version)
+ }
+ if props, ok := productVariableProps[minSdkVersionPropName]; ok {
+ for c, p := range props {
+ if val, ok := p.(*string); ok {
+ minSdkVersion.SetSelectValue(c.ConfigurationAxis(), c.SelectKey(), val)
+ }
+ }
}
var keyLabelAttribute bazel.LabelAttribute