Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b83b7b02 authored by Liz Kammer's avatar Liz Kammer Committed by Sasha Smundak
Browse files

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
parent 9d2d4106
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -3426,7 +3426,7 @@ type bazelApexBundleAttributes struct {
	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 @@ type convertedNativeSharedLibs struct {
	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 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
		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