Merge changes from topic "sysprop-apex-available"

* changes:
  Add apex_available tags for sysprop modules
  Add apex_available for static/shared only props
This commit is contained in:
Treehugger Robot
2023-03-24 22:21:16 +00:00
committed by Gerrit Code Review
3 changed files with 17 additions and 2 deletions

View File

@@ -65,6 +65,8 @@ type staticOrSharedAttributes struct {
Native_coverage *bool Native_coverage *bool
Apex_available []string
sdkAttributes sdkAttributes
tidyAttributes tidyAttributes
@@ -220,7 +222,7 @@ func bp2BuildPropParseHelper(ctx android.ArchVariantContext, module *Module, pro
} }
// Parses properties common to static and shared libraries. Also used for prebuilt libraries. // 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{} attrs := staticOrSharedAttributes{}
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) { setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
@@ -244,13 +246,16 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo
// empty list -> no values specified // empty list -> no values specified
attrs.System_dynamic_deps.ForceSpecifyEmptyList = true attrs.System_dynamic_deps.ForceSpecifyEmptyList = true
var apexAvailable []string
if isStatic { if isStatic {
apexAvailable = lib.StaticProperties.Static.Apex_available
bp2BuildPropParseHelper(ctx, module, &StaticProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) { bp2BuildPropParseHelper(ctx, module, &StaticProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
if staticOrSharedProps, ok := props.(*StaticProperties); ok { if staticOrSharedProps, ok := props.(*StaticProperties); ok {
setAttrs(axis, config, staticOrSharedProps.Static) setAttrs(axis, config, staticOrSharedProps.Static)
} }
}) })
} else { } else {
apexAvailable = lib.SharedProperties.Shared.Apex_available
bp2BuildPropParseHelper(ctx, module, &SharedProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) { bp2BuildPropParseHelper(ctx, module, &SharedProperties{}, func(axis bazel.ConfigurationAxis, config string, props interface{}) {
if staticOrSharedProps, ok := props.(*SharedProperties); ok { if staticOrSharedProps, ok := props.(*SharedProperties); ok {
setAttrs(axis, config, staticOrSharedProps.Shared) setAttrs(axis, config, staticOrSharedProps.Shared)
@@ -263,6 +268,8 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo
attrs.Srcs_c = partitionedSrcs[cSrcPartition] attrs.Srcs_c = partitionedSrcs[cSrcPartition]
attrs.Srcs_as = partitionedSrcs[asSrcPartition] attrs.Srcs_as = partitionedSrcs[asSrcPartition]
attrs.Apex_available = android.ConvertApexAvailableToTags(apexAvailable)
if !partitionedSrcs[protoSrcPartition].IsEmpty() { if !partitionedSrcs[protoSrcPartition].IsEmpty() {
// TODO(b/208815215): determine whether this is used and add support if necessary // 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") ctx.ModuleErrorf("Migrating static/shared only proto srcs is not currently supported")

View File

@@ -428,8 +428,10 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
if compilerAttrs.stubsSymbolFile == nil && len(compilerAttrs.stubsVersions.Value) == 0 { if compilerAttrs.stubsSymbolFile == nil && len(compilerAttrs.stubsVersions.Value) == 0 {
tagsForStaticVariant = android.ApexAvailableTags(m) tagsForStaticVariant = android.ApexAvailableTags(m)
} }
tagsForStaticVariant.Append(bazel.StringListAttribute{Value: staticAttrs.Apex_available})
tagsForSharedVariant := android.ApexAvailableTags(m) tagsForSharedVariant := android.ApexAvailableTags(m)
tagsForSharedVariant.Append(bazel.StringListAttribute{Value: sharedAttrs.Apex_available})
ctx.CreateBazelTargetModuleWithRestrictions(staticProps, ctx.CreateBazelTargetModuleWithRestrictions(staticProps,
android.CommonAttributes{ android.CommonAttributes{

View File

@@ -22,11 +22,13 @@ import (
// TODO(b/240463568): Additional properties will be added for API validation // TODO(b/240463568): Additional properties will be added for API validation
type bazelSyspropLibraryAttributes struct { type bazelSyspropLibraryAttributes struct {
Srcs bazel.LabelListAttribute Srcs bazel.LabelListAttribute
Tags bazel.StringListAttribute
} }
type bazelCcSyspropLibraryAttributes struct { type bazelCcSyspropLibraryAttributes struct {
Dep bazel.LabelAttribute Dep bazel.LabelAttribute
Min_sdk_version *string Min_sdk_version *string
Tags bazel.StringListAttribute
} }
type SyspropLibraryLabels struct { type SyspropLibraryLabels struct {
@@ -36,6 +38,7 @@ type SyspropLibraryLabels struct {
} }
func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) { func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
apexAvailableTags := android.ApexAvailableTags(ctx.Module())
ctx.CreateBazelTargetModule( ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{ bazel.BazelTargetModuleProperties{
Rule_class: "sysprop_library", Rule_class: "sysprop_library",
@@ -44,11 +47,14 @@ func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLa
android.CommonAttributes{Name: labels.SyspropLibraryLabel}, android.CommonAttributes{Name: labels.SyspropLibraryLabel},
&bazelSyspropLibraryAttributes{ &bazelSyspropLibraryAttributes{
Srcs: srcs, Srcs: srcs,
}) Tags: apexAvailableTags,
},
)
attrs := &bazelCcSyspropLibraryAttributes{ attrs := &bazelCcSyspropLibraryAttributes{
Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel), Dep: *bazel.MakeLabelAttribute(":" + labels.SyspropLibraryLabel),
Min_sdk_version: minSdkVersion, Min_sdk_version: minSdkVersion,
Tags: apexAvailableTags,
} }
if labels.SharedLibraryLabel != "" { if labels.SharedLibraryLabel != "" {