Merge changes from topics "remove-blueprint-main", "remove-some-minibp", "remove-srcdir"
* changes:
Remove Srcdir() from BootstrapConfig.
Define command line args in soong_build .
Move bpglob to .bootstrap from .minibootstrap.
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index 0e7c944..312f009 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -28,8 +28,6 @@
"android/soong/bazel/cquery"
- "github.com/google/blueprint/bootstrap"
-
"android/soong/bazel"
"android/soong/shared"
)
@@ -760,7 +758,7 @@
// Add ninja file dependencies for files which all bazel invocations require.
bazelBuildList := absolutePath(filepath.Join(
- filepath.Dir(bootstrap.CmdlineArgs.ModuleListFile), "bazel.list"))
+ filepath.Dir(ctx.Config().moduleListFile), "bazel.list"))
ctx.AddNinjaFileDeps(bazelBuildList)
data, err := ioutil.ReadFile(bazelBuildList)
diff --git a/android/config.go b/android/config.go
index e3d05a6..35403b8 100644
--- a/android/config.go
+++ b/android/config.go
@@ -79,10 +79,6 @@
return false // Never compile Go code in the main build for debugging
}
-func (c Config) SrcDir() string {
- return c.srcDir
-}
-
// A DeviceConfig object represents the configuration for a particular device
// being built. For now there will only be one of these, but in the future there
// may be multiple devices being built.
@@ -126,7 +122,6 @@
deviceConfig *deviceConfig
- srcDir string // the path of the root source directory
buildDir string // the path of the build output directory
moduleListFile string // the path to the file which lists blueprint files to parse.
@@ -402,7 +397,7 @@
// multiple runs in the same program execution is carried over (such as Bazel
// context or environment deps).
func ConfigForAdditionalRun(c Config) (Config, error) {
- newConfig, err := NewConfig(c.srcDir, c.buildDir, c.moduleListFile, c.env)
+ newConfig, err := NewConfig(c.buildDir, c.moduleListFile, c.env)
if err != nil {
return Config{}, err
}
@@ -413,14 +408,13 @@
// NewConfig creates a new Config object. The srcDir argument specifies the path
// to the root source directory. It also loads the config file, if found.
-func NewConfig(srcDir, buildDir string, moduleListFile string, availableEnv map[string]string) (Config, error) {
+func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]string) (Config, error) {
// Make a config with default options.
config := &config{
ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName),
env: availableEnv,
- srcDir: srcDir,
buildDir: buildDir,
multilibConflicts: make(map[ArchType]bool),
@@ -439,7 +433,7 @@
return Config{}, err
}
- absSrcDir, err := filepath.Abs(srcDir)
+ absSrcDir, err := filepath.Abs(".")
if err != nil {
return Config{}, err
}
@@ -597,7 +591,7 @@
// GoRoot returns the path to the root directory of the Go toolchain.
func (c *config) GoRoot() string {
- return fmt.Sprintf("%s/prebuilts/go/%s", c.srcDir, c.PrebuiltOS())
+ return fmt.Sprintf("prebuilts/go/%s", c.PrebuiltOS())
}
// PrebuiltBuildTool returns the path to a tool in the prebuilts directory containing
diff --git a/android/paths.go b/android/paths.go
index 9c9914e..71caaab 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -622,7 +622,7 @@
// It intended for use in globs that only list files that exist, so it allows '$' in
// filenames.
func pathsForModuleSrcFromFullPath(ctx EarlyModulePathContext, paths []string, incDirs bool) Paths {
- prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
+ prefix := ctx.ModuleDir() + "/"
if prefix == "./" {
prefix = ""
}
@@ -658,7 +658,7 @@
}
// Use Glob so that if the default doesn't exist, a dependency is added so that when it
// is created, we're run again.
- path := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir(), def)
+ path := filepath.Join(ctx.ModuleDir(), def)
return Glob(ctx, path, nil)
}
@@ -986,7 +986,7 @@
// code that is embedding ninja variables in paths
func safePathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error) {
p, err := validateSafePath(pathComponents...)
- ret := SourcePath{basePath{p, ""}, ctx.Config().srcDir}
+ ret := SourcePath{basePath{p, ""}, "."}
if err != nil {
return ret, err
}
@@ -1002,7 +1002,7 @@
// pathForSource creates a SourcePath from pathComponents, but does not check that it exists.
func pathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error) {
p, err := validatePath(pathComponents...)
- ret := SourcePath{basePath{p, ""}, ctx.Config().srcDir}
+ ret := SourcePath{basePath{p, ""}, "."}
if err != nil {
return ret, err
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 16656e4..af935db 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -44,6 +44,8 @@
docFile string
bazelQueryViewDir string
bp2buildMarker string
+
+ cmdlineArgs bootstrap.Args
)
func init() {
@@ -61,6 +63,21 @@
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(&cmdlineArgs.GlobFile, "globFile", "build-globs.ninja", "the Ninja file of globs to output")
+ flag.StringVar(&cmdlineArgs.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.DepFile, "d", "", "the dependency file to output")
+ 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.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 {
@@ -90,8 +107,8 @@
return ctx
}
-func newConfig(srcDir, outDir string, availableEnv map[string]string) android.Config {
- configuration, err := android.NewConfig(srcDir, outDir, bootstrap.CmdlineArgs.ModuleListFile, availableEnv)
+func newConfig(outDir string, availableEnv map[string]string) android.Config {
+ configuration, err := android.NewConfig(outDir, cmdlineArgs.ModuleListFile, availableEnv)
if err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
os.Exit(1)
@@ -107,7 +124,7 @@
func runMixedModeBuild(configuration android.Config, firstCtx *android.Context, extraNinjaDeps []string) {
var firstArgs, secondArgs bootstrap.Args
- firstArgs = bootstrap.CmdlineArgs
+ firstArgs = cmdlineArgs
configuration.SetStopBefore(bootstrap.StopBeforeWriteNinja)
bootstrap.RunBlueprint(firstArgs, firstCtx.Context, configuration)
@@ -123,7 +140,7 @@
os.Exit(1)
}
secondCtx := newContext(secondConfig, true)
- secondArgs = bootstrap.CmdlineArgs
+ secondArgs = cmdlineArgs
ninjaDeps := bootstrap.RunBlueprint(secondArgs, secondCtx.Context, secondConfig)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
err = deptools.WriteDepFile(shared.JoinPath(topDir, secondArgs.DepFile), secondArgs.OutFile, ninjaDeps)
@@ -145,7 +162,7 @@
func runSoongDocs(configuration android.Config) {
ctx := newContext(configuration, false)
- soongDocsArgs := bootstrap.CmdlineArgs
+ soongDocsArgs := cmdlineArgs
bootstrap.RunBlueprint(soongDocsArgs, ctx.Context, configuration)
if err := writeDocs(ctx, configuration, docFile); err != nil {
fmt.Fprintf(os.Stderr, "%s", err)
@@ -183,7 +200,7 @@
generateQueryView := bazelQueryViewDir != ""
jsonModuleFile := configuration.Getenv("SOONG_DUMP_JSON_MODULE_GRAPH")
- blueprintArgs := bootstrap.CmdlineArgs
+ blueprintArgs := cmdlineArgs
prepareBuildActions := !generateQueryView && jsonModuleFile == ""
if bazelConversionRequested {
// Run the alternate pipeline of bp2build mutators and singleton to convert
@@ -208,16 +225,16 @@
// Convert the Soong module graph into Bazel BUILD files.
if generateQueryView {
runQueryView(configuration, ctx)
- return bootstrap.CmdlineArgs.OutFile // TODO: This is a lie
+ return cmdlineArgs.OutFile // TODO: This is a lie
}
if jsonModuleFile != "" {
writeJsonModuleGraph(configuration, ctx, jsonModuleFile, extraNinjaDeps)
- return bootstrap.CmdlineArgs.OutFile // TODO: This is a lie
+ return cmdlineArgs.OutFile // TODO: This is a lie
}
writeMetrics(configuration)
- return bootstrap.CmdlineArgs.OutFile
+ return cmdlineArgs.OutFile
}
// soong_ui dumps the available environment variables to
@@ -256,9 +273,7 @@
availableEnv := parseAvailableEnv()
- // The top-level Blueprints file is passed as the first argument.
- srcDir := filepath.Dir(flag.Arg(0))
- configuration := newConfig(srcDir, outDir, availableEnv)
+ configuration := newConfig(outDir, availableEnv)
extraNinjaDeps := []string{
configuration.ProductVariablesFileName,
usedEnvFile,
@@ -420,7 +435,7 @@
// Read the bazel.list file that the Soong Finder already dumped earlier (hopefully)
// It contains the locations of BUILD files, BUILD.bazel files, etc. in the source dir
func getExistingBazelRelatedFiles(topDir string) ([]string, error) {
- bazelFinderFile := filepath.Join(filepath.Dir(bootstrap.CmdlineArgs.ModuleListFile), "bazel.list")
+ bazelFinderFile := filepath.Join(filepath.Dir(cmdlineArgs.ModuleListFile), "bazel.list")
if !filepath.IsAbs(bazelFinderFile) {
// Assume this was a relative path under topDir
bazelFinderFile = filepath.Join(topDir, bazelFinderFile)
@@ -451,8 +466,8 @@
// Android.bp files. It must not depend on the values of per-build product
// configurations or variables, since those will generate different BUILD
// files based on how the user has configured their tree.
- bp2buildCtx.SetModuleListFile(bootstrap.CmdlineArgs.ModuleListFile)
- modulePaths, err := bp2buildCtx.ListModulePaths(configuration.SrcDir())
+ bp2buildCtx.SetModuleListFile(cmdlineArgs.ModuleListFile)
+ modulePaths, err := bp2buildCtx.ListModulePaths(".")
if err != nil {
panic(err)
}
@@ -465,7 +480,7 @@
// Run the loading and analysis pipeline to prepare the graph of regular
// Modules parsed from Android.bp files, and the BazelTargetModules mapped
// from the regular Modules.
- blueprintArgs := bootstrap.CmdlineArgs
+ blueprintArgs := cmdlineArgs
ninjaDeps := bootstrap.RunBlueprint(blueprintArgs, bp2buildCtx.Context, configuration)
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
@@ -493,8 +508,8 @@
"bazel-" + filepath.Base(topDir),
}
- if bootstrap.CmdlineArgs.NinjaBuildDir[0] != '/' {
- excludes = append(excludes, bootstrap.CmdlineArgs.NinjaBuildDir)
+ if cmdlineArgs.NinjaBuildDir[0] != '/' {
+ excludes = append(excludes, cmdlineArgs.NinjaBuildDir)
}
existingBazelRelatedFiles, err := getExistingBazelRelatedFiles(topDir)
@@ -509,7 +524,7 @@
excludes = append(excludes, getTemporaryExcludes()...)
symlinkForestDeps := bp2build.PlantSymlinkForest(
- topDir, workspaceRoot, generatedRoot, configuration.SrcDir(), excludes)
+ topDir, workspaceRoot, generatedRoot, ".", excludes)
// Only report metrics when in bp2build mode. The metrics aren't relevant
// for queryview, since that's a total repo-wide conversion and there's a
diff --git a/ui/build/soong.go b/ui/build/soong.go
index 70eabc0..8ef8c74 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -71,16 +71,11 @@
// A tiny struct used to tell Blueprint that it's in bootstrap mode. It would
// probably be nicer to use a flag in bootstrap.Args instead.
type BlueprintConfig struct {
- srcDir string
buildDir string
ninjaBuildDir string
debugCompilation bool
}
-func (c BlueprintConfig) SrcDir() string {
- return "."
-}
-
func (c BlueprintConfig) BuildDir() string {
return c.buildDir
}
@@ -194,7 +189,6 @@
blueprintCtx := blueprint.NewContext()
blueprintCtx.SetIgnoreUnknownModuleTypes(true)
blueprintConfig := BlueprintConfig{
- srcDir: os.Getenv("TOP"),
buildDir: config.SoongOutDir(),
ninjaBuildDir: config.OutDir(),
debugCompilation: os.Getenv("SOONG_DELVE") != "",
@@ -227,11 +221,9 @@
// unused variables were changed?
envFile := filepath.Join(config.SoongOutDir(), availableEnvFile)
- for _, n := range []string{".bootstrap", ".minibootstrap"} {
- dir := filepath.Join(config.SoongOutDir(), n)
- if err := os.MkdirAll(dir, 0755); err != nil {
- ctx.Fatalf("Cannot mkdir " + dir)
- }
+ dir := filepath.Join(config.SoongOutDir(), ".bootstrap")
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ ctx.Fatalf("Cannot mkdir " + dir)
}
buildMode := config.bazelBuildMode()
@@ -272,7 +264,7 @@
}
}()
- runMicrofactory(ctx, config, ".minibootstrap/bpglob", "github.com/google/blueprint/bootstrap/bpglob",
+ runMicrofactory(ctx, config, ".bootstrap/bpglob", "github.com/google/blueprint/bootstrap/bpglob",
map[string]string{"github.com/google/blueprint": "build/blueprint"})
ninja := func(name, ninjaFile string, targets ...string) {
diff --git a/ui/build/test_build.go b/ui/build/test_build.go
index a910c06..57ceaba 100644
--- a/ui/build/test_build.go
+++ b/ui/build/test_build.go
@@ -65,7 +65,6 @@
outDir := config.OutDir()
bootstrapDir := filepath.Join(outDir, "soong", ".bootstrap")
- miniBootstrapDir := filepath.Join(outDir, "soong", ".minibootstrap")
modulePathsDir := filepath.Join(outDir, ".module_paths")
variablesFilePath := filepath.Join(outDir, "soong", "soong.variables")
@@ -89,7 +88,6 @@
continue
}
if strings.HasPrefix(line, bootstrapDir) ||
- strings.HasPrefix(line, miniBootstrapDir) ||
strings.HasPrefix(line, modulePathsDir) ||
line == variablesFilePath ||
line == dexpreoptConfigFilePath ||