From 0b73b4bc3735ea33d6c2ef873239b54eead3a4b2 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 12 May 2017 19:28:13 -0700 Subject: [PATCH] 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 --- ui/build/build.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ui/build/build.go b/ui/build/build.go index d6059c0bf..67850829a 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -73,6 +73,17 @@ func Build(ctx Context, config Config, what int) { 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)