Have ConvertWBp2build use Bp2buildMutatorContext
This no-op refactoring facilitates some upcoming functional changes for "bp2build allowlist v2". The work requires that the bp2build conversion mutator be changed from a TopDown mutator to a BottomUp mutator. Refactoring all bp2build-related methods so that they use Bp2buildMutatorContext makes it easier to make this functional change without touching tens of files and multiple projects. Bug: 285631638 Test: m bp2build Change-Id: I3d1ef3064146e959c6f0dc315350fc9764bf2bd2
This commit is contained in:
@@ -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)
|
||||
|
||||
|
2
cc/cc.go
2
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:
|
||||
|
@@ -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{})
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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",
|
||||
|
@@ -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",
|
||||
|
@@ -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")
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user