From ddb9674c662dff01e8cc61a18f98b395dd889724 Mon Sep 17 00:00:00 2001 From: John Asmuth Date: Sat, 21 Jan 2012 17:05:54 -0500 Subject: [PATCH] added --make-a-mess --- README | 4 ++++ gb/build.go | 15 ++++++++------- gb/cgo.go | 14 ++++++++------ gb/doc.go | 4 ++++ gb/gb.go | 12 +++++++++--- gb/pkg.go | 14 ++++++++------ gb/usage.go | 2 ++ 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/README b/README index 6919c40..13efc6e 100644 --- a/README +++ b/README @@ -192,6 +192,10 @@ Options: --gofmt Run gofmt on all source for relevant targets. + --make-a-mess + Do not clean up intermediate files, such as .6/.8, the _cgo + directory and the _test directory. + --testargs All command line arguments that follow --testargs will be passed on to the test binaries, and otherwise ignored. diff --git a/gb/build.go b/gb/build.go index f449f3c..e3edf63 100644 --- a/gb/build.go +++ b/gb/build.go @@ -65,13 +65,14 @@ func BuildPackage(pkg *Package) (err error) { if err != nil { return } - - defer func() { - if Verbose { - fmt.Printf("Removing %s\n", filepath.Join(pkg.Dir, ibname)) - } - os.Remove(filepath.Join(pkg.Dir, ibname)) - }() + if !MakeAMess { + defer func() { + if Verbose { + fmt.Printf("Removing %s\n", filepath.Join(pkg.Dir, ibname)) + } + os.Remove(filepath.Join(pkg.Dir, ibname)) + }() + } asmObjs := []string{} for _, asm := range pkg.AsmSrcs { diff --git a/gb/cgo.go b/gb/cgo.go index a923cc7..2891e2b 100644 --- a/gb/cgo.go +++ b/gb/cgo.go @@ -93,12 +93,14 @@ func BuildCgoPackage(pkg *Package) (err error) { return } - defer func() { - if Verbose { - fmt.Printf("Removing directory %s\n", cgodir) - } - os.RemoveAll(cgodir) - }() + if !MakeAMess { + defer func() { + if Verbose { + fmt.Printf("Removing directory %s\n", cgodir) + } + os.RemoveAll(cgodir) + }() + } var cgobases []string diff --git a/gb/doc.go b/gb/doc.go index 74d2508..b9403d5 100644 --- a/gb/doc.go +++ b/gb/doc.go @@ -198,6 +198,10 @@ Options: --gofmt Run gofmt on all source for relevant targets. + --make-a-mess + Do not clean up intermediate files, such as .6/.8, the _cgo + directory and the _test directory. + --testargs All command line arguments that follow --testargs will be passed on to the test binaries, and otherwise ignored. diff --git a/gb/gb.go b/gb/gb.go index 6d49b2e..fb6e3b5 100644 --- a/gb/gb.go +++ b/gb/gb.go @@ -48,8 +48,9 @@ var Install, //-i GoFix, //--gofix DoPkgs, //-P DoCmds, //-C - Distribution, //--dist - Workspace bool //--workspace + Distribution, //--dist (deprecated) + Workspace, //--workspace + MakeAMess bool //--make-a-mess var IncludeDir string var GCArgs []string @@ -620,19 +621,24 @@ func CheckFlags() bool { switch arg { case "--gofmt": GoFMT = true + HardArgs++ case "--gofix": GoFix = true + HardArgs++ case "--dist": Distribution = true case "--makefiles": GenMake = true + HardArgs++ case "--workspace": Workspace = true + HardArgs++ + case "--make-a-mess": + MakeAMess = true default: Usage() return false } - HardArgs++ } else if strings.HasPrefix(arg, "-") { for _, flag := range arg[1:] { switch flag { diff --git a/gb/pkg.go b/gb/pkg.go index 8502ee6..afe333b 100644 --- a/gb/pkg.go +++ b/gb/pkg.go @@ -979,12 +979,14 @@ func (this *Package) Test() (err error) { } testdir := path.Join(this.Dir, "_test") - defer func() { - if Verbose { - fmt.Printf(" Removing %s\n", testdir) - } - err = os.RemoveAll(testdir) - }() + if !MakeAMess { + defer func() { + if Verbose { + fmt.Printf(" Removing %s\n", testdir) + } + err = os.RemoveAll(testdir) + }() + } fmt.Printf("(in %s) testing \"%s\"\n", this.Dir, this.Target) diff --git a/gb/usage.go b/gb/usage.go index d040359..2474990 100644 --- a/gb/usage.go +++ b/gb/usage.go @@ -48,6 +48,8 @@ Options: generate standard makefiles without building --workspace create workspace.gb files in all directories + --make-a-mess + don't clean up intermediate files --testargs all arguments following --testargs are passed to the test binary `