Rename BuildDir and NinjaBuildDir.
These are just out/ and out/soong/ and the old names were quite confusing. Test: Presubmits. Change-Id: Idd9ce3c38a259faabcc56f0cd3fdac8b289123b1
This commit is contained in:
parent
b773e4fb03
commit
843db40eea
6 changed files with 52 additions and 52 deletions
|
@ -106,7 +106,7 @@ var (
|
|||
|
||||
bootstrap = pctx.StaticRule("bootstrap",
|
||||
blueprint.RuleParams{
|
||||
Command: "BUILDDIR=$buildDir $bootstrapCmd -i $in",
|
||||
Command: "BUILDDIR=$soongOutDir $bootstrapCmd -i $in",
|
||||
CommandDeps: []string{"$bootstrapCmd"},
|
||||
Description: "bootstrap $in",
|
||||
Generator: true,
|
||||
|
@ -131,8 +131,8 @@ var (
|
|||
`cd / && ` +
|
||||
`env -i "$$BUILDER" ` +
|
||||
` --top "$$TOP" ` +
|
||||
` --out "$buildDir" ` +
|
||||
` -n "$ninjaBuildDir" ` +
|
||||
` --out "$soongOutDir" ` +
|
||||
` -n "$outDir" ` +
|
||||
` -d "$out.d" ` +
|
||||
` $extra`,
|
||||
CommandDeps: []string{"$builder"},
|
||||
|
@ -160,7 +160,7 @@ var (
|
|||
return toolDir(config), nil
|
||||
})
|
||||
|
||||
bootstrapDir = filepath.Join("$buildDir", bootstrapSubDir)
|
||||
bootstrapDir = filepath.Join("$soongOutDir", bootstrapSubDir)
|
||||
)
|
||||
|
||||
type GoBinaryTool interface {
|
||||
|
@ -171,14 +171,14 @@ type GoBinaryTool interface {
|
|||
}
|
||||
|
||||
func bootstrapBinDir(config interface{}) string {
|
||||
return filepath.Join(config.(BootstrapConfig).BuildDir(), bootstrapSubDir, "bin")
|
||||
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).BuildDir(), "bin")
|
||||
return filepath.Join(config.(BootstrapConfig).SoongOutDir(), "bin")
|
||||
}
|
||||
|
||||
func pluginDeps(ctx blueprint.BottomUpMutatorContext) {
|
||||
|
@ -334,7 +334,7 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
ctx.VisitDepsDepthFirstIf(isGoPluginFor(name),
|
||||
func(module blueprint.Module) { hasPlugins = true })
|
||||
if hasPlugins {
|
||||
pluginSrc = filepath.Join(moduleGenSrcDir(ctx, g.config), "plugin.go")
|
||||
pluginSrc = filepath.Join(moduleGenSrcDir(ctx), "plugin.go")
|
||||
genSrcs = append(genSrcs, pluginSrc)
|
||||
}
|
||||
|
||||
|
@ -448,14 +448,14 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
if g.properties.Tool_dir {
|
||||
g.installPath = filepath.Join(toolDir(ctx.Config()), name)
|
||||
} else {
|
||||
buildDir := ctx.Config().(BootstrapConfig).BuildDir()
|
||||
g.installPath = filepath.Join(buildDir, bootstrapSubDir, "bin", name)
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
g.installPath = filepath.Join(soongOutDir, bootstrapSubDir, "bin", name)
|
||||
}
|
||||
|
||||
ctx.VisitDepsDepthFirstIf(isGoPluginFor(name),
|
||||
func(module blueprint.Module) { hasPlugins = true })
|
||||
if hasPlugins {
|
||||
pluginSrc = filepath.Join(moduleGenSrcDir(ctx, g.config), "plugin.go")
|
||||
pluginSrc = filepath.Join(moduleGenSrcDir(ctx), "plugin.go")
|
||||
genSrcs = append(genSrcs, pluginSrc)
|
||||
}
|
||||
|
||||
|
@ -730,7 +730,7 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
}
|
||||
|
||||
primaryBuilderFile := filepath.Join("$BinDir", primaryBuilderName)
|
||||
ctx.SetNinjaBuildDir(pctx, "${ninjaBuildDir}")
|
||||
ctx.SetOutDir(pctx, "${outDir}")
|
||||
|
||||
for _, subninja := range s.config.subninjas {
|
||||
ctx.AddSubninja(subninja)
|
||||
|
@ -781,16 +781,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 {
|
||||
buildDir := ctx.Config().(BootstrapConfig).BuildDir()
|
||||
return filepath.Join(buildDir, bootstrapSubDir, ctx.ModuleName(), "pkg")
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, 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 {
|
||||
buildDir := ctx.Config().(BootstrapConfig).BuildDir()
|
||||
return filepath.Join(buildDir, bootstrapSubDir, ctx.ModuleName(), "test")
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "test")
|
||||
}
|
||||
|
||||
// moduleSrcDir returns the path of the directory that all source file paths are
|
||||
|
@ -801,12 +801,12 @@ func moduleSrcDir(ctx blueprint.ModuleContext) string {
|
|||
|
||||
// moduleObjDir returns the module-specific object directory path.
|
||||
func moduleObjDir(ctx blueprint.ModuleContext) string {
|
||||
buildDir := ctx.Config().(BootstrapConfig).BuildDir()
|
||||
return filepath.Join(buildDir, bootstrapSubDir, ctx.ModuleName(), "obj")
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "obj")
|
||||
}
|
||||
|
||||
// moduleGenSrcDir returns the module-specific generated sources path.
|
||||
func moduleGenSrcDir(ctx blueprint.ModuleContext, config *Config) string {
|
||||
buildDir := ctx.Config().(BootstrapConfig).BuildDir()
|
||||
return filepath.Join(buildDir, bootstrapSubDir, ctx.ModuleName(), "gen")
|
||||
func moduleGenSrcDir(ctx blueprint.ModuleContext) string {
|
||||
soongOutDir := ctx.Config().(BootstrapConfig).SoongOutDir()
|
||||
return filepath.Join(soongOutDir, bootstrapSubDir, ctx.ModuleName(), "gen")
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func removeAbandonedFilesUnder(ctx *blueprint.Context,
|
|||
return nil
|
||||
}
|
||||
|
||||
ninjaBuildDir, err := ctx.NinjaBuildDir()
|
||||
outDir, err := ctx.OutDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func removeAbandonedFilesUnder(ctx *blueprint.Context,
|
|||
replacer := strings.NewReplacer(
|
||||
"@@SrcDir@@", srcDir,
|
||||
"@@BuildDir@@", buildDir)
|
||||
ninjaBuildDir = replacer.Replace(ninjaBuildDir)
|
||||
outDir = replacer.Replace(outDir)
|
||||
targets := make(map[string]bool)
|
||||
for target := range targetRules {
|
||||
replacedTarget := replacer.Replace(target)
|
||||
|
@ -62,7 +62,7 @@ func removeAbandonedFilesUnder(ctx *blueprint.Context,
|
|||
targets[filepath.Clean(replacedTarget)] = true
|
||||
}
|
||||
|
||||
filePaths, err := parseNinjaLog(ninjaBuildDir, under)
|
||||
filePaths, err := parseNinjaLog(outDir, under)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ func removeAbandonedFilesUnder(ctx *blueprint.Context,
|
|||
return nil
|
||||
}
|
||||
|
||||
func parseNinjaLog(ninjaBuildDir string, under []string) ([]string, error) {
|
||||
logFilePath := filepath.Join(ninjaBuildDir, logFileName)
|
||||
func parseNinjaLog(outDir string, under []string) ([]string, error) {
|
||||
logFilePath := filepath.Join(outDir, logFileName)
|
||||
logFile, err := os.Open(logFilePath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
|
|
@ -121,14 +121,14 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin
|
|||
fatalf("could not enumerate files: %v\n", err.Error())
|
||||
}
|
||||
|
||||
buildDir := config.(BootstrapConfig).BuildDir()
|
||||
soongOutDir := config.(BootstrapConfig).SoongOutDir()
|
||||
|
||||
stage := StageMain
|
||||
if args.GeneratingPrimaryBuilder {
|
||||
stage = StagePrimary
|
||||
}
|
||||
|
||||
mainNinjaFile := filepath.Join("$buildDir", "build.ninja")
|
||||
mainNinjaFile := filepath.Join("$soongOutDir", "build.ninja")
|
||||
|
||||
var invocations []PrimaryBuilderInvocation
|
||||
|
||||
|
@ -235,8 +235,8 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin
|
|||
}
|
||||
|
||||
if c, ok := config.(ConfigRemoveAbandonedFilesUnder); ok {
|
||||
under, except := c.RemoveAbandonedFilesUnder(buildDir)
|
||||
err := removeAbandonedFilesUnder(ctx, srcDir, buildDir, under, except)
|
||||
under, except := c.RemoveAbandonedFilesUnder(soongOutDir)
|
||||
err := removeAbandonedFilesUnder(ctx, srcDir, soongOutDir, under, except)
|
||||
if err != nil {
|
||||
fatalf("error removing abandoned files: %s", err)
|
||||
}
|
||||
|
|
|
@ -41,11 +41,11 @@ var (
|
|||
srcDirVariable = bootstrapVariable("srcDir", func(c BootstrapConfig) string {
|
||||
return "."
|
||||
})
|
||||
buildDirVariable = bootstrapVariable("buildDir", func(c BootstrapConfig) string {
|
||||
return c.BuildDir()
|
||||
soongOutDirVariable = bootstrapVariable("soongOutDir", func(c BootstrapConfig) string {
|
||||
return c.SoongOutDir()
|
||||
})
|
||||
ninjaBuildDirVariable = bootstrapVariable("ninjaBuildDir", func(c BootstrapConfig) string {
|
||||
return c.NinjaBuildDir()
|
||||
outDirVariable = bootstrapVariable("outDir", func(c BootstrapConfig) string {
|
||||
return c.OutDir()
|
||||
})
|
||||
goRootVariable = bootstrapVariable("goRoot", func(c BootstrapConfig) string {
|
||||
goroot := runtime.GOROOT()
|
||||
|
@ -77,11 +77,11 @@ var (
|
|||
|
||||
type BootstrapConfig interface {
|
||||
// The directory where files emitted during bootstrapping are located.
|
||||
// Usually NinjaBuildDir() + "/soong".
|
||||
BuildDir() string
|
||||
// Usually OutDir() + "/soong".
|
||||
SoongOutDir() string
|
||||
|
||||
// The output directory for the build.
|
||||
NinjaBuildDir() string
|
||||
OutDir() string
|
||||
|
||||
// Whether to compile Go code in such a way that it can be debugged
|
||||
DebugCompilation() bool
|
||||
|
|
24
context.go
24
context.go
|
@ -102,7 +102,7 @@ type Context struct {
|
|||
globalRules map[Rule]*ruleDef
|
||||
|
||||
// set during PrepareBuildActions
|
||||
ninjaBuildDir ninjaString // The builddir special Ninja variable
|
||||
outDir ninjaString // The builddir special Ninja variable
|
||||
requiredNinjaMajor int // For the ninja_required_version variable
|
||||
requiredNinjaMinor int // For the ninja_required_version variable
|
||||
requiredNinjaMicro int // For the ninja_required_version variable
|
||||
|
@ -388,7 +388,7 @@ func newContext() *Context {
|
|||
globs: make(map[globKey]pathtools.GlobResult),
|
||||
fs: pathtools.OsFs,
|
||||
finishedMutators: make(map[*mutatorInfo]bool),
|
||||
ninjaBuildDir: nil,
|
||||
outDir: nil,
|
||||
requiredNinjaMajor: 1,
|
||||
requiredNinjaMinor: 7,
|
||||
requiredNinjaMicro: 0,
|
||||
|
@ -2392,8 +2392,8 @@ func (c *Context) PrepareBuildActions(config interface{}) (deps []string, errs [
|
|||
deps = append(deps, depsModules...)
|
||||
deps = append(deps, depsSingletons...)
|
||||
|
||||
if c.ninjaBuildDir != nil {
|
||||
err := c.liveGlobals.addNinjaStringDeps(c.ninjaBuildDir)
|
||||
if c.outDir != nil {
|
||||
err := c.liveGlobals.addNinjaStringDeps(c.outDir)
|
||||
if err != nil {
|
||||
errs = []error{err}
|
||||
return
|
||||
|
@ -3205,9 +3205,9 @@ func (c *Context) requireNinjaVersion(major, minor, micro int) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *Context) setNinjaBuildDir(value ninjaString) {
|
||||
if c.ninjaBuildDir == nil {
|
||||
c.ninjaBuildDir = value
|
||||
func (c *Context) setOutDir(value ninjaString) {
|
||||
if c.outDir == nil {
|
||||
c.outDir = value
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3399,9 +3399,9 @@ func (c *Context) AllTargets() (map[string]string, error) {
|
|||
return targets, nil
|
||||
}
|
||||
|
||||
func (c *Context) NinjaBuildDir() (string, error) {
|
||||
if c.ninjaBuildDir != nil {
|
||||
return c.ninjaBuildDir.Eval(c.globalVariables)
|
||||
func (c *Context) OutDir() (string, error) {
|
||||
if c.outDir != nil {
|
||||
return c.outDir.Eval(c.globalVariables)
|
||||
} else {
|
||||
return "", nil
|
||||
}
|
||||
|
@ -3751,8 +3751,8 @@ func (c *Context) writeSubninjas(nw *ninjaWriter) error {
|
|||
}
|
||||
|
||||
func (c *Context) writeBuildDir(nw *ninjaWriter) error {
|
||||
if c.ninjaBuildDir != nil {
|
||||
err := nw.Assign("builddir", c.ninjaBuildDir.Value(c.pkgNames))
|
||||
if c.outDir != nil {
|
||||
err := nw.Assign("builddir", c.outDir.Value(c.pkgNames))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -82,10 +82,10 @@ type SingletonContext interface {
|
|||
// RequireNinjaVersion sets the generated ninja manifest to require at least the specified version of ninja.
|
||||
RequireNinjaVersion(major, minor, micro int)
|
||||
|
||||
// SetNinjaBuildDir sets the value of the top-level "builddir" Ninja variable
|
||||
// SetOutDir sets the value of the top-level "builddir" Ninja variable
|
||||
// that controls where Ninja stores its build log files. This value can be
|
||||
// set at most one time for a single build, later calls are ignored.
|
||||
SetNinjaBuildDir(pctx PackageContext, value string)
|
||||
SetOutDir(pctx PackageContext, value string)
|
||||
|
||||
// AddSubninja adds a ninja file to include with subninja. This should likely
|
||||
// only ever be used inside bootstrap to handle glob rules.
|
||||
|
@ -289,7 +289,7 @@ func (s *singletonContext) RequireNinjaVersion(major, minor, micro int) {
|
|||
s.context.requireNinjaVersion(major, minor, micro)
|
||||
}
|
||||
|
||||
func (s *singletonContext) SetNinjaBuildDir(pctx PackageContext, value string) {
|
||||
func (s *singletonContext) SetOutDir(pctx PackageContext, value string) {
|
||||
s.scope.ReparentTo(pctx)
|
||||
|
||||
ninjaValue, err := parseNinjaString(s.scope, value)
|
||||
|
@ -297,7 +297,7 @@ func (s *singletonContext) SetNinjaBuildDir(pctx PackageContext, value string) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
s.context.setNinjaBuildDir(ninjaValue)
|
||||
s.context.setOutDir(ninjaValue)
|
||||
}
|
||||
|
||||
func (s *singletonContext) AddSubninja(file string) {
|
||||
|
|
Loading…
Reference in a new issue