Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e81e1ef authored by Spandan Das's avatar Spandan Das Committed by Gerrit Code Review
Browse files

Merge "Bootstrap empty glob file"

parents 84a16018 8f99ae6b
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -99,6 +99,21 @@ func environmentArgs(config Config, suffix string) []string {
		"--used_env", shared.JoinPath(config.SoongOutDir(), usedEnvFile+suffix),
	}
}

func writeEmptyGlobFile(ctx Context, path string) {
	err := os.MkdirAll(filepath.Dir(path), 0777)
	if err != nil {
		ctx.Fatalf("Failed to create parent directories of empty ninja glob file '%s': %s", path, err)
	}

	if _, err := os.Stat(path); os.IsNotExist(err) {
		err = ioutil.WriteFile(path, nil, 0666)
		if err != nil {
			ctx.Fatalf("Failed to create empty ninja glob file '%s': %s", path, err)
		}
	}
}

func bootstrapBlueprint(ctx Context, config Config, integratedBp2Build bool) {
	ctx.BeginTrace(metrics.RunSoong, "blueprint bootstrap")
	defer ctx.EndTrace()
@@ -106,8 +121,10 @@ func bootstrapBlueprint(ctx Context, config Config, integratedBp2Build bool) {
	var args bootstrap.Args

	mainNinjaFile := shared.JoinPath(config.SoongOutDir(), "build.ninja")
	globFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/soong-build-globs.ninja")
	bootstrapGlobFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build-globs.ninja")
	// .bootstrap/build.ninja "includes" .bootstrap/build-globs.ninja for incremental builds
	// generate an empty glob before running any rule in .bootstrap/build.ninja
	writeEmptyGlobFile(ctx, bootstrapGlobFile)
	bootstrapDepFile := shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja.d")

	args.RunGoTests = !config.skipSoongTests
@@ -117,7 +134,10 @@ func bootstrapBlueprint(ctx Context, config Config, integratedBp2Build bool) {
	args.TopFile = "Android.bp"
	args.ModuleListFile = filepath.Join(config.FileListDir(), "Android.bp.list")
	args.OutFile = shared.JoinPath(config.SoongOutDir(), ".bootstrap/build.ninja")
	args.GlobFile = globFile
	// 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 "<soong_build_glob>.ninja" will ensure that an unused glob file is not written to out/soong/.bootstrap during StagePrimary
	args.GlobFile = ""
	args.GeneratingPrimaryBuilder = true
	args.EmptyNinjaFile = config.EmptyNinjaFile()