Merge "Have ConvertWBp2build use Bp2buildMutatorContext" into main

This commit is contained in:
Christopher Parsons 2023-09-20 17:56:24 +00:00 committed by Gerrit Code Review
commit c331812a59
49 changed files with 132 additions and 129 deletions

View file

@ -168,7 +168,7 @@ type bazelAconfigDeclarationsAttributes struct {
Package string Package string
} }
func (module *DeclarationsModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (module *DeclarationsModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() != "aconfig_declarations" { if ctx.ModuleType() != "aconfig_declarations" {
return return
} }

View file

@ -96,7 +96,7 @@ type bazelAconfigValueSetAttributes struct {
Values bazel.LabelListAttribute Values bazel.LabelListAttribute
} }
func (module *ValueSetModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (module *ValueSetModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() != "aconfig_value_set" { if ctx.ModuleType() != "aconfig_value_set" {
return return
} }

View file

@ -75,7 +75,7 @@ type bazelAconfigValuesAttributes struct {
Package string Package string
} }
func (module *ValuesModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (module *ValuesModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() != "aconfig_values" { if ctx.ModuleType() != "aconfig_values" {
return return
} }

View file

@ -64,7 +64,7 @@ type bazelAidlLibraryAttributes struct {
Deps bazel.LabelListAttribute Deps bazel.LabelListAttribute
} }
func (lib *AidlLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (lib *AidlLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
srcs := bazel.MakeLabelListAttribute( srcs := bazel.MakeLabelListAttribute(
android.BazelLabelForModuleSrc( android.BazelLabelForModuleSrc(
ctx, ctx,

View file

@ -162,7 +162,7 @@ type Bazelable interface {
// Modules must implement this function to be bp2build convertible. The function // Modules must implement this function to be bp2build convertible. The function
// must either create at least one Bazel target module (using ctx.CreateBazelTargetModule or // must either create at least one Bazel target module (using ctx.CreateBazelTargetModule or
// its related functions), or declare itself unconvertible using ctx.MarkBp2buildUnconvertible. // its related functions), or declare itself unconvertible using ctx.MarkBp2buildUnconvertible.
ConvertWithBp2build(ctx TopDownMutatorContext) ConvertWithBp2build(ctx Bp2buildMutatorContext)
// namespacedVariableProps is a map from a soong config variable namespace // namespacedVariableProps is a map from a soong config variable namespace
// (e.g. acme, android) to a map of interfaces{}, which are really // (e.g. acme, android) to a map of interfaces{}, which are really

View file

@ -585,7 +585,7 @@ func PathsForBazelOut(ctx PathContext, paths []string) Paths {
// For the first two cases, they are defined using the label attribute. For the third case, // For the first two cases, they are defined using the label attribute. For the third case,
// it's defined with the string attribute. // it's defined with the string attribute.
func BazelStringOrLabelFromProp( func BazelStringOrLabelFromProp(
ctx TopDownMutatorContext, ctx Bp2buildMutatorContext,
propToDistinguish *string) (bazel.LabelAttribute, bazel.StringAttribute) { propToDistinguish *string) (bazel.LabelAttribute, bazel.StringAttribute) {
var labelAttr bazel.LabelAttribute var labelAttr bazel.LabelAttribute

View file

@ -469,7 +469,7 @@ func mixedBuildModuleFactory() Module {
return m return m
} }
func (m *mixedBuildModule) ConvertWithBp2build(ctx TopDownMutatorContext) { func (m *mixedBuildModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
} }
func (m *mixedBuildModule) DepsMutator(ctx BottomUpMutatorContext) { func (m *mixedBuildModule) DepsMutator(ctx BottomUpMutatorContext) {

View file

@ -180,7 +180,7 @@ func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {}
// ConvertWithBp2build to fulfill Bazelable interface; however, at this time defaults module are // ConvertWithBp2build to fulfill Bazelable interface; however, at this time defaults module are
// *NOT* converted with bp2build // *NOT* converted with bp2build
func (defaultable *DefaultsModuleBase) ConvertWithBp2build(ctx TopDownMutatorContext) { func (defaultable *DefaultsModuleBase) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
// Defaults types are never convertible. // Defaults types are never convertible.
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "") ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "")
} }

View file

@ -93,7 +93,7 @@ func (fg *fileGroup) ConvertWithApiBp2build(ctx TopDownMutatorContext) {
} }
// ConvertWithBp2build performs bp2build conversion of filegroup // ConvertWithBp2build performs bp2build conversion of filegroup
func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) { func (fg *fileGroup) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
srcs := bazel.MakeLabelListAttribute( srcs := bazel.MakeLabelListAttribute(
BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs)) BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs))
@ -209,10 +209,10 @@ func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) {
} }
type FileGroupPath interface { type FileGroupPath interface {
GetPath(ctx TopDownMutatorContext) string GetPath(ctx Bp2buildMutatorContext) string
} }
func (fg *fileGroup) GetPath(ctx TopDownMutatorContext) string { func (fg *fileGroup) GetPath(ctx Bp2buildMutatorContext) string {
if fg.properties.Path != nil { if fg.properties.Path != nil {
return *fg.properties.Path return *fg.properties.Path
} }

View file

@ -71,7 +71,7 @@ type bazelLicenseAttributes struct {
Visibility []string Visibility []string
} }
func (m *licenseModule) ConvertWithBp2build(ctx TopDownMutatorContext) { func (m *licenseModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
attrs := &bazelLicenseAttributes{ attrs := &bazelLicenseAttributes{
License_kinds: m.properties.License_kinds, License_kinds: m.properties.License_kinds,
Copyright_notice: m.properties.Copyright_notice, Copyright_notice: m.properties.Copyright_notice,

View file

@ -50,7 +50,7 @@ type bazelLicenseKindAttributes struct {
Visibility []string Visibility []string
} }
func (m *licenseKindModule) ConvertWithBp2build(ctx TopDownMutatorContext) { func (m *licenseKindModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
attrs := &bazelLicenseKindAttributes{ attrs := &bazelLicenseKindAttributes{
Conditions: m.properties.Conditions, Conditions: m.properties.Conditions,
Url: m.properties.Url, Url: m.properties.Url,

View file

@ -15,9 +15,10 @@
package android package android
import ( import (
"path/filepath"
"android/soong/bazel" "android/soong/bazel"
"android/soong/ui/metrics/bp2build_metrics_proto" "android/soong/ui/metrics/bp2build_metrics_proto"
"path/filepath"
"github.com/google/blueprint" "github.com/google/blueprint"
) )
@ -229,37 +230,8 @@ var bp2buildPreArchMutators = []RegisterMutatorFunc{}
// A minimal context for Bp2build conversion // A minimal context for Bp2build conversion
type Bp2buildMutatorContext interface { type Bp2buildMutatorContext interface {
BazelConversionPathContext BazelConversionPathContext
CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
CreateBazelTargetModuleWithRestrictions(bazel.BazelTargetModuleProperties, CommonAttributes, interface{}, bazel.BoolAttribute)
}
// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
// into Bazel BUILD targets that should run prior to deps and conversion.
func PreArchBp2BuildMutators(f RegisterMutatorFunc) {
bp2buildPreArchMutators = append(bp2buildPreArchMutators, f)
}
type BaseMutatorContext interface {
BaseModuleContext
// MutatorName returns the name that this mutator was registered with.
MutatorName() string
// Rename all variants of a module. The new name is not visible to calls to ModuleName,
// AddDependency or OtherModuleName until after this mutator pass is complete.
Rename(name string)
}
type TopDownMutator func(TopDownMutatorContext)
type TopDownMutatorContext interface {
BaseMutatorContext BaseMutatorContext
// CreateModule creates a new module by calling the factory method for the specified moduleType, and applies
// the specified property structs to it as if the properties were set in a blueprint file.
CreateModule(ModuleFactory, ...interface{}) Module
// CreateBazelTargetModule creates a BazelTargetModule by calling the // CreateBazelTargetModule creates a BazelTargetModule by calling the
// factory method, just like in CreateModule, but also requires // factory method, just like in CreateModule, but also requires
// BazelTargetModuleProperties containing additional metadata for the // BazelTargetModuleProperties containing additional metadata for the
@ -290,6 +262,34 @@ type TopDownMutatorContext interface {
CreateBazelConfigSetting(csa bazel.ConfigSettingAttributes, ca CommonAttributes, dir string) CreateBazelConfigSetting(csa bazel.ConfigSettingAttributes, ca CommonAttributes, dir string)
} }
// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
// into Bazel BUILD targets that should run prior to deps and conversion.
func PreArchBp2BuildMutators(f RegisterMutatorFunc) {
bp2buildPreArchMutators = append(bp2buildPreArchMutators, f)
}
type BaseMutatorContext interface {
BaseModuleContext
// MutatorName returns the name that this mutator was registered with.
MutatorName() string
// Rename all variants of a module. The new name is not visible to calls to ModuleName,
// AddDependency or OtherModuleName until after this mutator pass is complete.
Rename(name string)
}
type TopDownMutator func(TopDownMutatorContext)
type TopDownMutatorContext interface {
BaseMutatorContext
Bp2buildMutatorContext
// CreateModule creates a new module by calling the factory method for the specified moduleType, and applies
// the specified property structs to it as if the properties were set in a blueprint file.
CreateModule(ModuleFactory, ...interface{}) Module
}
type topDownMutatorContext struct { type topDownMutatorContext struct {
bp blueprint.TopDownMutatorContext bp blueprint.TopDownMutatorContext
baseModuleContext baseModuleContext

View file

@ -54,7 +54,7 @@ type packageModule struct {
var _ Bazelable = &packageModule{} var _ Bazelable = &packageModule{}
func (p *packageModule) ConvertWithBp2build(ctx TopDownMutatorContext) { func (p *packageModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
defaultPackageMetadata := bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, p.properties.Default_applicable_licenses)) defaultPackageMetadata := bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, p.properties.Default_applicable_licenses))
// If METADATA file exists in the package, add it to package(default_package_metadata=) using a // If METADATA file exists in the package, add it to package(default_package_metadata=) using a
// filegroup(name="default_metadata_file") which can be accessed later on each module in Bazel // filegroup(name="default_metadata_file") which can be accessed later on each module in Bazel

View file

@ -2623,7 +2623,7 @@ func OverrideApexFactory() android.Module {
return m return m
} }
func (o *OverrideApex) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (o *OverrideApex) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() != "override_apex" { if ctx.ModuleType() != "override_apex" {
return return
} }
@ -3261,7 +3261,7 @@ const (
) )
// ConvertWithBp2build performs bp2build conversion of an apex // ConvertWithBp2build performs bp2build conversion of an apex
func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (a *apexBundle) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
// We only convert apex and apex_test modules at this time // We only convert apex and apex_test modules at this time
if ctx.ModuleType() != "apex" && ctx.ModuleType() != "apex_test" { if ctx.ModuleType() != "apex" && ctx.ModuleType() != "apex_test" {
return return
@ -3272,7 +3272,7 @@ func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
ctx.CreateBazelTargetModule(props, commonAttrs, &attrs) ctx.CreateBazelTargetModule(props, commonAttrs, &attrs)
} }
func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (bazelApexBundleAttributes, bazel.BazelTargetModuleProperties, android.CommonAttributes) { func convertWithBp2build(a *apexBundle, ctx android.Bp2buildMutatorContext) (bazelApexBundleAttributes, bazel.BazelTargetModuleProperties, android.CommonAttributes) {
var manifestLabelAttribute bazel.LabelAttribute var manifestLabelAttribute bazel.LabelAttribute
manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))) manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json")))
@ -3432,7 +3432,7 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze
// both, 32/32, 64/none, 32&64/32, 64/32 // both, 32/32, 64/none, 32&64/32, 64/32
// first, 32/32, 64/none, 64/32, 64/32 // first, 32/32, 64/none, 64/32, 64/32
func convert32Libs(ctx android.TopDownMutatorContext, compileMultilb string, func convert32Libs(ctx android.Bp2buildMutatorContext, compileMultilb string,
libs []string, nativeSharedLibs *convertedNativeSharedLibs) { libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
switch compileMultilb { switch compileMultilb {
@ -3447,7 +3447,7 @@ func convert32Libs(ctx android.TopDownMutatorContext, compileMultilb string,
} }
} }
func convert64Libs(ctx android.TopDownMutatorContext, compileMultilb string, func convert64Libs(ctx android.Bp2buildMutatorContext, compileMultilb string,
libs []string, nativeSharedLibs *convertedNativeSharedLibs) { libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
switch compileMultilb { switch compileMultilb {
@ -3460,7 +3460,7 @@ func convert64Libs(ctx android.TopDownMutatorContext, compileMultilb string,
} }
} }
func convertBothLibs(ctx android.TopDownMutatorContext, compileMultilb string, func convertBothLibs(ctx android.Bp2buildMutatorContext, compileMultilb string,
libs []string, nativeSharedLibs *convertedNativeSharedLibs) { libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
switch compileMultilb { switch compileMultilb {
@ -3478,7 +3478,7 @@ func convertBothLibs(ctx android.TopDownMutatorContext, compileMultilb string,
} }
} }
func convertFirstLibs(ctx android.TopDownMutatorContext, compileMultilb string, func convertFirstLibs(ctx android.Bp2buildMutatorContext, compileMultilb string,
libs []string, nativeSharedLibs *convertedNativeSharedLibs) { libs []string, nativeSharedLibs *convertedNativeSharedLibs) {
libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) libsLabelList := android.BazelLabelForModuleDeps(ctx, libs)
switch compileMultilb { switch compileMultilb {
@ -3521,7 +3521,7 @@ func makeSharedLibsAttributes(config string, libsLabelList bazel.LabelList,
labelListAttr.Append(list) labelListAttr.Append(list)
} }
func invalidCompileMultilib(ctx android.TopDownMutatorContext, value string) { func invalidCompileMultilib(ctx android.Bp2buildMutatorContext, value string) {
ctx.PropertyErrorf("compile_multilib", "Invalid value: %s", value) ctx.PropertyErrorf("compile_multilib", "Invalid value: %s", value)
} }

View file

@ -208,11 +208,11 @@ type bazelApexKeyAttributes struct {
} }
// ConvertWithBp2build performs conversion apexKey for bp2build // ConvertWithBp2build performs conversion apexKey for bp2build
func (m *apexKey) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *apexKey) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
apexKeyBp2BuildInternal(ctx, m) apexKeyBp2BuildInternal(ctx, m)
} }
func apexKeyBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexKey) { func apexKeyBp2BuildInternal(ctx android.Bp2buildMutatorContext, module *apexKey) {
privateKeyLabelAttribute, privateKeyNameAttribute := privateKeyLabelAttribute, privateKeyNameAttribute :=
android.BazelStringOrLabelFromProp(ctx, module.properties.Private_key) android.BazelStringOrLabelFromProp(ctx, module.properties.Private_key)

View file

@ -497,7 +497,7 @@ func (m *customModule) dir() *string {
return m.props.Dir return m.props.Dir
} }
func (m *customModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *customModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if p := m.props.One_to_many_prop; p != nil && *p { if p := m.props.One_to_many_prop; p != nil && *p {
customBp2buildOneToMany(ctx, m) customBp2buildOneToMany(ctx, m)
return return
@ -555,7 +555,7 @@ func (m *customModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
} }
func (m *customModule) createConfigSetting(ctx android.TopDownMutatorContext) { func (m *customModule) createConfigSetting(ctx android.Bp2buildMutatorContext) {
csa := bazel.ConfigSettingAttributes{ csa := bazel.ConfigSettingAttributes{
Flag_values: bazel.StringMapAttribute{ Flag_values: bazel.StringMapAttribute{
"//build/bazel/rules/my_string_setting": m.Name(), "//build/bazel/rules/my_string_setting": m.Name(),
@ -590,7 +590,7 @@ func (c *customModule) ConvertWithApiBp2build(ctx android.TopDownMutatorContext)
// A bp2build mutator that uses load statements and creates a 1:M mapping from // A bp2build mutator that uses load statements and creates a 1:M mapping from
// module to target. // module to target.
func customBp2buildOneToMany(ctx android.TopDownMutatorContext, m *customModule) { func customBp2buildOneToMany(ctx android.Bp2buildMutatorContext, m *customModule) {
baseName := m.Name() baseName := m.Name()
attrs := &customBazelModuleAttributes{} attrs := &customBazelModuleAttributes{}

View file

@ -313,7 +313,7 @@ type bazelBpfAttributes struct {
} }
// bpf bp2build converter // bpf bp2build converter
func (b *bpf) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (b *bpf) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() != "bpf" { if ctx.ModuleType() != "bpf" {
return return
} }

View file

@ -599,7 +599,7 @@ func (handler *ccBinaryBazelHandler) ProcessBazelQueryResponse(ctx android.Modul
handler.module.setAndroidMkVariablesFromCquery(info.CcAndroidMkInfo) handler.module.setAndroidMkVariablesFromCquery(info.CcAndroidMkInfo)
} }
func binaryBp2buildAttrs(ctx android.TopDownMutatorContext, m *Module) binaryAttributes { func binaryBp2buildAttrs(ctx android.Bp2buildMutatorContext, m *Module) binaryAttributes {
baseAttrs := bp2BuildParseBaseProps(ctx, m) baseAttrs := bp2BuildParseBaseProps(ctx, m)
binaryLinkerAttrs := bp2buildBinaryLinkerProps(ctx, m) binaryLinkerAttrs := bp2buildBinaryLinkerProps(ctx, m)
@ -661,7 +661,7 @@ func binaryBp2buildAttrs(ctx android.TopDownMutatorContext, m *Module) binaryAtt
return attrs return attrs
} }
func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) { func binaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
// shared with cc_test // shared with cc_test
binaryAttrs := binaryBp2buildAttrs(ctx, m) binaryAttrs := binaryBp2buildAttrs(ctx, m)

View file

@ -4214,7 +4214,7 @@ func (c *Module) typ() moduleType {
} }
// ConvertWithBp2build converts Module to Bazel for bp2build. // ConvertWithBp2build converts Module to Bazel for bp2build.
func (c *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (c *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
prebuilt := c.IsPrebuilt() prebuilt := c.IsPrebuilt()
switch c.typ() { switch c.typ() {
case binary: case binary:

View file

@ -45,7 +45,7 @@ type bazelFdoProfileAttributes struct {
Profile bazel.StringAttribute Profile bazel.StringAttribute
} }
func (fp *fdoProfile) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (fp *fdoProfile) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
var profileAttr bazel.StringAttribute var profileAttr bazel.StringAttribute
archVariantProps := fp.GetArchVariantProperties(ctx, &fdoProfileProperties{}) archVariantProps := fp.GetArchVariantProperties(ctx, &fdoProfileProperties{})

View file

@ -308,7 +308,7 @@ func stripAttrsFromLinkerAttrs(la *linkerAttributes) stripAttributes {
} }
} }
func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) { func libraryBp2Build(ctx android.Bp2buildMutatorContext, m *Module) {
sharedAttrs := bp2BuildParseSharedProps(ctx, m) sharedAttrs := bp2BuildParseSharedProps(ctx, m)
staticAttrs := bp2BuildParseStaticProps(ctx, m) staticAttrs := bp2BuildParseStaticProps(ctx, m)
baseAttributes := bp2BuildParseBaseProps(ctx, m) baseAttributes := bp2BuildParseBaseProps(ctx, m)
@ -480,7 +480,7 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
createStubsBazelTargetIfNeeded(ctx, m, compilerAttrs, exportedIncludes, baseAttributes) createStubsBazelTargetIfNeeded(ctx, m, compilerAttrs, exportedIncludes, baseAttributes)
} }
func createStubsBazelTargetIfNeeded(ctx android.TopDownMutatorContext, m *Module, compilerAttrs compilerAttributes, exportedIncludes BazelIncludes, baseAttributes baseAttributes) { func createStubsBazelTargetIfNeeded(ctx android.Bp2buildMutatorContext, m *Module, compilerAttrs compilerAttributes, exportedIncludes BazelIncludes, baseAttributes baseAttributes) {
if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 { if compilerAttrs.stubsSymbolFile != nil && len(compilerAttrs.stubsVersions.Value) > 0 {
stubSuitesProps := bazel.BazelTargetModuleProperties{ stubSuitesProps := bazel.BazelTargetModuleProperties{
Rule_class: "cc_stub_suite", Rule_class: "cc_stub_suite",
@ -2886,7 +2886,7 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu
return outputFile return outputFile
} }
func bp2buildParseAbiCheckerProps(ctx android.TopDownMutatorContext, module *Module) bazelCcHeaderAbiCheckerAttributes { func bp2buildParseAbiCheckerProps(ctx android.Bp2buildMutatorContext, module *Module) bazelCcHeaderAbiCheckerAttributes {
lib, ok := module.linker.(*libraryDecorator) lib, ok := module.linker.(*libraryDecorator)
if !ok { if !ok {
return bazelCcHeaderAbiCheckerAttributes{} return bazelCcHeaderAbiCheckerAttributes{}
@ -2909,7 +2909,7 @@ func bp2buildParseAbiCheckerProps(ctx android.TopDownMutatorContext, module *Mod
return abiCheckerAttrs return abiCheckerAttrs
} }
func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module, isStatic bool) { func sharedOrStaticLibraryBp2Build(ctx android.Bp2buildMutatorContext, module *Module, isStatic bool) {
baseAttributes := bp2BuildParseBaseProps(ctx, module) baseAttributes := bp2BuildParseBaseProps(ctx, module)
compilerAttrs := baseAttributes.compilerAttributes compilerAttrs := baseAttributes.compilerAttributes
linkerAttrs := baseAttributes.linkerAttributes linkerAttrs := baseAttributes.linkerAttributes

View file

@ -129,7 +129,7 @@ type bazelCcLibraryHeadersAttributes struct {
sdkAttributes sdkAttributes
} }
func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) { func libraryHeadersBp2Build(ctx android.Bp2buildMutatorContext, module *Module) {
baseAttributes := bp2BuildParseBaseProps(ctx, module) baseAttributes := bp2BuildParseBaseProps(ctx, module)
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, &baseAttributes.includes) exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, &baseAttributes.includes)
linkerAttrs := baseAttributes.linkerAttributes linkerAttrs := baseAttributes.linkerAttributes

View file

@ -584,7 +584,7 @@ func apiHeaderLabels(ctx android.TopDownMutatorContext, hdrLibs []string) bazel.
return android.BazelLabelForModuleDepsWithFn(ctx, hdrLibs, addSuffix) return android.BazelLabelForModuleDepsWithFn(ctx, hdrLibs, addSuffix)
} }
func ndkLibraryBp2build(ctx android.TopDownMutatorContext, c *Module) { func ndkLibraryBp2build(ctx android.Bp2buildMutatorContext, c *Module) {
ndk, _ := c.linker.(*stubDecorator) ndk, _ := c.linker.(*stubDecorator)
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "cc_stub_suite", Rule_class: "cc_stub_suite",

View file

@ -148,7 +148,7 @@ var (
// stlSrcBp2build returns a bazel label for the checked-in .so/.a file // stlSrcBp2build returns a bazel label for the checked-in .so/.a file
// It contains a select statement for each ABI // It contains a select statement for each ABI
func stlSrcBp2build(ctx android.TopDownMutatorContext, c *Module) bazel.LabelAttribute { func stlSrcBp2build(ctx android.Bp2buildMutatorContext, c *Module) bazel.LabelAttribute {
libName := strings.TrimPrefix(c.Name(), "ndk_") libName := strings.TrimPrefix(c.Name(), "ndk_")
libExt := ".so" // TODO - b/201079053: Support windows libExt := ".so" // TODO - b/201079053: Support windows
if ctx.ModuleType() == "ndk_prebuilt_static_stl" { if ctx.ModuleType() == "ndk_prebuilt_static_stl" {
@ -180,7 +180,7 @@ func stlIncludesBp2build(c *Module) bazel.StringListAttribute {
return bazel.MakeStringListAttribute(android.FirstUniqueStrings(includeDirs)) return bazel.MakeStringListAttribute(android.FirstUniqueStrings(includeDirs))
} }
func ndkPrebuiltStlBp2build(ctx android.TopDownMutatorContext, c *Module) { func ndkPrebuiltStlBp2build(ctx android.Bp2buildMutatorContext, c *Module) {
if ctx.ModuleType() == "ndk_prebuilt_static_stl" { if ctx.ModuleType() == "ndk_prebuilt_static_stl" {
ndkPrebuiltStaticStlBp2build(ctx, c) ndkPrebuiltStaticStlBp2build(ctx, c)
} else { } else {
@ -188,7 +188,7 @@ func ndkPrebuiltStlBp2build(ctx android.TopDownMutatorContext, c *Module) {
} }
} }
func ndkPrebuiltStaticStlBp2build(ctx android.TopDownMutatorContext, c *Module) { func ndkPrebuiltStaticStlBp2build(ctx android.Bp2buildMutatorContext, c *Module) {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "cc_prebuilt_library_static", Rule_class: "cc_prebuilt_library_static",
Bzl_load_location: "//build/bazel/rules/cc:cc_prebuilt_library_static.bzl", Bzl_load_location: "//build/bazel/rules/cc:cc_prebuilt_library_static.bzl",
@ -201,7 +201,7 @@ func ndkPrebuiltStaticStlBp2build(ctx android.TopDownMutatorContext, c *Module)
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: c.Name()}, attrs) ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: c.Name()}, attrs)
} }
func ndkPrebuiltSharedStlBp2build(ctx android.TopDownMutatorContext, c *Module) { func ndkPrebuiltSharedStlBp2build(ctx android.Bp2buildMutatorContext, c *Module) {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "cc_prebuilt_library_shared", Rule_class: "cc_prebuilt_library_shared",
Bzl_load_location: "//build/bazel/rules/cc:cc_prebuilt_library_shared.bzl", Bzl_load_location: "//build/bazel/rules/cc:cc_prebuilt_library_shared.bzl",

View file

@ -156,7 +156,7 @@ type bazelObjectAttributes struct {
// objectBp2Build is the bp2build converter from cc_object modules to the // objectBp2Build is the bp2build converter from cc_object modules to the
// Bazel equivalent target, plus any necessary include deps for the cc_object. // Bazel equivalent target, plus any necessary include deps for the cc_object.
func objectBp2Build(ctx android.TopDownMutatorContext, m *Module) { func objectBp2Build(ctx android.Bp2buildMutatorContext, m *Module) {
if m.compiler == nil { if m.compiler == nil {
// a cc_object must have access to the compiler decorator for its props. // a cc_object must have access to the compiler decorator for its props.
ctx.ModuleErrorf("compiler must not be nil for a cc_object module") ctx.ModuleErrorf("compiler must not be nil for a cc_object module")

View file

@ -363,12 +363,12 @@ type bazelPrebuiltLibraryStaticAttributes struct {
// all variants // all variants
// //
// In all cases, cc_prebuilt_library_static target names will be appended with "_bp2build_cc_library_static". // In all cases, cc_prebuilt_library_static target names will be appended with "_bp2build_cc_library_static".
func prebuiltLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module) { func prebuiltLibraryBp2Build(ctx android.Bp2buildMutatorContext, module *Module) {
prebuiltLibraryStaticBp2Build(ctx, module, true) prebuiltLibraryStaticBp2Build(ctx, module, true)
prebuiltLibrarySharedBp2Build(ctx, module) prebuiltLibrarySharedBp2Build(ctx, module)
} }
func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Module, fullBuild bool) { func prebuiltLibraryStaticBp2Build(ctx android.Bp2buildMutatorContext, module *Module, fullBuild bool) {
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, true) prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, true)
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil) exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil)
@ -404,7 +404,7 @@ type bazelPrebuiltLibrarySharedAttributes struct {
Export_system_includes bazel.StringListAttribute Export_system_includes bazel.StringListAttribute
} }
func prebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext, module *Module) { func prebuiltLibrarySharedBp2Build(ctx android.Bp2buildMutatorContext, module *Module) {
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, false) prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, false)
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil) exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil)
@ -637,7 +637,7 @@ type bazelPrebuiltObjectAttributes struct {
Src bazel.LabelAttribute Src bazel.LabelAttribute
} }
func prebuiltObjectBp2Build(ctx android.TopDownMutatorContext, module *Module) { func prebuiltObjectBp2Build(ctx android.Bp2buildMutatorContext, module *Module) {
prebuiltAttrs := bp2BuildParsePrebuiltObjectProps(ctx, module) prebuiltAttrs := bp2BuildParsePrebuiltObjectProps(ctx, module)
attrs := &bazelPrebuiltObjectAttributes{ attrs := &bazelPrebuiltObjectAttributes{
@ -797,7 +797,7 @@ type bazelPrebuiltBinaryAttributes struct {
Strip stripAttributes Strip stripAttributes
} }
func prebuiltBinaryBp2Build(ctx android.TopDownMutatorContext, module *Module) { func prebuiltBinaryBp2Build(ctx android.Bp2buildMutatorContext, module *Module) {
prebuiltAttrs := bp2BuildParsePrebuiltBinaryProps(ctx, module) prebuiltAttrs := bp2BuildParsePrebuiltBinaryProps(ctx, module)
var la linkerAttributes var la linkerAttributes

View file

@ -700,7 +700,7 @@ type testBinaryAttributes struct {
// TODO(b/244432609): handle `isolated` property. // TODO(b/244432609): handle `isolated` property.
// TODO(b/244432134): handle custom runpaths for tests that assume runfile layouts not // TODO(b/244432134): handle custom runpaths for tests that assume runfile layouts not
// default to bazel. (see linkerInit function) // default to bazel. (see linkerInit function)
func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) { func testBinaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
var testBinaryAttrs testBinaryAttributes var testBinaryAttrs testBinaryAttributes
testBinaryAttrs.binaryAttributes = binaryBp2buildAttrs(ctx, m) testBinaryAttrs.binaryAttributes = binaryBp2buildAttrs(ctx, m)

View file

@ -712,7 +712,7 @@ type bazelPrebuiltFileAttributes struct {
// Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion // Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion
// of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes // of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes
// used by both prebuilt_etc_xml and other prebuilt_* moodules // used by both prebuilt_etc_xml and other prebuilt_* moodules
func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) (*bazelPrebuiltFileAttributes, bool) { func (module *PrebuiltEtc) Bp2buildHelper(ctx android.Bp2buildMutatorContext) (*bazelPrebuiltFileAttributes, bool) {
var src bazel.LabelAttribute var src bazel.LabelAttribute
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) { for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) {
for config, p := range configToProps { for config, p := range configToProps {
@ -794,7 +794,7 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) (*b
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc // ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
// prebuilt_* modules (except prebuilt_etc_xml) are PrebuiltEtc, // prebuilt_* modules (except prebuilt_etc_xml) are PrebuiltEtc,
// which we treat as *PrebuiltFile* // which we treat as *PrebuiltFile*
func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
var dir = module.installDirBase var dir = module.installDirBase
// prebuilt_file supports only `etc` or `usr/share` // prebuilt_file supports only `etc` or `usr/share`
if !(dir == "etc" || dir == "usr/share") { if !(dir == "etc" || dir == "usr/share") {

View file

@ -920,7 +920,7 @@ type BazelGenruleAttributes struct {
} }
// ConvertWithBp2build converts a Soong module -> Bazel target. // ConvertWithBp2build converts a Soong module -> Bazel target.
func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
// Bazel only has the "tools" attribute. // Bazel only has the "tools" attribute.
tools_prop := android.BazelLabelForModuleDeps(ctx, m.properties.Tools) tools_prop := android.BazelLabelForModuleDeps(ctx, m.properties.Tools)
tool_files_prop := android.BazelLabelForModuleSrc(ctx, m.properties.Tool_files) tool_files_prop := android.BazelLabelForModuleSrc(ctx, m.properties.Tool_files)

View file

@ -1239,7 +1239,7 @@ type bazelAndroidLibraryImport struct {
Sdk_version bazel.StringAttribute Sdk_version bazel.StringAttribute
} }
func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) (*bazelAapt, bool) { func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.Bp2buildMutatorContext) (*bazelAapt, bool) {
manifest := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml") manifest := proptools.StringDefault(a.aaptProperties.Manifest, "AndroidManifest.xml")
resourceFiles := bazel.LabelList{ resourceFiles := bazel.LabelList{
@ -1275,7 +1275,7 @@ func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) (
}, true }, true
} }
func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (a *AARImport) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
aars := android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Aars, []string{}) aars := android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Aars, []string{})
exportableStaticLibs := []string{} exportableStaticLibs := []string{}
// TODO(b/240716882): investigate and handle static_libs deps that are not imports. They are not supported for export by Bazel. // TODO(b/240716882): investigate and handle static_libs deps that are not imports. They are not supported for export by Bazel.
@ -1328,7 +1328,7 @@ func AndroidLibraryBazelTargetModuleProperties() bazel.BazelTargetModuleProperti
} }
} }
func (a *AndroidLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (a *AndroidLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
commonAttrs, bp2buildInfo, supported := a.convertLibraryAttrsBp2Build(ctx) commonAttrs, bp2buildInfo, supported := a.convertLibraryAttrsBp2Build(ctx)
if !supported { if !supported {
return return

View file

@ -1594,11 +1594,11 @@ type bazelAndroidAppCertificateAttributes struct {
Certificate string Certificate string
} }
func (m *AndroidAppCertificate) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *AndroidAppCertificate) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
androidAppCertificateBp2Build(ctx, m) androidAppCertificateBp2Build(ctx, m)
} }
func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) { func androidAppCertificateBp2Build(ctx android.Bp2buildMutatorContext, module *AndroidAppCertificate) {
var certificate string var certificate string
if module.properties.Certificate != nil { if module.properties.Certificate != nil {
certificate = *module.properties.Certificate certificate = *module.properties.Certificate
@ -1634,7 +1634,7 @@ type bazelAndroidAppAttributes struct {
Proguard_specs bazel.LabelListAttribute Proguard_specs bazel.LabelListAttribute
} }
func convertWithBp2build(ctx android.TopDownMutatorContext, a *AndroidApp) (bool, android.CommonAttributes, *bazelAndroidAppAttributes) { func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (bool, android.CommonAttributes, *bazelAndroidAppAttributes) {
aapt, supported := a.convertAaptAttrsWithBp2Build(ctx) aapt, supported := a.convertAaptAttrsWithBp2Build(ctx)
if !supported { if !supported {
return false, android.CommonAttributes{}, &bazelAndroidAppAttributes{} return false, android.CommonAttributes{}, &bazelAndroidAppAttributes{}
@ -1745,7 +1745,7 @@ func convertWithBp2build(ctx android.TopDownMutatorContext, a *AndroidApp) (bool
} }
// ConvertWithBp2build is used to convert android_app to Bazel. // ConvertWithBp2build is used to convert android_app to Bazel.
func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (a *AndroidApp) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, a); ok { if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, a); ok {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "android_binary", Rule_class: "android_binary",
@ -1758,7 +1758,7 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
} }
// ConvertWithBp2build is used to convert android_test to Bazel. // ConvertWithBp2build is used to convert android_test to Bazel.
func (at *AndroidTest) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (at *AndroidTest) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, &at.AndroidApp); ok { if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, &at.AndroidApp); ok {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "android_test", Rule_class: "android_test",

View file

@ -2359,7 +2359,7 @@ type ModuleWithStem interface {
var _ ModuleWithStem = (*Module)(nil) var _ ModuleWithStem = (*Module)(nil)
func (j *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (j *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
switch ctx.ModuleType() { switch ctx.ModuleType() {
case "java_library", "java_library_host", "java_library_static", "tradefed_java_library_host": case "java_library", "java_library_host", "java_library_static", "tradefed_java_library_host":
if lib, ok := ctx.Module().(*Library); ok { if lib, ok := ctx.Module().(*Library); ok {

View file

@ -198,7 +198,7 @@ type bazelDeviceHostConverterAttributes struct {
Exports bazel.LabelListAttribute Exports bazel.LabelListAttribute
} }
func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
ctx.CreateBazelTargetModule( ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{ bazel.BazelTargetModuleProperties{
Rule_class: "java_host_for_device", Rule_class: "java_host_for_device",

View file

@ -871,7 +871,7 @@ func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleCont
} }
// ConvertWithBp2build implements android.BazelModule. // ConvertWithBp2build implements android.BazelModule.
func (d *ExportedDroiddocDir) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (d *ExportedDroiddocDir) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
// Use the native py_library rule. // Use the native py_library rule.
Rule_class: "droiddoc_exported_dir", Rule_class: "droiddoc_exported_dir",

View file

@ -2775,7 +2775,7 @@ type javaResourcesAttributes struct {
Additional_resources bazel.LabelListAttribute Additional_resources bazel.LabelListAttribute
} }
func (m *Library) getResourceFilegroupStripPrefix(ctx android.TopDownMutatorContext, resourceFilegroup string) (*string, bool) { func (m *Library) getResourceFilegroupStripPrefix(ctx android.Bp2buildMutatorContext, resourceFilegroup string) (*string, bool) {
if otherM, ok := ctx.ModuleFromName(resourceFilegroup); ok { if otherM, ok := ctx.ModuleFromName(resourceFilegroup); ok {
if fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup { if fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup {
return proptools.StringPtr(filepath.Join(ctx.OtherModuleDir(otherM), fg.GetPath(ctx))), true return proptools.StringPtr(filepath.Join(ctx.OtherModuleDir(otherM), fg.GetPath(ctx))), true
@ -2784,7 +2784,7 @@ func (m *Library) getResourceFilegroupStripPrefix(ctx android.TopDownMutatorCont
return proptools.StringPtr(""), false return proptools.StringPtr(""), false
} }
func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorContext) *javaResourcesAttributes { func (m *Library) convertJavaResourcesAttributes(ctx android.Bp2buildMutatorContext) *javaResourcesAttributes {
var resources bazel.LabelList var resources bazel.LabelList
var resourceStripPrefix *string var resourceStripPrefix *string
@ -2915,7 +2915,7 @@ func javaXsdTargetName(xsd android.XsdConfigBp2buildTargets) string {
// which has other non-attribute information needed for bp2build conversion // which has other non-attribute information needed for bp2build conversion
// that needs different handling depending on the module types, and thus needs // that needs different handling depending on the module types, and thus needs
// to be returned to the calling function. // to be returned to the calling function.
func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) (*javaCommonAttributes, *bp2BuildJavaInfo, bool) { func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext) (*javaCommonAttributes, *bp2BuildJavaInfo, bool) {
var srcs bazel.LabelListAttribute var srcs bazel.LabelListAttribute
var deps bazel.LabelListAttribute var deps bazel.LabelListAttribute
var staticDeps bazel.LabelListAttribute var staticDeps bazel.LabelListAttribute
@ -3136,7 +3136,7 @@ func javaLibraryBazelTargetModuleProperties() bazel.BazelTargetModuleProperties
} }
} }
func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { func javaLibraryBp2Build(ctx android.Bp2buildMutatorContext, m *Library) {
commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx) commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx)
if !supported { if !supported {
return return
@ -3192,7 +3192,7 @@ type javaBinaryHostAttributes struct {
} }
// JavaBinaryHostBp2Build is for java_binary_host bp2build. // JavaBinaryHostBp2Build is for java_binary_host bp2build.
func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) { func javaBinaryHostBp2Build(ctx android.Bp2buildMutatorContext, m *Binary) {
commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx) commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx)
if !supported { if !supported {
return return
@ -3279,7 +3279,7 @@ type javaTestHostAttributes struct {
} }
// javaTestHostBp2Build is for java_test_host bp2build. // javaTestHostBp2Build is for java_test_host bp2build.
func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) { func javaTestHostBp2Build(ctx android.Bp2buildMutatorContext, m *TestHost) {
commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx) commonAttrs, bp2BuildInfo, supported := m.convertLibraryAttrsBp2Build(ctx)
if !supported { if !supported {
return return
@ -3332,7 +3332,7 @@ type libraryCreationInfo struct {
// helper function that creates java_library target from java_binary_host or java_test_host, // helper function that creates java_library target from java_binary_host or java_test_host,
// and returns the library target name, // and returns the library target name,
func createLibraryTarget(ctx android.TopDownMutatorContext, libInfo libraryCreationInfo) string { func createLibraryTarget(ctx android.Bp2buildMutatorContext, libInfo libraryCreationInfo) string {
libName := libInfo.baseName + "_lib" libName := libInfo.baseName + "_lib"
var libProps bazel.BazelTargetModuleProperties var libProps bazel.BazelTargetModuleProperties
if libInfo.hasKotlin { if libInfo.hasKotlin {
@ -3355,7 +3355,7 @@ type bazelJavaImportAttributes struct {
} }
// java_import bp2Build converter. // java_import bp2Build converter.
func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (i *Import) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
var jars bazel.LabelListAttribute var jars bazel.LabelListAttribute
archVariantProps := i.GetArchVariantProperties(ctx, &ImportProperties{}) archVariantProps := i.GetArchVariantProperties(ctx, &ImportProperties{})
for axis, configToProps := range archVariantProps { for axis, configToProps := range archVariantProps {

View file

@ -130,7 +130,7 @@ type bazelPlatformCompatConfigAttributes struct {
Src bazel.LabelAttribute Src bazel.LabelAttribute
} }
func (p *platformCompatConfig) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (p *platformCompatConfig) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "platform_compat_config", Rule_class: "platform_compat_config",
Bzl_load_location: "//build/bazel/rules/java:platform_compat_config.bzl", Bzl_load_location: "//build/bazel/rules/java:platform_compat_config.bzl",

View file

@ -64,7 +64,7 @@ type pluginAttributes struct {
} }
// ConvertWithBp2build is used to convert android_app to Bazel. // ConvertWithBp2build is used to convert android_app to Bazel.
func (p *Plugin) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (p *Plugin) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
pluginName := p.Name() pluginName := p.Name()
commonAttrs, bp2BuildInfo, supported := p.convertLibraryAttrsBp2Build(ctx) commonAttrs, bp2BuildInfo, supported := p.convertLibraryAttrsBp2Build(ctx)
if !supported { if !supported {

View file

@ -2284,7 +2284,7 @@ type bazelSdkLibraryAttributes struct {
} }
// java_sdk_library bp2build converter // java_sdk_library bp2build converter
func (module *SdkLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (module *SdkLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() != "java_sdk_library" { if ctx.ModuleType() != "java_sdk_library" {
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "") ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "")
return return
@ -2449,7 +2449,7 @@ func sdkLibraryImportFactory() android.Module {
} }
// java_sdk_library bp2build converter // java_sdk_library bp2build converter
func (i *SdkLibraryImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (i *SdkLibraryImport) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
nameToAttr := make(map[string]*bazel.Label) nameToAttr := make(map[string]*bazel.Label)
for scope, props := range i.scopeProperties { for scope, props := range i.scopeProperties {

View file

@ -107,7 +107,7 @@ type linkerConfigAttributes struct {
Src bazel.LabelAttribute Src bazel.LabelAttribute
} }
func (l *linkerConfig) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (l *linkerConfig) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if l.properties.Src == nil { if l.properties.Src == nil {
ctx.PropertyErrorf("src", "empty src is not supported") ctx.PropertyErrorf("src", "empty src is not supported")
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_UNSUPPORTED, "") ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_UNSUPPORTED, "")

View file

@ -54,7 +54,7 @@ type baseAttributes struct {
Imports bazel.StringListAttribute Imports bazel.StringListAttribute
} }
func (m *PythonLibraryModule) makeArchVariantBaseAttributes(ctx android.TopDownMutatorContext) baseAttributes { func (m *PythonLibraryModule) makeArchVariantBaseAttributes(ctx android.Bp2buildMutatorContext) baseAttributes {
var attrs baseAttributes var attrs baseAttributes
archVariantBaseProps := m.GetArchVariantProperties(ctx, &BaseProperties{}) archVariantBaseProps := m.GetArchVariantProperties(ctx, &BaseProperties{})
for axis, configToProps := range archVariantBaseProps { for axis, configToProps := range archVariantBaseProps {
@ -123,7 +123,7 @@ func (m *PythonLibraryModule) makeArchVariantBaseAttributes(ctx android.TopDownM
return attrs return attrs
} }
func (m *PythonLibraryModule) bp2buildPythonVersion(ctx android.TopDownMutatorContext) *string { func (m *PythonLibraryModule) bp2buildPythonVersion(ctx android.Bp2buildMutatorContext) *string {
py3Enabled := proptools.BoolDefault(m.properties.Version.Py3.Enabled, true) py3Enabled := proptools.BoolDefault(m.properties.Version.Py3.Enabled, true)
py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false) py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false)
if py2Enabled && !py3Enabled { if py2Enabled && !py3Enabled {
@ -146,7 +146,7 @@ type bazelPythonBinaryAttributes struct {
Imports bazel.StringListAttribute Imports bazel.StringListAttribute
} }
func (p *PythonLibraryModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (p *PythonLibraryModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
// TODO(b/182306917): this doesn't fully handle all nested props versioned // TODO(b/182306917): this doesn't fully handle all nested props versioned
// by the python version, which would have been handled by the version split // by the python version, which would have been handled by the version split
// mutator. This is sufficient for very simple python_library modules under // mutator. This is sufficient for very simple python_library modules under
@ -176,7 +176,7 @@ func (p *PythonLibraryModule) ConvertWithBp2build(ctx android.TopDownMutatorCont
}, attrs) }, attrs)
} }
func (p *PythonBinaryModule) bp2buildBinaryProperties(ctx android.TopDownMutatorContext) (*bazelPythonBinaryAttributes, bazel.LabelListAttribute) { func (p *PythonBinaryModule) bp2buildBinaryProperties(ctx android.Bp2buildMutatorContext) (*bazelPythonBinaryAttributes, bazel.LabelListAttribute) {
// TODO(b/182306917): this doesn't fully handle all nested props versioned // TODO(b/182306917): this doesn't fully handle all nested props versioned
// by the python version, which would have been handled by the version split // by the python version, which would have been handled by the version split
// mutator. This is sufficient for very simple python_binary_host modules // mutator. This is sufficient for very simple python_binary_host modules
@ -209,7 +209,7 @@ func (p *PythonBinaryModule) bp2buildBinaryProperties(ctx android.TopDownMutator
return attrs, baseAttrs.Data return attrs, baseAttrs.Data
} }
func (p *PythonBinaryModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (p *PythonBinaryModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
attrs, data := p.bp2buildBinaryProperties(ctx) attrs, data := p.bp2buildBinaryProperties(ctx)
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
@ -223,7 +223,7 @@ func (p *PythonBinaryModule) ConvertWithBp2build(ctx android.TopDownMutatorConte
}, attrs) }, attrs)
} }
func (p *PythonTestModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (p *PythonTestModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
// Python tests are currently exactly the same as binaries, but with a different module type // Python tests are currently exactly the same as binaries, but with a different module type
attrs, data := p.bp2buildBinaryProperties(ctx) attrs, data := p.bp2buildBinaryProperties(ctx)

View file

@ -15,9 +15,10 @@
package rust package rust
import ( import (
"fmt"
"android/soong/android" "android/soong/android"
"android/soong/bazel" "android/soong/bazel"
"fmt"
) )
func init() { func init() {
@ -199,7 +200,7 @@ type rustBinaryLibraryAttributes struct {
Rustc_flags bazel.StringListAttribute Rustc_flags bazel.StringListAttribute
} }
func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) { func binaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
binary := m.compiler.(*binaryDecorator) binary := m.compiler.(*binaryDecorator)
var srcs bazel.LabelList var srcs bazel.LabelList

View file

@ -810,7 +810,7 @@ type rustLibraryAttributes struct {
Proc_macro_deps bazel.LabelListAttribute Proc_macro_deps bazel.LabelListAttribute
} }
func libraryBp2build(ctx android.TopDownMutatorContext, m *Module) { func libraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
lib := m.compiler.(*libraryDecorator) lib := m.compiler.(*libraryDecorator)
srcs, compileData := srcsAndCompileDataAttrs(ctx, *lib.baseCompiler) srcs, compileData := srcsAndCompileDataAttrs(ctx, *lib.baseCompiler)
@ -887,7 +887,7 @@ type cargoBuildScriptAttributes struct {
Version bazel.StringAttribute Version bazel.StringAttribute
} }
func cargoBuildScriptBp2build(ctx android.TopDownMutatorContext, m *Module) *string { func cargoBuildScriptBp2build(ctx android.Bp2buildMutatorContext, m *Module) *string {
// Soong treats some crates like libprotobuf as special in that they have // Soong treats some crates like libprotobuf as special in that they have
// cargo build script ran to produce an out folder and check it into AOSP // cargo build script ran to produce an out folder and check it into AOSP
// For example, https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/protobuf/out/ // For example, https://cs.android.com/android/platform/superproject/main/+/main:external/rust/crates/protobuf/out/

View file

@ -15,9 +15,10 @@
package rust package rust
import ( import (
"fmt"
"android/soong/android" "android/soong/android"
"android/soong/bazel" "android/soong/bazel"
"fmt"
) )
func init() { func init() {
@ -114,7 +115,7 @@ type procMacroAttributes struct {
Rustc_flags bazel.StringListAttribute Rustc_flags bazel.StringListAttribute
} }
func procMacroBp2build(ctx android.TopDownMutatorContext, m *Module) { func procMacroBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
procMacro := m.compiler.(*procMacroDecorator) procMacro := m.compiler.(*procMacroDecorator)
srcs, compileData := srcsAndCompileDataAttrs(ctx, *procMacro.baseCompiler) srcs, compileData := srcsAndCompileDataAttrs(ctx, *procMacro.baseCompiler)
deps := android.BazelLabelForModuleDeps(ctx, append( deps := android.BazelLabelForModuleDeps(ctx, append(

View file

@ -282,7 +282,7 @@ type protoLibraryAttributes struct {
Srcs bazel.LabelListAttribute Srcs bazel.LabelListAttribute
} }
func protoLibraryBp2build(ctx android.TopDownMutatorContext, m *Module) { func protoLibraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) {
var protoFiles []string var protoFiles []string
for _, propsInterface := range m.sourceProvider.SourceProviderProps() { for _, propsInterface := range m.sourceProvider.SourceProviderProps() {

View file

@ -15,11 +15,12 @@
package rust package rust
import ( import (
"fmt"
"strings"
"android/soong/bazel" "android/soong/bazel"
"android/soong/bloaty" "android/soong/bloaty"
"android/soong/ui/metrics/bp2build_metrics_proto" "android/soong/ui/metrics/bp2build_metrics_proto"
"fmt"
"strings"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
@ -1845,7 +1846,7 @@ func (c *Module) Partition() string {
return "" return ""
} }
func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
if ctx.ModuleType() == "rust_library_host" || ctx.ModuleType() == "rust_library" { if ctx.ModuleType() == "rust_library_host" || ctx.ModuleType() == "rust_library" {
libraryBp2build(ctx, m) libraryBp2build(ctx, m)
} else if ctx.ModuleType() == "rust_proc_macro" { } else if ctx.ModuleType() == "rust_proc_macro" {
@ -1864,7 +1865,7 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
// TODO(b/297344471): When crate_root prop is set which enforces inputs sandboxing, // TODO(b/297344471): When crate_root prop is set which enforces inputs sandboxing,
// always use `srcs` and `compile_data` props to generate `srcs` and `compile_data` attributes // always use `srcs` and `compile_data` props to generate `srcs` and `compile_data` attributes
// instead of using globs. // instead of using globs.
func srcsAndCompileDataAttrs(ctx android.TopDownMutatorContext, c baseCompiler) (bazel.LabelList, bazel.LabelList) { func srcsAndCompileDataAttrs(ctx android.Bp2buildMutatorContext, c baseCompiler) (bazel.LabelList, bazel.LabelList) {
var srcs bazel.LabelList var srcs bazel.LabelList
var compileData bazel.LabelList var compileData bazel.LabelList

View file

@ -583,7 +583,7 @@ type bazelShTestAttributes struct {
Auto_gen_config *bool Auto_gen_config *bool
} }
func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *ShBinary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
srcs := bazel.MakeLabelListAttribute( srcs := bazel.MakeLabelListAttribute(
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src})) android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
@ -611,7 +611,7 @@ func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
} }
func (m *ShTest) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *ShTest) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
srcs := bazel.MakeLabelListAttribute( srcs := bazel.MakeLabelListAttribute(
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src})) android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))

View file

@ -591,7 +591,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
} }
// TODO(b/240463568): Additional properties will be added for API validation // TODO(b/240463568): Additional properties will be added for API validation
func (m *syspropLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (m *syspropLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
labels := cc.SyspropLibraryLabels{ labels := cc.SyspropLibraryLabels{
SyspropLibraryLabel: m.BaseModuleName(), SyspropLibraryLabel: m.BaseModuleName(),
SharedLibraryLabel: m.CcImplementationModuleName(), SharedLibraryLabel: m.CcImplementationModuleName(),

View file

@ -49,7 +49,7 @@ type TestConfigAttributes struct {
} }
func GetTestConfigAttributes( func GetTestConfigAttributes(
ctx android.TopDownMutatorContext, ctx android.Bp2buildMutatorContext,
testConfig *string, testConfig *string,
extraTestConfigs []string, extraTestConfigs []string,
autoGenConfig *bool, autoGenConfig *bool,
@ -93,7 +93,7 @@ func GetTestConfigAttributes(
} }
func GetTestConfig( func GetTestConfig(
ctx android.TopDownMutatorContext, ctx android.Bp2buildMutatorContext,
testConfig *string, testConfig *string,
) *bazel.Label { ) *bazel.Label {

View file

@ -145,7 +145,7 @@ type bazelPrebuiltEtcXmlAttributes struct {
Schema *string Schema *string
} }
func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.TopDownMutatorContext) { func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
baseAttrs, convertible := p.PrebuiltEtc.Bp2buildHelper(ctx) baseAttrs, convertible := p.PrebuiltEtc.Bp2buildHelper(ctx)
if !convertible { if !convertible {