From f11b7c30938256142371562eb8b25d34e3d3b41f Mon Sep 17 00:00:00 2001 From: Yu Liu Date: Fri, 20 Oct 2023 19:15:51 +0000 Subject: [PATCH] Support a few more attrs in cc_aconfig_library. More might be added later when we have an allowlist. Bug: 305998969 Test: b build with the change in ag/25094394 Change-Id: I92df843ac81f4e33ce7506db61c989a380015975 --- aconfig/cc_aconfig_library.go | 12 ++++++++++-- cc/binary.go | 4 ++-- cc/bp2build.go | 12 ++++++------ cc/cc.go | 4 ++-- cc/library.go | 8 ++++---- cc/library_headers.go | 4 ++-- cc/object.go | 4 ++-- 7 files changed, 28 insertions(+), 20 deletions(-) diff --git a/aconfig/cc_aconfig_library.go b/aconfig/cc_aconfig_library.go index 0583befc0..5b0fb4a82 100644 --- a/aconfig/cc_aconfig_library.go +++ b/aconfig/cc_aconfig_library.go @@ -143,6 +143,7 @@ func (this *CcAconfigLibraryCallbacks) GeneratorBuildActions(ctx cc.ModuleContex } type bazelCcAconfigLibraryAttributes struct { + cc.SdkAttributes Aconfig_declarations bazel.LabelAttribute Dynamic_deps bazel.LabelListAttribute } @@ -154,12 +155,13 @@ type bazelCcAconfigLibraryAttributes struct { // module type returns a cc library and the bp2build conversion is called on the // cc library type. -func (this *CcAconfigLibraryCallbacks) GeneratorBp2build(ctx android.Bp2buildMutatorContext) bool { +func (this *CcAconfigLibraryCallbacks) GeneratorBp2build(ctx android.Bp2buildMutatorContext, module *cc.Module) bool { if ctx.ModuleType() != "cc_aconfig_library" { return false } attrs := bazelCcAconfigLibraryAttributes{ + SdkAttributes: cc.Bp2BuildParseSdkAttributes(module), Aconfig_declarations: *bazel.MakeLabelAttribute(android.BazelLabelForModuleDepSingle(ctx, this.properties.Aconfig_declarations).Label), Dynamic_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, []string{baseLibDep})), } @@ -168,6 +170,12 @@ func (this *CcAconfigLibraryCallbacks) GeneratorBp2build(ctx android.Bp2buildMut Bzl_load_location: "//build/bazel/rules/cc:cc_aconfig_library.bzl", } - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: ctx.ModuleName()}, &attrs) + ctx.CreateBazelTargetModule( + props, + android.CommonAttributes{ + Name: ctx.ModuleName(), + Tags: android.ApexAvailableTagsWithoutTestApexes(ctx, module), + }, + &attrs) return true } diff --git a/cc/binary.go b/cc/binary.go index 0722f8110..0f0560569 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -651,7 +651,7 @@ func binaryBp2buildAttrs(ctx android.Bp2buildMutatorContext, m *Module) binaryAt Features: baseAttrs.features, - sdkAttributes: bp2BuildParseSdkAttributes(m), + SdkAttributes: Bp2BuildParseSdkAttributes(m), Native_coverage: baseAttrs.Native_coverage, } @@ -708,7 +708,7 @@ type binaryAttributes struct { Features bazel.StringListAttribute - sdkAttributes + SdkAttributes tidyAttributes diff --git a/cc/bp2build.go b/cc/bp2build.go index 7ae8d8981..919b4d446 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -85,7 +85,7 @@ type staticOrSharedAttributes struct { Features bazel.StringListAttribute - sdkAttributes + SdkAttributes tidyAttributes } @@ -1185,7 +1185,7 @@ func bp2buildCcAidlLibrary( implementationDynamicDeps := linkerAttrs.dynamicDeps.Clone() implementationDynamicDeps.Append(linkerAttrs.implementationDynamicDeps) - sdkAttrs := bp2BuildParseSdkAttributes(m) + sdkAttrs := Bp2BuildParseSdkAttributes(m) exportedIncludes := bp2BuildParseExportedIncludes(ctx, m, &compilerAttrs.includes) includeAttrs := includesAttributes{ @@ -1207,7 +1207,7 @@ func bp2buildCcAidlLibrary( Implementation_deps: *implementationDeps, Implementation_dynamic_deps: *implementationDynamicDeps, Tags: apexAvailableTags, - sdkAttributes: sdkAttrs, + SdkAttributes: sdkAttrs, includesAttributes: includeAttrs, }, ) @@ -1222,14 +1222,14 @@ func bp2buildCcAidlLibrary( return nil } -func bp2BuildParseSdkAttributes(module *Module) sdkAttributes { - return sdkAttributes{ +func Bp2BuildParseSdkAttributes(module *Module) SdkAttributes { + return SdkAttributes{ Sdk_version: module.Properties.Sdk_version, Min_sdk_version: module.Properties.Min_sdk_version, } } -type sdkAttributes struct { +type SdkAttributes struct { Sdk_version *string Min_sdk_version *string } diff --git a/cc/cc.go b/cc/cc.go index 8c248f934..814a66cda 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -589,7 +589,7 @@ type Generator interface { GeneratorFlags(ctx ModuleContext, flags Flags, deps PathDeps) Flags GeneratorSources(ctx ModuleContext) GeneratedSource GeneratorBuildActions(ctx ModuleContext, flags Flags, deps PathDeps) - GeneratorBp2build(ctx android.Bp2buildMutatorContext) bool + GeneratorBp2build(ctx android.Bp2buildMutatorContext, module *Module) bool } // compiler is the interface for a compiler helper object. Different module decorators may implement @@ -4218,7 +4218,7 @@ func (c *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if len(c.generators) > 0 { allConverted := true for _, generator := range c.generators { - allConverted = allConverted && generator.GeneratorBp2build(ctx) + allConverted = allConverted && generator.GeneratorBp2build(ctx, c) } if allConverted { return diff --git a/cc/library.go b/cc/library.go index 21615121d..b7688f716 100644 --- a/cc/library.go +++ b/cc/library.go @@ -286,7 +286,7 @@ type ccAidlLibraryAttributes struct { Implementation_dynamic_deps bazel.LabelListAttribute Tags bazel.StringListAttribute - sdkAttributes + SdkAttributes includesAttributes } @@ -347,7 +347,7 @@ func libraryBp2Build(ctx android.Bp2buildMutatorContext, m *Module) { Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(staticAttrs.Whole_archive_deps), System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(staticAttrs.System_dynamic_deps), Runtime_deps: linkerAttrs.runtimeDeps, - sdkAttributes: bp2BuildParseSdkAttributes(m), + SdkAttributes: Bp2BuildParseSdkAttributes(m), Native_coverage: baseAttributes.Native_coverage, Additional_compiler_inputs: compilerAttrs.additionalCompilerInputs, } @@ -375,7 +375,7 @@ func libraryBp2Build(ctx android.Bp2buildMutatorContext, m *Module) { Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps, System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(sharedAttrs.System_dynamic_deps), Runtime_deps: linkerAttrs.runtimeDeps, - sdkAttributes: bp2BuildParseSdkAttributes(m), + SdkAttributes: Bp2BuildParseSdkAttributes(m), Native_coverage: baseAttributes.Native_coverage, Additional_compiler_inputs: compilerAttrs.additionalCompilerInputs, } @@ -2861,7 +2861,7 @@ func sharedOrStaticLibraryBp2Build(ctx android.Bp2buildMutatorContext, module *M Whole_archive_deps: linkerAttrs.wholeArchiveDeps, Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps, System_dynamic_deps: linkerAttrs.systemDynamicDeps, - sdkAttributes: bp2BuildParseSdkAttributes(module), + SdkAttributes: Bp2BuildParseSdkAttributes(module), Runtime_deps: linkerAttrs.runtimeDeps, Native_coverage: baseAttributes.Native_coverage, Additional_compiler_inputs: compilerAttrs.additionalCompilerInputs, diff --git a/cc/library_headers.go b/cc/library_headers.go index 3f8be467b..2e5a19516 100644 --- a/cc/library_headers.go +++ b/cc/library_headers.go @@ -122,7 +122,7 @@ type bazelCcLibraryHeadersAttributes struct { Export_absolute_includes bazel.StringListAttribute Export_system_includes bazel.StringListAttribute Deps bazel.LabelListAttribute - sdkAttributes + SdkAttributes } func libraryHeadersBp2Build(ctx android.Bp2buildMutatorContext, module *Module) { @@ -138,7 +138,7 @@ func libraryHeadersBp2Build(ctx android.Bp2buildMutatorContext, module *Module) Export_system_includes: exportedIncludes.SystemIncludes, Deps: linkerAttrs.deps, Hdrs: baseAttributes.hdrs, - sdkAttributes: bp2BuildParseSdkAttributes(module), + SdkAttributes: Bp2BuildParseSdkAttributes(module), } props := bazel.BazelTargetModuleProperties{ diff --git a/cc/object.go b/cc/object.go index a3000e06e..d6eb369a5 100644 --- a/cc/object.go +++ b/cc/object.go @@ -151,7 +151,7 @@ type bazelObjectAttributes struct { Stl *string Linker_script bazel.LabelAttribute Crt *bool - sdkAttributes + SdkAttributes } // objectBp2Build is the bp2build converter from cc_object modules to the @@ -218,7 +218,7 @@ func objectBp2Build(ctx android.Bp2buildMutatorContext, m *Module) { Stl: compilerAttrs.stl, Linker_script: linkerScript, Crt: m.linker.(*objectLinker).Properties.Crt, - sdkAttributes: bp2BuildParseSdkAttributes(m), + SdkAttributes: Bp2BuildParseSdkAttributes(m), } props := bazel.BazelTargetModuleProperties{