Merge "Delete bazel-related files while bazel is off" into main

This commit is contained in:
Christopher Parsons
2023-10-31 15:00:17 +00:00
committed by Gerrit Code Review

View File

@@ -632,6 +632,10 @@ func runSoong(ctx Context, config Config) {
if config.BazelBuildEnabled() || config.Bp2Build() {
checkEnvironmentFile(ctx, soongBuildEnv, config.UsedEnvFile(bp2buildFilesTag))
} else {
// Remove bazel files in the event that bazel is disabled for the build.
// These files may have been left over from a previous bazel-enabled build.
cleanBazelFiles(config)
}
if config.JsonModuleGraph() {
@@ -790,6 +794,18 @@ func loadSoongBuildMetrics(ctx Context, config Config, oldTimestamp time.Time) {
}
}
func cleanBazelFiles(config Config) {
files := []string{
shared.JoinPath(config.SoongOutDir(), "bp2build"),
shared.JoinPath(config.SoongOutDir(), "workspace"),
shared.JoinPath(config.SoongOutDir(), bazel.SoongInjectionDirName),
shared.JoinPath(config.OutDir(), "bazel")}
for _, f := range files {
os.RemoveAll(f)
}
}
func runMicrofactory(ctx Context, config Config, name string, pkg string, mapping map[string]string) {
ctx.BeginTrace(metrics.RunSoong, name)
defer ctx.EndTrace()