Remove the bootstrap.Config class. am: d782b504e0
am: cf5b271af2
am: cd0ca27287
am: 385732a99e
Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/1817976 Change-Id: I46f769097a829c83a21cb5c10cbf2c3dab3f48c8
This commit is contained in:
commit
cf0779c393
3 changed files with 28 additions and 71 deletions
|
@ -236,18 +236,13 @@ type goPackage struct {
|
|||
|
||||
// The path of the test result file.
|
||||
testResultFile []string
|
||||
|
||||
// The bootstrap Config
|
||||
config *Config
|
||||
}
|
||||
|
||||
var _ goPackageProducer = (*goPackage)(nil)
|
||||
|
||||
func newGoPackageModuleFactory(config *Config) func() (blueprint.Module, []interface{}) {
|
||||
func newGoPackageModuleFactory() func() (blueprint.Module, []interface{}) {
|
||||
return func() (blueprint.Module, []interface{}) {
|
||||
module := &goPackage{
|
||||
config: config,
|
||||
}
|
||||
module := &goPackage{}
|
||||
return module, []interface{}{&module.properties, &module.SimpleName.Properties}
|
||||
}
|
||||
}
|
||||
|
@ -331,12 +326,11 @@ func (g *goPackage) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
testSrcs = append(g.properties.TestSrcs, g.properties.Linux.TestSrcs...)
|
||||
}
|
||||
|
||||
if g.config.runGoTests {
|
||||
if ctx.Config().(BootstrapConfig).RunGoTests() {
|
||||
testArchiveFile := filepath.Join(testRoot(ctx),
|
||||
filepath.FromSlash(g.properties.PkgPath)+".a")
|
||||
g.testResultFile = buildGoTest(ctx, testRoot(ctx), testArchiveFile,
|
||||
g.properties.PkgPath, srcs, genSrcs,
|
||||
testSrcs, g.config.useValidations)
|
||||
g.properties.PkgPath, srcs, genSrcs, testSrcs)
|
||||
}
|
||||
|
||||
// Don't build for test-only packages
|
||||
|
@ -371,24 +365,16 @@ type goBinary struct {
|
|||
Srcs []string
|
||||
TestSrcs []string
|
||||
}
|
||||
|
||||
Tool_dir bool `blueprint:"mutated"`
|
||||
}
|
||||
|
||||
installPath string
|
||||
|
||||
// The bootstrap Config
|
||||
config *Config
|
||||
}
|
||||
|
||||
var _ GoBinaryTool = (*goBinary)(nil)
|
||||
|
||||
func newGoBinaryModuleFactory(config *Config, tooldir bool) func() (blueprint.Module, []interface{}) {
|
||||
func newGoBinaryModuleFactory() func() (blueprint.Module, []interface{}) {
|
||||
return func() (blueprint.Module, []interface{}) {
|
||||
module := &goBinary{
|
||||
config: config,
|
||||
}
|
||||
module.properties.Tool_dir = tooldir
|
||||
module := &goBinary{}
|
||||
return module, []interface{}{&module.properties, &module.SimpleName.Properties}
|
||||
}
|
||||
}
|
||||
|
@ -448,9 +434,9 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
testSrcs = append(g.properties.TestSrcs, g.properties.Linux.TestSrcs...)
|
||||
}
|
||||
|
||||
if g.config.runGoTests {
|
||||
if ctx.Config().(BootstrapConfig).RunGoTests() {
|
||||
testDeps = buildGoTest(ctx, testRoot(ctx), testArchiveFile,
|
||||
name, srcs, genSrcs, testSrcs, g.config.useValidations)
|
||||
name, srcs, genSrcs, testSrcs)
|
||||
}
|
||||
|
||||
buildGoPackage(ctx, objDir, "main", archiveFile, srcs, genSrcs)
|
||||
|
@ -481,7 +467,7 @@ func (g *goBinary) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||
})
|
||||
|
||||
var orderOnlyDeps, validationDeps []string
|
||||
if g.config.useValidations {
|
||||
if ctx.Config().(BootstrapConfig).UseValidationsForGoTests() {
|
||||
validationDeps = testDeps
|
||||
} else {
|
||||
orderOnlyDeps = testDeps
|
||||
|
@ -558,7 +544,7 @@ func buildGoPackage(ctx blueprint.ModuleContext, pkgRoot string,
|
|||
}
|
||||
|
||||
func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive,
|
||||
pkgPath string, srcs, genSrcs, testSrcs []string, useValidations bool) []string {
|
||||
pkgPath string, srcs, genSrcs, testSrcs []string) []string {
|
||||
|
||||
if len(testSrcs) == 0 {
|
||||
return nil
|
||||
|
@ -621,7 +607,7 @@ func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive,
|
|||
})
|
||||
|
||||
var orderOnlyDeps, validationDeps []string
|
||||
if useValidations {
|
||||
if ctx.Config().(BootstrapConfig).UseValidationsForGoTests() {
|
||||
validationDeps = testDeps
|
||||
} else {
|
||||
orderOnlyDeps = testDeps
|
||||
|
@ -644,15 +630,11 @@ func buildGoTest(ctx blueprint.ModuleContext, testRoot, testPkgArchive,
|
|||
}
|
||||
|
||||
type singleton struct {
|
||||
// The bootstrap Config
|
||||
config *Config
|
||||
}
|
||||
|
||||
func newSingletonFactory(config *Config) func() blueprint.Singleton {
|
||||
func newSingletonFactory() func() blueprint.Singleton {
|
||||
return func() blueprint.Singleton {
|
||||
return &singleton{
|
||||
config: config,
|
||||
}
|
||||
return &singleton{}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,9 +651,7 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
func(module blueprint.Module) {
|
||||
if ctx.PrimaryModule(module) == module {
|
||||
if binaryModule, ok := module.(*goBinary); ok {
|
||||
if binaryModule.properties.Tool_dir {
|
||||
blueprintTools = append(blueprintTools, binaryModule.InstallPath())
|
||||
}
|
||||
blueprintTools = append(blueprintTools, binaryModule.InstallPath())
|
||||
if binaryModule.properties.PrimaryBuilder {
|
||||
primaryBuilders = append(primaryBuilders, binaryModule)
|
||||
}
|
||||
|
@ -706,11 +686,11 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) {
|
|||
primaryBuilderFile := filepath.Join("$ToolDir", primaryBuilderName)
|
||||
ctx.SetOutDir(pctx, "${outDir}")
|
||||
|
||||
for _, subninja := range s.config.subninjas {
|
||||
for _, subninja := range ctx.Config().(BootstrapConfig).Subninjas() {
|
||||
ctx.AddSubninja(subninja)
|
||||
}
|
||||
|
||||
for _, i := range s.config.primaryBuilderInvocations {
|
||||
for _, i := range ctx.Config().(BootstrapConfig).PrimaryBuilderInvocations() {
|
||||
flags := make([]string, 0)
|
||||
flags = append(flags, primaryBuilderCmdlinePrefix...)
|
||||
flags = append(flags, i.Args...)
|
||||
|
|
|
@ -122,33 +122,10 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin
|
|||
|
||||
soongOutDir := config.(BootstrapConfig).SoongOutDir()
|
||||
|
||||
mainNinjaFile := filepath.Join("$soongOutDir", "build.ninja")
|
||||
|
||||
var invocations []PrimaryBuilderInvocation
|
||||
|
||||
if args.PrimaryBuilderInvocations != nil {
|
||||
invocations = args.PrimaryBuilderInvocations
|
||||
} else {
|
||||
primaryBuilderArgs := PrimaryBuilderExtraFlags(args, mainNinjaFile)
|
||||
|
||||
invocations = []PrimaryBuilderInvocation{{
|
||||
Inputs: []string{},
|
||||
Outputs: []string{mainNinjaFile},
|
||||
Args: primaryBuilderArgs,
|
||||
}}
|
||||
}
|
||||
|
||||
bootstrapConfig := &Config{
|
||||
subninjas: args.Subninjas,
|
||||
runGoTests: args.RunGoTests,
|
||||
useValidations: args.UseValidations,
|
||||
primaryBuilderInvocations: invocations,
|
||||
}
|
||||
|
||||
ctx.RegisterBottomUpMutator("bootstrap_plugin_deps", pluginDeps)
|
||||
ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory(bootstrapConfig))
|
||||
ctx.RegisterModuleType("blueprint_go_binary", newGoBinaryModuleFactory(bootstrapConfig, true))
|
||||
ctx.RegisterSingletonType("bootstrap", newSingletonFactory(bootstrapConfig))
|
||||
ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory())
|
||||
ctx.RegisterModuleType("blueprint_go_binary", newGoBinaryModuleFactory())
|
||||
ctx.RegisterSingletonType("bootstrap", newSingletonFactory())
|
||||
|
||||
blueprintFiles, errs := ctx.ParseFileList(".", filesToParse, config)
|
||||
if len(errs) > 0 {
|
||||
|
|
|
@ -88,6 +88,15 @@ type BootstrapConfig interface {
|
|||
|
||||
// Whether to compile Go code in such a way that it can be debugged
|
||||
DebugCompilation() bool
|
||||
|
||||
// Whether to run tests for Go code
|
||||
RunGoTests() bool
|
||||
|
||||
// Whether to use Ninja validations for running Go tests
|
||||
UseValidationsForGoTests() bool
|
||||
|
||||
Subninjas() []string
|
||||
PrimaryBuilderInvocations() []PrimaryBuilderInvocation
|
||||
}
|
||||
|
||||
type ConfigRemoveAbandonedFilesUnder interface {
|
||||
|
@ -114,12 +123,3 @@ type PrimaryBuilderInvocation struct {
|
|||
Outputs []string
|
||||
Args []string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
subninjas []string
|
||||
|
||||
runGoTests bool
|
||||
useValidations bool
|
||||
|
||||
primaryBuilderInvocations []PrimaryBuilderInvocation
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue