From b078ade28d94c85cec78e9776eb31948a5647070 Mon Sep 17 00:00:00 2001 From: "Lukacs T. Berki" Date: Tue, 31 Aug 2021 10:42:08 +0200 Subject: [PATCH] Remove some unused args from Blueprint. These are: TopFile and GeneratingPrimaryBuilder. Also re-shuffle the list of flags to make a bit more sense and finish the rename of BuildDir and NinjaBuildDir to SoongOutDir and OutDir, respectively. Test: Presubmits. Change-Id: I103ff5f09f1c0d16f695a7da5dea13b55028e33e --- android/config.go | 2 +- android/paths.go | 4 ++-- cmd/soong_build/main.go | 28 +++++++++++++++------------- ui/build/soong.go | 7 +++---- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/android/config.go b/android/config.go index b69963fd0..d3db68fd2 100644 --- a/android/config.go +++ b/android/config.go @@ -66,7 +66,7 @@ type Config struct { *config } -// BuildDir returns the build output directory for the configuration. +// SoongOutDir returns the build output directory for the configuration. func (c Config) SoongOutDir() string { return c.soongOutDir } diff --git a/android/paths.go b/android/paths.go index a733558ba..763cd7c40 100644 --- a/android/paths.go +++ b/android/paths.go @@ -1150,7 +1150,7 @@ func (p SourcePath) OverlayPath(ctx ModuleMissingDepsPathContext, path Path) Opt type OutputPath struct { basePath - // The soong build directory, i.e. Config.BuildDir() + // The soong build directory, i.e. Config.SoongOutDir() soongOutDir string fullPath string @@ -1544,7 +1544,7 @@ func PathForModuleRes(ctx ModuleOutPathContext, pathComponents ...string) Module type InstallPath struct { basePath - // The soong build directory, i.e. Config.BuildDir() + // The soong build directory, i.e. Config.SoongOutDir() soongOutDir string // partitionDir is the part of the InstallPath that is automatically determined according to the context. diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go index beda1842a..16a4e1a8a 100644 --- a/cmd/soong_build/main.go +++ b/cmd/soong_build/main.go @@ -58,30 +58,32 @@ func init() { flag.StringVar(&outDir, "out", "", "Soong output directory (usually $TOP/out/soong)") flag.StringVar(&availableEnvFile, "available_env", "", "File containing available environment variables") flag.StringVar(&usedEnvFile, "used_env", "", "File containing used environment variables") + flag.StringVar(&globFile, "globFile", "build-globs.ninja", "the Ninja file of globs to output") + flag.StringVar(&globListDir, "globListDir", "", "the directory containing the glob list files") + flag.StringVar(&cmdlineArgs.SoongOutDir, "b", ".", "the build output directory") + flag.StringVar(&cmdlineArgs.OutDir, "n", "", "the ninja builddir directory") + flag.StringVar(&cmdlineArgs.ModuleListFile, "l", "", "file that lists filepaths to parse") // Debug flags flag.StringVar(&delveListen, "delve_listen", "", "Delve port to listen on for debugging") flag.StringVar(&delvePath, "delve_path", "", "Path to Delve. Only used if --delve_listen is set") + flag.StringVar(&cmdlineArgs.Cpuprofile, "cpuprofile", "", "write cpu profile to file") + flag.StringVar(&cmdlineArgs.TraceFile, "trace", "", "write trace to file") + flag.StringVar(&cmdlineArgs.Memprofile, "memprofile", "", "write memory profile to file") + flag.BoolVar(&cmdlineArgs.NoGC, "nogc", false, "turn off GC for debugging") // Flags representing various modes soong_build can run in flag.StringVar(&moduleGraphFile, "module_graph_file", "", "JSON module graph file to output") flag.StringVar(&docFile, "soong_docs", "", "build documentation file to output") flag.StringVar(&bazelQueryViewDir, "bazel_queryview_dir", "", "path to the bazel queryview directory relative to --top") flag.StringVar(&bp2buildMarker, "bp2build_marker", "", "If set, run bp2build, touch the specified marker file then exit") - flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output") - flag.StringVar(&globFile, "globFile", "build-globs.ninja", "the Ninja file of globs to output") - flag.StringVar(&globListDir, "globListDir", "", "the directory containing the glob list files") - flag.StringVar(&cmdlineArgs.BuildDir, "b", ".", "the build output directory") - flag.StringVar(&cmdlineArgs.NinjaBuildDir, "n", "", "the ninja builddir directory") - flag.StringVar(&cmdlineArgs.Cpuprofile, "cpuprofile", "", "write cpu profile to file") - flag.StringVar(&cmdlineArgs.TraceFile, "trace", "", "write trace to file") - flag.StringVar(&cmdlineArgs.Memprofile, "memprofile", "", "write memory profile to file") - flag.BoolVar(&cmdlineArgs.NoGC, "nogc", false, "turn off GC for debugging") + flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file") + + // Flags that probably shouldn't be flags of soong_build but we haven't found + // the time to remove them yet flag.BoolVar(&cmdlineArgs.RunGoTests, "t", false, "build and run go tests during bootstrap") flag.BoolVar(&cmdlineArgs.UseValidations, "use-validations", false, "use validations to depend on go tests") - flag.StringVar(&cmdlineArgs.ModuleListFile, "l", "", "file that lists filepaths to parse") - flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file") } func newNameResolver(config android.Config) *android.NameResolver { @@ -503,8 +505,8 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) { "bazel-" + filepath.Base(topDir), } - if cmdlineArgs.NinjaBuildDir[0] != '/' { - excludes = append(excludes, cmdlineArgs.NinjaBuildDir) + if cmdlineArgs.OutDir[0] != '/' { + excludes = append(excludes, cmdlineArgs.OutDir) } existingBazelRelatedFiles, err := getExistingBazelRelatedFiles(topDir) diff --git a/ui/build/soong.go b/ui/build/soong.go index 058f8197f..726b5418b 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -128,16 +128,14 @@ func bootstrapBlueprint(ctx Context, config Config) { args.RunGoTests = !config.skipSoongTests args.UseValidations = true // Use validations to depend on tests - args.BuildDir = config.SoongOutDir() - args.NinjaBuildDir = config.OutDir() - args.TopFile = "Android.bp" + args.SoongOutDir = config.SoongOutDir() + args.OutDir = config.OutDir() args.ModuleListFile = filepath.Join(config.FileListDir(), "Android.bp.list") args.OutFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja") // The primary builder (aka soong_build) will use bootstrapGlobFile as the globFile to generate build.ninja(.d) // Building soong_build does not require a glob file // Using "" instead of ".ninja" will ensure that an unused glob file is not written to out/soong/.bootstrap during StagePrimary args.Subninjas = []string{bootstrapGlobFile, bp2buildGlobFile} - args.GeneratingPrimaryBuilder = true args.EmptyNinjaFile = config.EmptyNinjaFile() args.DelveListen = os.Getenv("SOONG_DELVE") @@ -213,6 +211,7 @@ func bootstrapBlueprint(ctx Context, config Config) { debugCompilation: os.Getenv("SOONG_DELVE") != "", } + args.EmptyNinjaFile = false bootstrapDeps := bootstrap.RunBlueprint(args, blueprintCtx, blueprintConfig) err := deptools.WriteDepFile(bootstrapDepFile, args.OutFile, bootstrapDeps) if err != nil {