diff --git a/aconfig/aconfig_declarations.go b/aconfig/aconfig_declarations.go index ed0961b25..f19ddb8be 100644 --- a/aconfig/aconfig_declarations.go +++ b/aconfig/aconfig_declarations.go @@ -168,7 +168,7 @@ type bazelAconfigDeclarationsAttributes struct { Package string } -func (module *DeclarationsModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (module *DeclarationsModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if ctx.ModuleType() != "aconfig_declarations" { return } diff --git a/aconfig/aconfig_value_set.go b/aconfig/aconfig_value_set.go index af9ddd3dc..cd178d480 100644 --- a/aconfig/aconfig_value_set.go +++ b/aconfig/aconfig_value_set.go @@ -96,7 +96,7 @@ type bazelAconfigValueSetAttributes struct { Values bazel.LabelListAttribute } -func (module *ValueSetModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (module *ValueSetModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if ctx.ModuleType() != "aconfig_value_set" { return } diff --git a/aconfig/aconfig_values.go b/aconfig/aconfig_values.go index 0aa6a72a4..03a930dbd 100644 --- a/aconfig/aconfig_values.go +++ b/aconfig/aconfig_values.go @@ -75,7 +75,7 @@ type bazelAconfigValuesAttributes struct { Package string } -func (module *ValuesModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (module *ValuesModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if ctx.ModuleType() != "aconfig_values" { return } diff --git a/aidl_library/aidl_library.go b/aidl_library/aidl_library.go index 7449d678c..2c0aef77f 100644 --- a/aidl_library/aidl_library.go +++ b/aidl_library/aidl_library.go @@ -64,7 +64,7 @@ type bazelAidlLibraryAttributes struct { Deps bazel.LabelListAttribute } -func (lib *AidlLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (lib *AidlLibrary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { srcs := bazel.MakeLabelListAttribute( android.BazelLabelForModuleSrc( ctx, diff --git a/android/bazel.go b/android/bazel.go index e764b1864..8634daba1 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -162,7 +162,7 @@ type Bazelable interface { // Modules must implement this function to be bp2build convertible. The function // must either create at least one Bazel target module (using ctx.CreateBazelTargetModule or // 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 // (e.g. acme, android) to a map of interfaces{}, which are really diff --git a/android/bazel_paths.go b/android/bazel_paths.go index 86829ce29..ac862d4b4 100644 --- a/android/bazel_paths.go +++ b/android/bazel_paths.go @@ -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, // it's defined with the string attribute. func BazelStringOrLabelFromProp( - ctx TopDownMutatorContext, + ctx Bp2buildMutatorContext, propToDistinguish *string) (bazel.LabelAttribute, bazel.StringAttribute) { var labelAttr bazel.LabelAttribute diff --git a/android/bazel_test.go b/android/bazel_test.go index 15d3a6b52..e0145b527 100644 --- a/android/bazel_test.go +++ b/android/bazel_test.go @@ -469,7 +469,7 @@ func mixedBuildModuleFactory() Module { return m } -func (m *mixedBuildModule) ConvertWithBp2build(ctx TopDownMutatorContext) { +func (m *mixedBuildModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) { } func (m *mixedBuildModule) DepsMutator(ctx BottomUpMutatorContext) { diff --git a/android/defaults.go b/android/defaults.go index e0e6e5cf1..cc723f728 100644 --- a/android/defaults.go +++ b/android/defaults.go @@ -180,7 +180,7 @@ func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {} // ConvertWithBp2build to fulfill Bazelable interface; however, at this time defaults module are // *NOT* converted with bp2build -func (defaultable *DefaultsModuleBase) ConvertWithBp2build(ctx TopDownMutatorContext) { +func (defaultable *DefaultsModuleBase) ConvertWithBp2build(ctx Bp2buildMutatorContext) { // Defaults types are never convertible. ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "") } diff --git a/android/filegroup.go b/android/filegroup.go index 6cc9232b6..a4bbcae99 100644 --- a/android/filegroup.go +++ b/android/filegroup.go @@ -93,7 +93,7 @@ func (fg *fileGroup) ConvertWithApiBp2build(ctx TopDownMutatorContext) { } // ConvertWithBp2build performs bp2build conversion of filegroup -func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) { +func (fg *fileGroup) ConvertWithBp2build(ctx Bp2buildMutatorContext) { srcs := bazel.MakeLabelListAttribute( BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs)) @@ -209,10 +209,10 @@ func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) { } 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 { return *fg.properties.Path } diff --git a/android/license.go b/android/license.go index a09422b98..76f5115f5 100644 --- a/android/license.go +++ b/android/license.go @@ -71,7 +71,7 @@ type bazelLicenseAttributes struct { Visibility []string } -func (m *licenseModule) ConvertWithBp2build(ctx TopDownMutatorContext) { +func (m *licenseModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) { attrs := &bazelLicenseAttributes{ License_kinds: m.properties.License_kinds, Copyright_notice: m.properties.Copyright_notice, diff --git a/android/license_kind.go b/android/license_kind.go index 24b91e4c2..78df93835 100644 --- a/android/license_kind.go +++ b/android/license_kind.go @@ -50,7 +50,7 @@ type bazelLicenseKindAttributes struct { Visibility []string } -func (m *licenseKindModule) ConvertWithBp2build(ctx TopDownMutatorContext) { +func (m *licenseKindModule) ConvertWithBp2build(ctx Bp2buildMutatorContext) { attrs := &bazelLicenseKindAttributes{ Conditions: m.properties.Conditions, Url: m.properties.Url, diff --git a/android/mutator.go b/android/mutator.go index 41477b8ed..028479427 100644 --- a/android/mutator.go +++ b/android/mutator.go @@ -15,9 +15,10 @@ package android import ( + "path/filepath" + "android/soong/bazel" "android/soong/ui/metrics/bp2build_metrics_proto" - "path/filepath" "github.com/google/blueprint" ) @@ -229,37 +230,8 @@ var bp2buildPreArchMutators = []RegisterMutatorFunc{} // A minimal context for Bp2build conversion type Bp2buildMutatorContext interface { 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 - // 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 // factory method, just like in CreateModule, but also requires // BazelTargetModuleProperties containing additional metadata for the @@ -290,6 +262,34 @@ type TopDownMutatorContext interface { 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 { bp blueprint.TopDownMutatorContext baseModuleContext diff --git a/android/package.go b/android/package.go index 7fbc70041..ce0b15013 100644 --- a/android/package.go +++ b/android/package.go @@ -54,7 +54,7 @@ type packageModule struct { 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)) // 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 diff --git a/apex/apex.go b/apex/apex.go index a116b85ee..de6c6a8bd 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2623,7 +2623,7 @@ func OverrideApexFactory() android.Module { return m } -func (o *OverrideApex) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (o *OverrideApex) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if ctx.ModuleType() != "override_apex" { return } @@ -3261,7 +3261,7 @@ const ( ) // 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 if ctx.ModuleType() != "apex" && ctx.ModuleType() != "apex_test" { return @@ -3272,7 +3272,7 @@ func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) { 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 manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, proptools.StringDefault(a.properties.Manifest, "apex_manifest.json"))) @@ -3429,7 +3429,7 @@ func convertWithBp2build(a *apexBundle, ctx android.TopDownMutatorContext) (baze // both, 32/32, 64/none, 32&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) { libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) switch compileMultilb { @@ -3444,7 +3444,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) { libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) switch compileMultilb { @@ -3457,7 +3457,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) { libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) switch compileMultilb { @@ -3475,7 +3475,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) { libsLabelList := android.BazelLabelForModuleDeps(ctx, libs) switch compileMultilb { @@ -3518,7 +3518,7 @@ func makeSharedLibsAttributes(config string, libsLabelList bazel.LabelList, 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) } diff --git a/apex/key.go b/apex/key.go index 65e739a90..fc1456b96 100644 --- a/apex/key.go +++ b/apex/key.go @@ -208,11 +208,11 @@ type bazelApexKeyAttributes struct { } // ConvertWithBp2build performs conversion apexKey for bp2build -func (m *apexKey) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (m *apexKey) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { apexKeyBp2BuildInternal(ctx, m) } -func apexKeyBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexKey) { +func apexKeyBp2BuildInternal(ctx android.Bp2buildMutatorContext, module *apexKey) { privateKeyLabelAttribute, privateKeyNameAttribute := android.BazelStringOrLabelFromProp(ctx, module.properties.Private_key) diff --git a/bp2build/testing.go b/bp2build/testing.go index dbabc067e..b30f8eebb 100644 --- a/bp2build/testing.go +++ b/bp2build/testing.go @@ -497,7 +497,7 @@ func (m *customModule) dir() *string { 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 { customBp2buildOneToMany(ctx, m) return @@ -552,7 +552,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{ Flag_values: bazel.StringMapAttribute{ "//build/bazel/rules/my_string_setting": m.Name(), @@ -587,7 +587,7 @@ func (c *customModule) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) // A bp2build mutator that uses load statements and creates a 1:M mapping from // module to target. -func customBp2buildOneToMany(ctx android.TopDownMutatorContext, m *customModule) { +func customBp2buildOneToMany(ctx android.Bp2buildMutatorContext, m *customModule) { baseName := m.Name() attrs := &customBazelModuleAttributes{} diff --git a/bpf/bpf.go b/bpf/bpf.go index d135d5f56..38777ff65 100644 --- a/bpf/bpf.go +++ b/bpf/bpf.go @@ -313,7 +313,7 @@ type bazelBpfAttributes struct { } // bpf bp2build converter -func (b *bpf) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (b *bpf) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if ctx.ModuleType() != "bpf" { return } diff --git a/cc/binary.go b/cc/binary.go index 4606b623e..0722f8110 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -599,7 +599,7 @@ func (handler *ccBinaryBazelHandler) ProcessBazelQueryResponse(ctx android.Modul 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) binaryLinkerAttrs := bp2buildBinaryLinkerProps(ctx, m) @@ -661,7 +661,7 @@ func binaryBp2buildAttrs(ctx android.TopDownMutatorContext, m *Module) binaryAtt return attrs } -func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) { +func binaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) { // shared with cc_test binaryAttrs := binaryBp2buildAttrs(ctx, m) diff --git a/cc/cc.go b/cc/cc.go index e28d056f8..9aa0cac37 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -4214,7 +4214,7 @@ func (c *Module) typ() moduleType { } // ConvertWithBp2build converts Module to Bazel for bp2build. -func (c *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (c *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { prebuilt := c.IsPrebuilt() switch c.typ() { case binary: diff --git a/cc/fdo_profile.go b/cc/fdo_profile.go index d61af7e44..05a8f464b 100644 --- a/cc/fdo_profile.go +++ b/cc/fdo_profile.go @@ -45,7 +45,7 @@ type bazelFdoProfileAttributes struct { Profile bazel.StringAttribute } -func (fp *fdoProfile) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (fp *fdoProfile) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { var profileAttr bazel.StringAttribute archVariantProps := fp.GetArchVariantProperties(ctx, &fdoProfileProperties{}) diff --git a/cc/library.go b/cc/library.go index 7e0c55ac2..b9dc71b32 100644 --- a/cc/library.go +++ b/cc/library.go @@ -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) staticAttrs := bp2BuildParseStaticProps(ctx, m) baseAttributes := bp2BuildParseBaseProps(ctx, m) @@ -480,7 +480,7 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) { 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 { stubSuitesProps := bazel.BazelTargetModuleProperties{ Rule_class: "cc_stub_suite", @@ -2886,7 +2886,7 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu return outputFile } -func bp2buildParseAbiCheckerProps(ctx android.TopDownMutatorContext, module *Module) bazelCcHeaderAbiCheckerAttributes { +func bp2buildParseAbiCheckerProps(ctx android.Bp2buildMutatorContext, module *Module) bazelCcHeaderAbiCheckerAttributes { lib, ok := module.linker.(*libraryDecorator) if !ok { return bazelCcHeaderAbiCheckerAttributes{} @@ -2909,7 +2909,7 @@ func bp2buildParseAbiCheckerProps(ctx android.TopDownMutatorContext, module *Mod return abiCheckerAttrs } -func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module, isStatic bool) { +func sharedOrStaticLibraryBp2Build(ctx android.Bp2buildMutatorContext, module *Module, isStatic bool) { baseAttributes := bp2BuildParseBaseProps(ctx, module) compilerAttrs := baseAttributes.compilerAttributes linkerAttrs := baseAttributes.linkerAttributes diff --git a/cc/library_headers.go b/cc/library_headers.go index 52198fc45..5eba6ab96 100644 --- a/cc/library_headers.go +++ b/cc/library_headers.go @@ -129,7 +129,7 @@ type bazelCcLibraryHeadersAttributes struct { sdkAttributes } -func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) { +func libraryHeadersBp2Build(ctx android.Bp2buildMutatorContext, module *Module) { baseAttributes := bp2BuildParseBaseProps(ctx, module) exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, &baseAttributes.includes) linkerAttrs := baseAttributes.linkerAttributes diff --git a/cc/ndk_library.go b/cc/ndk_library.go index c13eda2ea..b3bb2da15 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -584,7 +584,7 @@ func apiHeaderLabels(ctx android.TopDownMutatorContext, hdrLibs []string) bazel. return android.BazelLabelForModuleDepsWithFn(ctx, hdrLibs, addSuffix) } -func ndkLibraryBp2build(ctx android.TopDownMutatorContext, c *Module) { +func ndkLibraryBp2build(ctx android.Bp2buildMutatorContext, c *Module) { ndk, _ := c.linker.(*stubDecorator) props := bazel.BazelTargetModuleProperties{ Rule_class: "cc_stub_suite", diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go index c2382b33e..c3e65106a 100644 --- a/cc/ndk_prebuilt.go +++ b/cc/ndk_prebuilt.go @@ -148,7 +148,7 @@ var ( // stlSrcBp2build returns a bazel label for the checked-in .so/.a file // 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_") libExt := ".so" // TODO - b/201079053: Support windows if ctx.ModuleType() == "ndk_prebuilt_static_stl" { @@ -180,7 +180,7 @@ func stlIncludesBp2build(c *Module) bazel.StringListAttribute { 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" { ndkPrebuiltStaticStlBp2build(ctx, c) } 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{ Rule_class: "cc_prebuilt_library_static", 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) } -func ndkPrebuiltSharedStlBp2build(ctx android.TopDownMutatorContext, c *Module) { +func ndkPrebuiltSharedStlBp2build(ctx android.Bp2buildMutatorContext, c *Module) { props := bazel.BazelTargetModuleProperties{ Rule_class: "cc_prebuilt_library_shared", Bzl_load_location: "//build/bazel/rules/cc:cc_prebuilt_library_shared.bzl", diff --git a/cc/object.go b/cc/object.go index ca1484538..a3000e06e 100644 --- a/cc/object.go +++ b/cc/object.go @@ -156,7 +156,7 @@ type bazelObjectAttributes struct { // objectBp2Build is the bp2build converter from cc_object modules to the // 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 { // 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") diff --git a/cc/prebuilt.go b/cc/prebuilt.go index a4ca59050..b4819b013 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -363,12 +363,12 @@ type bazelPrebuiltLibraryStaticAttributes struct { // all variants // // 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) 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) exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil) @@ -404,7 +404,7 @@ type bazelPrebuiltLibrarySharedAttributes struct { Export_system_includes bazel.StringListAttribute } -func prebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext, module *Module) { +func prebuiltLibrarySharedBp2Build(ctx android.Bp2buildMutatorContext, module *Module) { prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module, false) exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, nil) @@ -637,7 +637,7 @@ type bazelPrebuiltObjectAttributes struct { Src bazel.LabelAttribute } -func prebuiltObjectBp2Build(ctx android.TopDownMutatorContext, module *Module) { +func prebuiltObjectBp2Build(ctx android.Bp2buildMutatorContext, module *Module) { prebuiltAttrs := bp2BuildParsePrebuiltObjectProps(ctx, module) attrs := &bazelPrebuiltObjectAttributes{ @@ -797,7 +797,7 @@ type bazelPrebuiltBinaryAttributes struct { Strip stripAttributes } -func prebuiltBinaryBp2Build(ctx android.TopDownMutatorContext, module *Module) { +func prebuiltBinaryBp2Build(ctx android.Bp2buildMutatorContext, module *Module) { prebuiltAttrs := bp2BuildParsePrebuiltBinaryProps(ctx, module) var la linkerAttributes diff --git a/cc/test.go b/cc/test.go index ae621287c..7a6cf1b4e 100644 --- a/cc/test.go +++ b/cc/test.go @@ -700,7 +700,7 @@ type testBinaryAttributes struct { // TODO(b/244432609): handle `isolated` property. // TODO(b/244432134): handle custom runpaths for tests that assume runfile layouts not // default to bazel. (see linkerInit function) -func testBinaryBp2build(ctx android.TopDownMutatorContext, m *Module) { +func testBinaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) { var testBinaryAttrs testBinaryAttributes testBinaryAttrs.binaryAttributes = binaryBp2buildAttrs(ctx, m) diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go index c48bafa26..9314e0ca2 100644 --- a/etc/prebuilt_etc.go +++ b/etc/prebuilt_etc.go @@ -712,7 +712,7 @@ type bazelPrebuiltFileAttributes struct { // Bp2buildHelper returns a bazelPrebuiltFileAttributes used for the conversion // of prebuilt_* modules. bazelPrebuiltFileAttributes has the common attributes // 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 for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltEtcProperties{}) { for config, p := range configToProps { @@ -791,7 +791,7 @@ func (module *PrebuiltEtc) Bp2buildHelper(ctx android.TopDownMutatorContext) (*b // ConvertWithBp2build performs bp2build conversion of PrebuiltEtc // prebuilt_* modules (except prebuilt_etc_xml) are PrebuiltEtc, // which we treat as *PrebuiltFile* -func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (module *PrebuiltEtc) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { var dir = module.installDirBase // prebuilt_file supports only `etc` or `usr/share` if !(dir == "etc" || dir == "usr/share") { diff --git a/genrule/genrule.go b/genrule/genrule.go index d1c2f1378..973b19454 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -920,7 +920,7 @@ type BazelGenruleAttributes struct { } // 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. tools_prop := android.BazelLabelForModuleDeps(ctx, m.properties.Tools) tool_files_prop := android.BazelLabelForModuleSrc(ctx, m.properties.Tool_files) diff --git a/java/aar.go b/java/aar.go index 262657d2d..f28d97149 100644 --- a/java/aar.go +++ b/java/aar.go @@ -1239,7 +1239,7 @@ type bazelAndroidLibraryImport struct { 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") resourceFiles := bazel.LabelList{ @@ -1275,7 +1275,7 @@ func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) ( }, true } -func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (a *AARImport) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { aars := android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Aars, []string{}) exportableStaticLibs := []string{} // 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) if !supported { return diff --git a/java/app.go b/java/app.go index 1b4d279f7..2edd3f74b 100755 --- a/java/app.go +++ b/java/app.go @@ -1594,11 +1594,11 @@ type bazelAndroidAppCertificateAttributes struct { Certificate string } -func (m *AndroidAppCertificate) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (m *AndroidAppCertificate) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { androidAppCertificateBp2Build(ctx, m) } -func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) { +func androidAppCertificateBp2Build(ctx android.Bp2buildMutatorContext, module *AndroidAppCertificate) { var certificate string if module.properties.Certificate != nil { certificate = *module.properties.Certificate @@ -1634,7 +1634,7 @@ type bazelAndroidAppAttributes struct { 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) if !supported { 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. -func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (a *AndroidApp) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, a); ok { props := bazel.BazelTargetModuleProperties{ Rule_class: "android_binary", @@ -1758,7 +1758,7 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { } // 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 { props := bazel.BazelTargetModuleProperties{ Rule_class: "android_test", diff --git a/java/base.go b/java/base.go index 8f483989e..a007717dc 100644 --- a/java/base.go +++ b/java/base.go @@ -2359,7 +2359,7 @@ type ModuleWithStem interface { var _ ModuleWithStem = (*Module)(nil) -func (j *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (j *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { switch ctx.ModuleType() { case "java_library", "java_library_host", "java_library_static", "tradefed_java_library_host": if lib, ok := ctx.Module().(*Library); ok { diff --git a/java/device_host_converter.go b/java/device_host_converter.go index 5460dc993..c5ba245ea 100644 --- a/java/device_host_converter.go +++ b/java/device_host_converter.go @@ -198,7 +198,7 @@ type bazelDeviceHostConverterAttributes struct { Exports bazel.LabelListAttribute } -func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "java_host_for_device", diff --git a/java/droiddoc.go b/java/droiddoc.go index fe0643a78..d5547d05c 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -871,7 +871,7 @@ func (d *ExportedDroiddocDir) GenerateAndroidBuildActions(ctx android.ModuleCont } // ConvertWithBp2build implements android.BazelModule. -func (d *ExportedDroiddocDir) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (d *ExportedDroiddocDir) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { props := bazel.BazelTargetModuleProperties{ // Use the native py_library rule. Rule_class: "droiddoc_exported_dir", diff --git a/java/java.go b/java/java.go index 4f31af685..d5aeb7cb2 100644 --- a/java/java.go +++ b/java/java.go @@ -2775,7 +2775,7 @@ type javaResourcesAttributes struct { 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 fg, isFilegroup := otherM.(android.FileGroupPath); isFilegroup { 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 } -func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorContext) *javaResourcesAttributes { +func (m *Library) convertJavaResourcesAttributes(ctx android.Bp2buildMutatorContext) *javaResourcesAttributes { var resources bazel.LabelList var resourceStripPrefix *string @@ -2915,7 +2915,7 @@ func javaXsdTargetName(xsd android.XsdConfigBp2buildTargets) string { // which has other non-attribute information needed for bp2build conversion // that needs different handling depending on the module types, and thus needs // 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 deps 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) if !supported { return @@ -3192,7 +3192,7 @@ type javaBinaryHostAttributes struct { } // 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) if !supported { return @@ -3279,7 +3279,7 @@ type javaTestHostAttributes struct { } // 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) if !supported { return @@ -3332,7 +3332,7 @@ type libraryCreationInfo struct { // helper function that creates java_library target from java_binary_host or java_test_host, // 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" var libProps bazel.BazelTargetModuleProperties if libInfo.hasKotlin { @@ -3355,7 +3355,7 @@ type bazelJavaImportAttributes struct { } // java_import bp2Build converter. -func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (i *Import) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { var jars bazel.LabelListAttribute archVariantProps := i.GetArchVariantProperties(ctx, &ImportProperties{}) for axis, configToProps := range archVariantProps { diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 124827523..662a2d768 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -130,7 +130,7 @@ type bazelPlatformCompatConfigAttributes struct { Src bazel.LabelAttribute } -func (p *platformCompatConfig) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (p *platformCompatConfig) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { props := bazel.BazelTargetModuleProperties{ Rule_class: "platform_compat_config", Bzl_load_location: "//build/bazel/rules/java:platform_compat_config.bzl", diff --git a/java/plugin.go b/java/plugin.go index 51272981b..4d4c199f7 100644 --- a/java/plugin.go +++ b/java/plugin.go @@ -64,7 +64,7 @@ type pluginAttributes struct { } // 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() commonAttrs, bp2BuildInfo, supported := p.convertLibraryAttrsBp2Build(ctx) if !supported { diff --git a/java/sdk_library.go b/java/sdk_library.go index e3e2427bc..27f862662 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2284,7 +2284,7 @@ type bazelSdkLibraryAttributes struct { } // 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" { ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "") return @@ -2449,7 +2449,7 @@ func sdkLibraryImportFactory() android.Module { } // 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) for scope, props := range i.scopeProperties { diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go index 165697dfa..dad589256 100644 --- a/linkerconfig/linkerconfig.go +++ b/linkerconfig/linkerconfig.go @@ -107,7 +107,7 @@ type linkerConfigAttributes struct { Src bazel.LabelAttribute } -func (l *linkerConfig) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (l *linkerConfig) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { if l.properties.Src == nil { ctx.PropertyErrorf("src", "empty src is not supported") ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_UNSUPPORTED, "") diff --git a/python/bp2build.go b/python/bp2build.go index 8bc3d0a3e..3b283e432 100644 --- a/python/bp2build.go +++ b/python/bp2build.go @@ -54,7 +54,7 @@ type baseAttributes struct { Imports bazel.StringListAttribute } -func (m *PythonLibraryModule) makeArchVariantBaseAttributes(ctx android.TopDownMutatorContext) baseAttributes { +func (m *PythonLibraryModule) makeArchVariantBaseAttributes(ctx android.Bp2buildMutatorContext) baseAttributes { var attrs baseAttributes archVariantBaseProps := m.GetArchVariantProperties(ctx, &BaseProperties{}) for axis, configToProps := range archVariantBaseProps { @@ -123,7 +123,7 @@ func (m *PythonLibraryModule) makeArchVariantBaseAttributes(ctx android.TopDownM 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) py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false) if py2Enabled && !py3Enabled { @@ -146,7 +146,7 @@ type bazelPythonBinaryAttributes struct { 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 // by the python version, which would have been handled by the version split // mutator. This is sufficient for very simple python_library modules under @@ -176,7 +176,7 @@ func (p *PythonLibraryModule) ConvertWithBp2build(ctx android.TopDownMutatorCont }, 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 // by the python version, which would have been handled by the version split // 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 } -func (p *PythonBinaryModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (p *PythonBinaryModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { attrs, data := p.bp2buildBinaryProperties(ctx) props := bazel.BazelTargetModuleProperties{ @@ -223,7 +223,7 @@ func (p *PythonBinaryModule) ConvertWithBp2build(ctx android.TopDownMutatorConte }, 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 attrs, data := p.bp2buildBinaryProperties(ctx) diff --git a/rust/binary.go b/rust/binary.go index 1e24bebab..1408ff17b 100644 --- a/rust/binary.go +++ b/rust/binary.go @@ -15,9 +15,10 @@ package rust import ( + "fmt" + "android/soong/android" "android/soong/bazel" - "fmt" ) func init() { @@ -199,7 +200,7 @@ type rustBinaryLibraryAttributes struct { Rustc_flags bazel.StringListAttribute } -func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) { +func binaryBp2build(ctx android.Bp2buildMutatorContext, m *Module) { binary := m.compiler.(*binaryDecorator) var srcs bazel.LabelList diff --git a/rust/library.go b/rust/library.go index 3f031c10c..035708674 100644 --- a/rust/library.go +++ b/rust/library.go @@ -810,7 +810,7 @@ type rustLibraryAttributes struct { Proc_macro_deps bazel.LabelListAttribute } -func libraryBp2build(ctx android.TopDownMutatorContext, m *Module) { +func libraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) { lib := m.compiler.(*libraryDecorator) srcs, compileData := srcsAndCompileDataAttrs(ctx, *lib.baseCompiler) @@ -887,7 +887,7 @@ type cargoBuildScriptAttributes struct { 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 // 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/ diff --git a/rust/proc_macro.go b/rust/proc_macro.go index 26227d048..b93b24f15 100644 --- a/rust/proc_macro.go +++ b/rust/proc_macro.go @@ -15,9 +15,10 @@ package rust import ( + "fmt" + "android/soong/android" "android/soong/bazel" - "fmt" ) func init() { @@ -114,7 +115,7 @@ type procMacroAttributes struct { Rustc_flags bazel.StringListAttribute } -func procMacroBp2build(ctx android.TopDownMutatorContext, m *Module) { +func procMacroBp2build(ctx android.Bp2buildMutatorContext, m *Module) { procMacro := m.compiler.(*procMacroDecorator) srcs, compileData := srcsAndCompileDataAttrs(ctx, *procMacro.baseCompiler) deps := android.BazelLabelForModuleDeps(ctx, append( diff --git a/rust/protobuf.go b/rust/protobuf.go index ae828442b..c8d2bdaeb 100644 --- a/rust/protobuf.go +++ b/rust/protobuf.go @@ -282,7 +282,7 @@ type protoLibraryAttributes struct { Srcs bazel.LabelListAttribute } -func protoLibraryBp2build(ctx android.TopDownMutatorContext, m *Module) { +func protoLibraryBp2build(ctx android.Bp2buildMutatorContext, m *Module) { var protoFiles []string for _, propsInterface := range m.sourceProvider.SourceProviderProps() { diff --git a/rust/rust.go b/rust/rust.go index 1ee99cdb1..3b2448493 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -15,11 +15,12 @@ package rust import ( + "fmt" + "strings" + "android/soong/bazel" "android/soong/bloaty" "android/soong/ui/metrics/bp2build_metrics_proto" - "fmt" - "strings" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -1845,7 +1846,7 @@ func (c *Module) Partition() string { 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" { libraryBp2build(ctx, m) } 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, // always use `srcs` and `compile_data` props to generate `srcs` and `compile_data` attributes // 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 compileData bazel.LabelList diff --git a/sh/sh_binary.go b/sh/sh_binary.go index 4fe6fdda0..79a885fa9 100644 --- a/sh/sh_binary.go +++ b/sh/sh_binary.go @@ -583,7 +583,7 @@ type bazelShTestAttributes struct { Auto_gen_config *bool } -func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (m *ShBinary) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { srcs := bazel.MakeLabelListAttribute( 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) } -func (m *ShTest) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (m *ShTest) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { srcs := bazel.MakeLabelListAttribute( android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src})) diff --git a/sysprop/sysprop_library.go b/sysprop/sysprop_library.go index a2c0fb731..d16bf32f9 100644 --- a/sysprop/sysprop_library.go +++ b/sysprop/sysprop_library.go @@ -591,7 +591,7 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) { } // 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{ SyspropLibraryLabel: m.BaseModuleName(), SharedLibraryLabel: m.CcImplementationModuleName(), diff --git a/tradefed/autogen_bazel.go b/tradefed/autogen_bazel.go index 8283984c9..cc16176c8 100644 --- a/tradefed/autogen_bazel.go +++ b/tradefed/autogen_bazel.go @@ -49,7 +49,7 @@ type TestConfigAttributes struct { } func GetTestConfigAttributes( - ctx android.TopDownMutatorContext, + ctx android.Bp2buildMutatorContext, testConfig *string, extraTestConfigs []string, autoGenConfig *bool, @@ -93,7 +93,7 @@ func GetTestConfigAttributes( } func GetTestConfig( - ctx android.TopDownMutatorContext, + ctx android.Bp2buildMutatorContext, testConfig *string, ) *bazel.Label { diff --git a/xml/xml.go b/xml/xml.go index 20a26f562..65fe12a8e 100644 --- a/xml/xml.go +++ b/xml/xml.go @@ -145,7 +145,7 @@ type bazelPrebuiltEtcXmlAttributes struct { Schema *string } -func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.TopDownMutatorContext) { +func (p *prebuiltEtcXml) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) { baseAttrs, convertible := p.PrebuiltEtc.Bp2buildHelper(ctx) if !convertible {