Wrap blueprint_go_binary and bootstrap_go_package into android.Modules
Depending on a blueprint_go_binary from a Soong module requires hacks
that allow Soong to support both blueprint.Module and android.Module.
Wrap the blueprint Go module types with ones that implement
android.Module, and delete all the related hacks.
Bug: 319288033
Test: m checkbuild
Flag: EXEMPT refactor
Change-Id: I9b62b450de09bd10288333fbc66aa71c867ae0b3
diff --git a/android/androidmk.go b/android/androidmk.go
index 5fb0cd1..cac2cfe 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -34,7 +34,6 @@
"strings"
"github.com/google/blueprint"
- "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/pathtools"
"github.com/google/blueprint/proptools"
)
@@ -815,8 +814,6 @@
switch x := mod.(type) {
case AndroidMkDataProvider:
err = translateAndroidModule(ctx, w, moduleInfoJSONs, mod, x)
- case bootstrap.GoBinaryTool:
- err = translateGoBinaryModule(ctx, w, mod, x)
case AndroidMkEntriesProvider:
err = translateAndroidMkEntriesModule(ctx, w, moduleInfoJSONs, mod, x)
default:
@@ -831,23 +828,6 @@
return err
}
-// A simple, special Android.mk entry output func to make it possible to build blueprint tools using
-// m by making them phony targets.
-func translateGoBinaryModule(ctx SingletonContext, w io.Writer, mod blueprint.Module,
- goBinary bootstrap.GoBinaryTool) error {
-
- name := ctx.ModuleName(mod)
- fmt.Fprintln(w, ".PHONY:", name)
- fmt.Fprintln(w, name+":", goBinary.InstallPath())
- fmt.Fprintln(w, "")
- // Assuming no rules in make include go binaries in distributables.
- // If the assumption is wrong, make will fail to build without the necessary .meta_lic and .meta_module files.
- // In that case, add the targets and rules here to build a .meta_lic file for `name` and a .meta_module for
- // `goBinary.InstallPath()` pointing to the `name`.meta_lic file.
-
- return nil
-}
-
func (data *AndroidMkData) fillInData(ctx fillInEntriesContext, mod blueprint.Module) {
// Get the preamble content through AndroidMkEntries logic.
data.Entries = AndroidMkEntries{
diff --git a/android/arch.go b/android/arch.go
index 6d896e5..a7868ba 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -23,7 +23,6 @@
"strings"
"github.com/google/blueprint"
- "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
)
@@ -397,33 +396,8 @@
// device_supported and host_supported properties to determine which OsTypes are enabled for this
// module, then searches through the Targets to determine which have enabled Targets for this
// module.
-func osMutator(bpctx blueprint.BottomUpMutatorContext) {
- var module Module
- var ok bool
- if module, ok = bpctx.Module().(Module); !ok {
- // The module is not a Soong module, it is a Blueprint module.
- if bootstrap.IsBootstrapModule(bpctx.Module()) {
- // Bootstrap Go modules are always the build OS or linux bionic.
- config := bpctx.Config().(Config)
- osNames := []string{config.BuildOSTarget.OsVariation()}
- for _, hostCrossTarget := range config.Targets[LinuxBionic] {
- if hostCrossTarget.Arch.ArchType == config.BuildOSTarget.Arch.ArchType {
- osNames = append(osNames, hostCrossTarget.OsVariation())
- }
- }
- osNames = FirstUniqueStrings(osNames)
- bpctx.CreateVariations(osNames...)
- }
- return
- }
-
- // Bootstrap Go module support above requires this mutator to be a
- // blueprint.BottomUpMutatorContext because android.BottomUpMutatorContext
- // filters out non-Soong modules. Now that we've handled them, create a
- // normal android.BottomUpMutatorContext.
- mctx := bottomUpMutatorContextFactory(bpctx, module, false)
- defer bottomUpMutatorContextPool.Put(mctx)
-
+func osMutator(mctx BottomUpMutatorContext) {
+ module := mctx.Module()
base := module.base()
// Nothing to do for modules that are not architecture specific (e.g. a genrule).
@@ -553,24 +527,8 @@
//
// Modules can be initialized with InitAndroidMultiTargetsArchModule, in which case they will be split by OsClass,
// but will have a common Target that is expected to handle all other selected Targets via ctx.MultiTargets().
-func archMutator(bpctx blueprint.BottomUpMutatorContext) {
- var module Module
- var ok bool
- if module, ok = bpctx.Module().(Module); !ok {
- if bootstrap.IsBootstrapModule(bpctx.Module()) {
- // Bootstrap Go modules are always the build architecture.
- bpctx.CreateVariations(bpctx.Config().(Config).BuildOSTarget.ArchVariation())
- }
- return
- }
-
- // Bootstrap Go module support above requires this mutator to be a
- // blueprint.BottomUpMutatorContext because android.BottomUpMutatorContext
- // filters out non-Soong modules. Now that we've handled them, create a
- // normal android.BottomUpMutatorContext.
- mctx := bottomUpMutatorContextFactory(bpctx, module, false)
- defer bottomUpMutatorContextPool.Put(mctx)
-
+func archMutator(mctx BottomUpMutatorContext) {
+ module := mctx.Module()
base := module.base()
if !base.ArchSpecific() {
diff --git a/android/module_context.go b/android/module_context.go
index 54fe0be..2bf2a8f 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -85,7 +85,9 @@
type ModuleContext interface {
BaseModuleContext
- blueprintModuleContext() blueprint.ModuleContext
+ // BlueprintModuleContext returns the blueprint.ModuleContext that the ModuleContext wraps. It may only be
+ // used by the golang module types that need to call into the bootstrap module types.
+ BlueprintModuleContext() blueprint.ModuleContext
// Deprecated: use ModuleContext.Build instead.
ModuleBuild(pctx PackageContext, params ModuleBuildParams)
@@ -779,7 +781,7 @@
m.uncheckedModule = true
}
-func (m *moduleContext) blueprintModuleContext() blueprint.ModuleContext {
+func (m *moduleContext) BlueprintModuleContext() blueprint.ModuleContext {
return m.bp
}
diff --git a/android/mutator.go b/android/mutator.go
index 38fb857..2ef4d7f 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -148,9 +148,9 @@
}
func registerArchMutator(ctx RegisterMutatorsContext) {
- ctx.BottomUpBlueprint("os", osMutator).Parallel()
+ ctx.BottomUp("os", osMutator).Parallel()
ctx.Transition("image", &imageTransitionMutator{})
- ctx.BottomUpBlueprint("arch", archMutator).Parallel()
+ ctx.BottomUp("arch", archMutator).Parallel()
}
var preDeps = []RegisterMutatorFunc{
diff --git a/android/paths.go b/android/paths.go
index 6322f75..0a4f891 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -27,7 +27,6 @@
"strings"
"github.com/google/blueprint"
- "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/pathtools"
)
@@ -555,13 +554,6 @@
return ret
}
-// PathForGoBinary returns the path to the installed location of a bootstrap_go_binary module.
-func PathForGoBinary(ctx PathContext, goBinary bootstrap.GoBinaryTool) Path {
- goBinaryInstallDir := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin")
- rel := Rel(ctx, goBinaryInstallDir.String(), goBinary.InstallPath())
- return goBinaryInstallDir.Join(ctx, rel)
-}
-
// Expands Paths to a SourceFileProducer or OutputFileProducer module dependency referenced via ":name" or ":name{.tag}" syntax.
// If the dependency is not found, a missingErrorDependency is returned.
// If the module dependency is not a SourceFileProducer or OutputFileProducer, appropriate errors will be returned.
@@ -573,10 +565,6 @@
if aModule, ok := module.(Module); ok && !aModule.Enabled(ctx) {
return nil, missingDependencyError{[]string{moduleName}}
}
- if goBinary, ok := module.(bootstrap.GoBinaryTool); ok && tag == "" {
- goBinaryPath := PathForGoBinary(ctx, goBinary)
- return Paths{goBinaryPath}, nil
- }
outputFiles, err := outputFilesForModule(ctx, module, tag)
if outputFiles != nil && err == nil {
return outputFiles, nil