Simplify bootstrapping:
- Remove the bootstrap_go_binary module type in favor of blueprint_go_binary - Make it so that all the binaries used during bootstrapping are in the host tool directory so that the bootstrap and main Ninja files are consistent Test: Presubmits. Change-Id: I00744fec0474fbea89db6c0c0338856453138564
This commit is contained in:
parent
ce41c169b5
commit
ceb3c43f65
5 changed files with 23 additions and 53 deletions
|
@ -140,7 +140,7 @@ bootstrap_go_package {
|
|||
],
|
||||
}
|
||||
|
||||
bootstrap_go_binary {
|
||||
blueprint_go_binary {
|
||||
name: "bpglob",
|
||||
deps: ["blueprint-pathtools"],
|
||||
srcs: ["bootstrap/bpglob/bpglob.go"],
|
||||
|
@ -158,7 +158,7 @@ blueprint_go_binary {
|
|||
srcs: ["bpmodify/bpmodify.go"],
|
||||
}
|
||||
|
||||
bootstrap_go_binary {
|
||||
blueprint_go_binary {
|
||||
name: "gotestmain",
|
||||
srcs: ["gotestmain/gotestmain.go"],
|
||||
}
|
||||
|
@ -176,12 +176,12 @@ bootstrap_go_package {
|
|||
],
|
||||
}
|
||||
|
||||
bootstrap_go_binary {
|
||||
blueprint_go_binary {
|
||||
name: "gotestrunner",
|
||||
srcs: ["gotestrunner/gotestrunner.go"],
|
||||
}
|
||||
|
||||
bootstrap_go_binary {
|
||||
blueprint_go_binary {
|
||||
name: "loadplugins",
|
||||
srcs: ["loadplugins/loadplugins.go"],
|
||||
}
|
||||
|
|
|
@ -25,14 +25,12 @@ import (
|
|||
"github.com/google/blueprint/pathtools"
|
||||
)
|
||||
|
||||
const bootstrapSubDir = ".bootstrap"
|
||||
|
||||
var (
|
||||
pctx = blueprint.NewPackageContext("github.com/google/blueprint/bootstrap")
|
||||
|
||||
goTestMainCmd = pctx.StaticVariable("goTestMainCmd", filepath.Join(bootstrapDir, "bin", "gotestmain"))
|
||||
goTestRunnerCmd = pctx.StaticVariable("goTestRunnerCmd", filepath.Join(bootstrapDir, "bin", "gotestrunner"))
|
||||
pluginGenSrcCmd = pctx.StaticVariable("pluginGenSrcCmd", filepath.Join(bootstrapDir, "bin", "loadplugins"))
|
||||
goTestMainCmd = pctx.StaticVariable("goTestMainCmd", filepath.Join("$ToolDir", "gotestmain"))
|
||||
goTestRunnerCmd = pctx.StaticVariable("goTestRunnerCmd", filepath.Join("$ToolDir", "gotestrunner"))
|
||||
pluginGenSrcCmd = pctx.StaticVariable("pluginGenSrcCmd", filepath.Join("$ToolDir", "loadplugins"))
|
||||
|
||||
parallelCompile = pctx.StaticVariable("parallelCompile", func() string {
|
||||
// Parallel compilation is only supported on >= go1.9
|
||||
|
@ -151,15 +149,9 @@ var (
|
|||
},
|
||||
"depfile")
|
||||
|
||||
_ = pctx.VariableFunc("BinDir", func(config interface{}) (string, error) {
|
||||
return bootstrapBinDir(config), nil
|
||||
})
|
||||
|
||||
_ = pctx.VariableFunc("ToolDir", func(config interface{}) (string, error) {
|
||||
return toolDir(config), nil
|
||||
return config.(BootstrapConfig).HostToolDir(), nil
|
||||
})
|
||||
|
||||
bootstrapDir = filepath.Join("$soongOutDir", bootstrapSubDir)
|
||||
)
|
||||
|
||||
type GoBinaryTool interface {
|
||||
|
@ -169,17 +161,6 @@ type GoBinaryTool interface {
|
|||
isGoBinary()
|
||||
}
|
||||
|
||||
func bootstrapBinDir(config interface{}) string {
|
||||
return filepath.Join(config.(BootstrapConfig).SoongOutDir(), bootstrapSubDir, "bin")
|
||||
}
|
||||
|
||||
func toolDir(config interface{}) string {
|
||||
if c, ok := config.(ConfigBlueprintToolLocation); ok {
|
||||
return filepath.Join(c.BlueprintToolLocation())
|
||||
}
|
||||
return filepath.Join(config.(BootstrapConfig).SoongOutDir(), "bin")
|
||||
}
|
||||
|
||||
func pluginDeps(ctx blueprint.BottomUpMutatorContext) {
|
||||
if pkg, ok := ctx.Module().(*goPackage); ok {
|
||||
if ctx.PrimaryModule() == ctx.Module() {
|
||||
|
@ -444,13 +425,7 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
genSrcs = []string{}
|
||||
)
|
||||
|
||||
if g.properties.Tool_dir {
|
||||
g.installPath = filepath.Join(toolDir(ctx.Config()), name)
|
||||
} else {
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
g.installPath = filepath.Join(soongOutDir, bootstrapSubDir, "bin", name)
|
||||
}
|
||||
|
||||
g.installPath = filepath.Join(ctx.Config().(BootstrapConfig).HostToolDir(), name)
|
||||
ctx.VisitDepsDepthFirstIf(isGoPluginFor(name),
|
||||
func(module blueprint.Module) { hasPlugins = true })
|
||||
if hasPlugins {
|
||||
|
@ -728,7 +703,7 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
primaryBuilderName = ctx.ModuleName(primaryBuilders[0])
|
||||
}
|
||||
|
||||
primaryBuilderFile := filepath.Join("$BinDir", primaryBuilderName)
|
||||
primaryBuilderFile := filepath.Join("$ToolDir", primaryBuilderName)
|
||||
ctx.SetOutDir(pctx, "${outDir}")
|
||||
|
||||
for _, subninja := range s.config.subninjas {
|
||||
|
@ -776,16 +751,16 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
// directory is where the final package .a files are output and where dependant
|
||||
// modules search for this package via -I arguments.
|
||||
func packageRoot(ctx blueprint.ModuleContext) string {
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "pkg")
|
||||
toolDir := ctx.Config().(BootstrapConfig).HostToolDir()
|
||||
return filepath.Join(toolDir, "go", ctx.ModuleName(), "pkg")
|
||||
}
|
||||
|
||||
// testRoot returns the module-specific package root directory path used for
|
||||
// building tests. The .a files generated here will include everything from
|
||||
// packageRoot, plus the test-only code.
|
||||
func testRoot(ctx blueprint.ModuleContext) string {
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "test")
|
||||
toolDir := ctx.Config().(BootstrapConfig).HostToolDir()
|
||||
return filepath.Join(toolDir, "go", ctx.ModuleName(), "test")
|
||||
}
|
||||
|
||||
// moduleSrcDir returns the path of the directory that all source file paths are
|
||||
|
@ -796,12 +771,12 @@ func moduleSrcDir(ctx blueprint.ModuleContext) string {
|
|||
|
||||
// moduleObjDir returns the module-specific object directory path.
|
||||
func moduleObjDir(ctx blueprint.ModuleContext) string {
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "obj")
|
||||
toolDir := ctx.Config().(BootstrapConfig).HostToolDir()
|
||||
return filepath.Join(toolDir, "go", ctx.ModuleName(), "obj")
|
||||
}
|
||||
|
||||
// moduleGenSrcDir returns the module-specific generated sources path.
|
||||
func moduleGenSrcDir(ctx blueprint.ModuleContext) string {
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "gen")
|
||||
toolDir := ctx.Config().(BootstrapConfig).HostToolDir()
|
||||
return filepath.Join(toolDir, "go", ctx.ModuleName(), "gen")
|
||||
}
|
||||
|
|
|
@ -147,7 +147,6 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin
|
|||
|
||||
ctx.RegisterBottomUpMutator("bootstrap_plugin_deps", pluginDeps)
|
||||
ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory(bootstrapConfig))
|
||||
ctx.RegisterModuleType("bootstrap_go_binary", newGoBinaryModuleFactory(bootstrapConfig, false))
|
||||
ctx.RegisterModuleType("blueprint_go_binary", newGoBinaryModuleFactory(bootstrapConfig, true))
|
||||
ctx.RegisterSingletonType("bootstrap", newSingletonFactory(bootstrapConfig))
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ var (
|
|||
)
|
||||
|
||||
type BootstrapConfig interface {
|
||||
// The directory where tools run during the build are located.
|
||||
HostToolDir() string
|
||||
|
||||
// The directory where files emitted during bootstrapping are located.
|
||||
// Usually OutDir() + "/soong".
|
||||
SoongOutDir() string
|
||||
|
@ -95,13 +98,6 @@ type ConfigRemoveAbandonedFilesUnder interface {
|
|||
RemoveAbandonedFilesUnder(buildDir string) (under, except []string)
|
||||
}
|
||||
|
||||
type ConfigBlueprintToolLocation interface {
|
||||
// BlueprintToolLocation can return a path name to install blueprint tools
|
||||
// designed for end users (bpfmt, bpmodify, and anything else using
|
||||
// blueprint_go_binary).
|
||||
BlueprintToolLocation() string
|
||||
}
|
||||
|
||||
type StopBefore int
|
||||
|
||||
const (
|
||||
|
|
|
@ -44,7 +44,7 @@ import (
|
|||
// in a build failure with a "missing and no known rule to make it" error.
|
||||
|
||||
var (
|
||||
globCmd = filepath.Join(bootstrapDir, "bpglob")
|
||||
globCmd = filepath.Join("$ToolDir", "bpglob")
|
||||
|
||||
// globRule rule traverses directories to produce a list of files that match $glob
|
||||
// and writes it to $out if it has changed, and writes the directories to $out.d
|
||||
|
@ -168,7 +168,7 @@ func globBucketName(globDir string, globBucket int) string {
|
|||
|
||||
// Returns the directory where glob list files live
|
||||
func GlobDirectory(buildDir, globListDir string) string {
|
||||
return filepath.Join(buildDir, bootstrapSubDir, globListDir)
|
||||
return filepath.Join(buildDir, "globs", globListDir)
|
||||
}
|
||||
|
||||
func (s *GlobSingleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
||||
|
|
Loading…
Reference in a new issue