diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index a7818ab..035e884 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -735,45 +735,41 @@ func (s *singleton) GenerateBuildActions(ctx blueprint.SingletonContext) { ctx.AddSubninja(subninja) } - if s.config.stage == StagePrimary { - for _, i := range s.config.primaryBuilderInvocations { - flags := make([]string, 0) - flags = append(flags, primaryBuilderCmdlinePrefix...) - flags = append(flags, i.Args...) + for _, i := range s.config.primaryBuilderInvocations { + flags := make([]string, 0) + flags = append(flags, primaryBuilderCmdlinePrefix...) + flags = append(flags, i.Args...) - // Build the main build.ninja - ctx.Build(pctx, blueprint.BuildParams{ - Rule: generateBuildNinja, - Outputs: i.Outputs, - Inputs: i.Inputs, - Args: map[string]string{ - "builder": primaryBuilderFile, - "extra": strings.Join(flags, " "), - }, - // soong_ui explicitly requests what it wants to be build. This is - // because the same Ninja file contains instructions to run - // soong_build, run bp2build and to generate the JSON module graph. - Optional: true, - }) - } - } - - if s.config.stage == StageMain { - // Add a phony target for building various tools that are part of blueprint + // Build the main build.ninja ctx.Build(pctx, blueprint.BuildParams{ - Rule: blueprint.Phony, - Outputs: []string{"blueprint_tools"}, - Inputs: blueprintTools, - }) - - // Add a phony target for running go tests - ctx.Build(pctx, blueprint.BuildParams{ - Rule: blueprint.Phony, - Outputs: []string{"blueprint_go_packages"}, - Inputs: blueprintGoPackages, + Rule: generateBuildNinja, + Outputs: i.Outputs, + Inputs: i.Inputs, + Args: map[string]string{ + "builder": primaryBuilderFile, + "extra": strings.Join(flags, " "), + }, + // soong_ui explicitly requests what it wants to be build. This is + // because the same Ninja file contains instructions to run + // soong_build, run bp2build and to generate the JSON module graph. Optional: true, }) } + + // Add a phony target for building various tools that are part of blueprint + ctx.Build(pctx, blueprint.BuildParams{ + Rule: blueprint.Phony, + Outputs: []string{"blueprint_tools"}, + Inputs: blueprintTools, + }) + + // Add a phony target for running go tests + ctx.Build(pctx, blueprint.BuildParams{ + Rule: blueprint.Phony, + Outputs: []string{"blueprint_go_packages"}, + Inputs: blueprintGoPackages, + Optional: true, + }) } // packageRoot returns the module-specific package root directory path. This diff --git a/bootstrap/command.go b/bootstrap/command.go index dd8367d..228a0cc 100644 --- a/bootstrap/command.go +++ b/bootstrap/command.go @@ -30,24 +30,24 @@ import ( ) type Args struct { - OutFile string - Subninjas []string - Cpuprofile string - Memprofile string - DelveListen string - DelvePath string - TraceFile string - RunGoTests bool - UseValidations bool - NoGC bool - EmptyNinjaFile bool - BuildDir string - ModuleListFile string - NinjaBuildDir string - TopFile string - GeneratingPrimaryBuilder bool + ModuleListFile string + OutDir string + SoongOutDir string + OutFile string + Subninjas []string PrimaryBuilderInvocations []PrimaryBuilderInvocation + + RunGoTests bool + UseValidations bool + EmptyNinjaFile bool + + NoGC bool + Cpuprofile string + Memprofile string + DelveListen string + DelvePath string + TraceFile string } func PrimaryBuilderExtraFlags(args Args, mainNinjaFile string) []string { @@ -105,7 +105,7 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin defer trace.Stop() } - srcDir := filepath.Dir(args.TopFile) + srcDir := "." ninjaDeps := make([]string, 0) @@ -122,11 +122,6 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin soongOutDir := config.(BootstrapConfig).SoongOutDir() - stage := StageMain - if args.GeneratingPrimaryBuilder { - stage = StagePrimary - } - mainNinjaFile := filepath.Join("$soongOutDir", "build.ninja") var invocations []PrimaryBuilderInvocation @@ -135,19 +130,15 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin invocations = args.PrimaryBuilderInvocations } else { primaryBuilderArgs := PrimaryBuilderExtraFlags(args, mainNinjaFile) - primaryBuilderArgs = append(primaryBuilderArgs, args.TopFile) invocations = []PrimaryBuilderInvocation{{ - Inputs: []string{args.TopFile}, + Inputs: []string{}, Outputs: []string{mainNinjaFile}, Args: primaryBuilderArgs, }} } bootstrapConfig := &Config{ - stage: stage, - - topLevelBlueprintsFile: args.TopFile, subninjas: args.Subninjas, runGoTests: args.RunGoTests, useValidations: args.UseValidations, @@ -160,7 +151,7 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin ctx.RegisterModuleType("blueprint_go_binary", newGoBinaryModuleFactory(bootstrapConfig, true)) ctx.RegisterSingletonType("bootstrap", newSingletonFactory(bootstrapConfig)) - blueprintFiles, errs := ctx.ParseFileList(filepath.Dir(args.TopFile), filesToParse, config) + blueprintFiles, errs := ctx.ParseFileList(".", filesToParse, config) if len(errs) > 0 { fatalErrors(errs) } @@ -203,7 +194,7 @@ func RunBlueprint(args Args, ctx *blueprint.Context, config interface{}) []strin } } - if stage != StageMain || !args.EmptyNinjaFile { + if !args.EmptyNinjaFile { f, err = os.OpenFile(joinPath(ctx.SrcDir(), args.OutFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions) if err != nil { fatalf("error opening Ninja file: %s", err) diff --git a/bootstrap/config.go b/bootstrap/config.go index 8f5fb11..3706fbe 100644 --- a/bootstrap/config.go +++ b/bootstrap/config.go @@ -113,13 +113,6 @@ type ConfigStopBefore interface { StopBefore() StopBefore } -type Stage int - -const ( - StagePrimary Stage = iota - StageMain -) - type PrimaryBuilderInvocation struct { Inputs []string Outputs []string @@ -127,10 +120,7 @@ type PrimaryBuilderInvocation struct { } type Config struct { - stage Stage - - topLevelBlueprintsFile string - subninjas []string + subninjas []string runGoTests bool useValidations bool