Merge remote-tracking branch 'aosp/upstream' into master am: 6c5a2f7288 am: 247a72401f

am: eedba6251b

Change-Id: I4b1516dbbfa47ebb334c8a7d7fcbc4f84dbb7ed4
This commit is contained in:
Colin Cross 2019-10-17 19:22:54 -07:00 committed by android-build-merger
commit 9a5267262a

View file

@ -27,6 +27,7 @@ import (
"github.com/google/blueprint/pathtools"
)
const mainSubDir = ".primary"
const bootstrapSubDir = ".bootstrap"
const miniBootstrapSubDir = ".minibootstrap"
@ -143,15 +144,16 @@ var (
"depfile")
_ = pctx.VariableFunc("BinDir", func(config interface{}) (string, error) {
return binDir(), nil
return bootstrapBinDir(), nil
})
_ = pctx.VariableFunc("ToolDir", func(config interface{}) (string, error) {
return toolDir(config), nil
})
docsDir = filepath.Join(bootstrapDir, "docs")
docsDir = filepath.Join(mainDir, "docs")
mainDir = filepath.Join("$buildDir", mainSubDir)
bootstrapDir = filepath.Join("$buildDir", bootstrapSubDir)
miniBootstrapDir = filepath.Join("$buildDir", miniBootstrapSubDir)
@ -165,7 +167,7 @@ type GoBinaryTool interface {
isGoBinary()
}
func binDir() string {
func bootstrapBinDir() string {
return filepath.Join(BuildDir, bootstrapSubDir, "bin")
}
@ -307,14 +309,14 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
return
}
g.pkgRoot = packageRoot(ctx)
g.pkgRoot = packageRoot(ctx, g.config)
g.archiveFile = filepath.Join(g.pkgRoot,
filepath.FromSlash(g.properties.PkgPath)+".a")
ctx.VisitDepsDepthFirstIf(isGoPluginFor(name),
func(module blueprint.Module) { hasPlugins = true })
if hasPlugins {
pluginSrc = filepath.Join(moduleGenSrcDir(ctx), "plugin.go")
pluginSrc = filepath.Join(moduleGenSrcDir(ctx, g.config), "plugin.go")
genSrcs = append(genSrcs, pluginSrc)
}
@ -332,9 +334,9 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
}
if g.config.runGoTests {
testArchiveFile := filepath.Join(testRoot(ctx),
testArchiveFile := filepath.Join(testRoot(ctx, g.config),
filepath.FromSlash(g.properties.PkgPath)+".a")
g.testResultFile = buildGoTest(ctx, testRoot(ctx), testArchiveFile,
g.testResultFile = buildGoTest(ctx, testRoot(ctx, g.config), testArchiveFile,
g.properties.PkgPath, srcs, genSrcs,
testSrcs)
}
@ -395,9 +397,9 @@ func (g *goBinary) InstallPath() string {
func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
var (
name = ctx.ModuleName()
objDir = moduleObjDir(ctx)
objDir = moduleObjDir(ctx, g.config)
archiveFile = filepath.Join(objDir, name+".a")
testArchiveFile = filepath.Join(testRoot(ctx), name+".a")
testArchiveFile = filepath.Join(testRoot(ctx, g.config), name+".a")
aoutFile = filepath.Join(objDir, "a.out")
hasPlugins = false
pluginSrc = ""
@ -406,14 +408,16 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
if g.properties.Tool_dir {
g.installPath = filepath.Join(toolDir(ctx.Config()), name)
} else if g.config.stage == StageMain {
g.installPath = filepath.Join(mainDir, "bin", name)
} else {
g.installPath = filepath.Join(binDir(), name)
g.installPath = filepath.Join(bootstrapDir, "bin", name)
}
ctx.VisitDepsDepthFirstIf(isGoPluginFor(name),
func(module blueprint.Module) { hasPlugins = true })
if hasPlugins {
pluginSrc = filepath.Join(moduleGenSrcDir(ctx), "plugin.go")
pluginSrc = filepath.Join(moduleGenSrcDir(ctx, g.config), "plugin.go")
genSrcs = append(genSrcs, pluginSrc)
}
@ -433,7 +437,7 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
}
if g.config.runGoTests {
deps = buildGoTest(ctx, testRoot(ctx), testArchiveFile,
deps = buildGoTest(ctx, testRoot(ctx, g.config), testArchiveFile,
name, srcs, genSrcs, testSrcs)
}
@ -758,18 +762,26 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
}
}
func stageDir(config *Config) string {
if config.stage == StageMain {
return mainDir
} else {
return bootstrapDir
}
}
// packageRoot returns the module-specific package root directory path. This
// 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 {
return filepath.Join(bootstrapDir, ctx.ModuleName(), "pkg")
func packageRoot(ctx blueprint.ModuleContext, config *Config) string {
return filepath.Join(stageDir(config), 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 {
return filepath.Join(bootstrapDir, ctx.ModuleName(), "test")
func testRoot(ctx blueprint.ModuleContext, config *Config) string {
return filepath.Join(stageDir(config), ctx.ModuleName(), "test")
}
// moduleSrcDir returns the path of the directory that all source file paths are
@ -779,11 +791,11 @@ func moduleSrcDir(ctx blueprint.ModuleContext) string {
}
// moduleObjDir returns the module-specific object directory path.
func moduleObjDir(ctx blueprint.ModuleContext) string {
return filepath.Join(bootstrapDir, ctx.ModuleName(), "obj")
func moduleObjDir(ctx blueprint.ModuleContext, config *Config) string {
return filepath.Join(stageDir(config), ctx.ModuleName(), "obj")
}
// moduleGenSrcDir returns the module-specific generated sources path.
func moduleGenSrcDir(ctx blueprint.ModuleContext) string {
return filepath.Join(bootstrapDir, ctx.ModuleName(), "gen")
func moduleGenSrcDir(ctx blueprint.ModuleContext, config *Config) string {
return filepath.Join(stageDir(config), ctx.ModuleName(), "gen")
}