From aceec25d3f27f2f871965bbc30098ec96da80eb3 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Fri, 24 Mar 2023 09:46:36 -0400 Subject: [PATCH 1/2] Add apex_available for static/shared only props Test: b build com.android.neuralnetworks com.android.media.swcodec Change-Id: I492c61d60d29a7a441d709ac4315a5ed2288960d --- cc/bp2build.go | 9 ++++++++- cc/library.go | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cc/bp2build.go b/cc/bp2build.go index 03d9de85c..6951fc3a4 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -65,6 +65,8 @@ type staticOrSharedAttributes struct { Native_coverage *bool + Apex_available []string + sdkAttributes 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. -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 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo // 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 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo 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 1b579cd6e..31b76cdf8 100644 --- a/cc/library.go +++ b/cc/library.go @@ -428,8 +428,10 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) { 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{ From 10e5a0e987f56ab2dfcf754995df470317759615 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Thu, 23 Mar 2023 11:51:22 -0400 Subject: [PATCH 2/2] Add apex_available tags for sysprop modules Test: b build com.android.mediaswcodec Change-Id: Ic780573d6992a0471989d6c4887960a3c42e1bef --- cc/sysprop.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cc/sysprop.go b/cc/sysprop.go index 2b1e354d3..0df290afa 100644 --- a/cc/sysprop.go +++ b/cc/sysprop.go @@ -22,11 +22,13 @@ import ( // 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 @@ type SyspropLibraryLabels struct { } 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 @@ func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLa 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 != "" {