Move clean/clobber to soong_ui
So that we don't have to load up all the makefile state just to remove
the output directory.
Starting from a completely empty out directory:
kati: 16s
soong_ui: 2.0s
From a minimal out directory (m -j blueprint_tools):
kati: 3.8s
soong_ui: 0.4s
Test: m -j clean
Test: m -j clobber
Change-Id: Ibeec6fbfa29387750342a752a55336caca4b3992
diff --git a/ui/build/build.go b/ui/build/build.go
index d6059c0..6785082 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -73,6 +73,17 @@
cmd.Stderr = ctx.Stderr()
cmd.RunOrFatal()
return
+ } else if inList("clean", config.Arguments()) || inList("clobber", config.Arguments()) {
+ // We can't use os.RemoveAll, since we don't want to remove the
+ // output directory itself, in case it's a symlink. So just do
+ // exactly what make used to do.
+ cmd := Command(ctx, config, "rm -rf $OUT_DIR/*",
+ "/bin/bash", "-c", "rm -rf "+config.OutDir()+"/*")
+ cmd.Stdout = ctx.Stdout()
+ cmd.Stderr = ctx.Stderr()
+ cmd.RunOrFatal()
+ ctx.Println("Entire build directory removed.")
+ return
}
SetupOutDir(ctx, config)