Merge changes from topic "sysprop-apex-available"
* changes:
Add apex_available tags for sysprop modules
Add apex_available for static/shared only props
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 03d9de8..6951fc3 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -65,6 +65,8 @@
Native_coverage *bool
+ Apex_available []string
+
sdkAttributes
tidyAttributes
@@ -220,7 +222,7 @@
}
// Parses properties common to static and shared libraries. Also used for prebuilt libraries.
-func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, _ *libraryDecorator, isStatic bool) staticOrSharedAttributes {
+func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
attrs := staticOrSharedAttributes{}
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
@@ -244,13 +246,16 @@
// empty list -> no values specified
attrs.System_dynamic_deps.ForceSpecifyEmptyList = true
+ var apexAvailable []string
if isStatic {
+ apexAvailable = lib.StaticProperties.Static.Apex_available
bp2BuildPropParseHelper(ctx, module, &StaticProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
if staticOrSharedProps, ok := props.(*StaticProperties); ok {
setAttrs(axis, config, staticOrSharedProps.Static)
}
})
} else {
+ apexAvailable = lib.SharedProperties.Shared.Apex_available
bp2BuildPropParseHelper(ctx, module, &SharedProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
if staticOrSharedProps, ok := props.(*SharedProperties); ok {
setAttrs(axis, config, staticOrSharedProps.Shared)
@@ -263,6 +268,8 @@
attrs.Srcs_c = partitionedSrcs[cSrcPartition]
attrs.Srcs_as = partitionedSrcs[asSrcPartition]
+ attrs.Apex_available = android.ConvertApexAvailableToTags(apexAvailable)
+
if !partitionedSrcs[protoSrcPartition].IsEmpty() {
// TODO(b/208815215): determine whether this is used and add support if necessary
ctx.ModuleErrorf("Migrating static/shared only proto srcs is not currently supported")
diff --git a/cc/library.go b/cc/library.go
index 1b579cd..31b76cd 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -428,8 +428,10 @@
if compilerAttrs.stubsSymbolFile == nil && len(compilerAttrs.stubsVersions.Value) == 0 {
tagsForStaticVariant = android.ApexAvailableTags(m)
}
+ tagsForStaticVariant.Append(bazel.StringListAttribute{Value: staticAttrs.Apex_available})
tagsForSharedVariant := android.ApexAvailableTags(m)
+ tagsForSharedVariant.Append(bazel.StringListAttribute{Value: sharedAttrs.Apex_available})
ctx.CreateBazelTargetModuleWithRestrictions(staticProps,
android.CommonAttributes{
diff --git a/cc/sysprop.go b/cc/sysprop.go
index 2b1e354..0df290a 100644
--- a/cc/sysprop.go
+++ b/cc/sysprop.go
@@ -22,11 +22,13 @@
// TODO(b/240463568): Additional properties will be added for API validation
type bazelSyspropLibraryAttributes struct {
Srcs bazel.LabelListAttribute
+ Tags bazel.StringListAttribute
}
type bazelCcSyspropLibraryAttributes struct {
Dep bazel.LabelAttribute
Min_sdk_version *string
+ Tags bazel.StringListAttribute
}
type SyspropLibraryLabels struct {
@@ -36,6 +38,7 @@
}
func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
+ apexAvailableTags := android.ApexAvailableTags(ctx.Module())
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{
Rule_class: "sysprop_library",
@@ -44,11 +47,14 @@
android.CommonAttributes{Name: labels.SyspropLibraryLabel},
&bazelSyspropLibraryAttributes{
Srcs: srcs,
- })
+ Tags: apexAvailableTags,
+ },
+ )
attrs := &bazelCcSyspropLibraryAttributes{
Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel),
Min_sdk_version: minSdkVersion,
+ Tags: apexAvailableTags,
}
if labels.SharedLibraryLabel != "" {