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