Skip to content

Commit

Permalink
added --make-a-mess
Browse files Browse the repository at this point in the history
  • Loading branch information
skelterjohn committed Jan 21, 2012
1 parent 624e8b4 commit ddb9674
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
4 changes: 4 additions & 0 deletions README
Expand Up @@ -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.
15 changes: 8 additions & 7 deletions gb/build.go
Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions gb/cgo.go
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions gb/doc.go
Expand Up @@ -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.
Expand Down
12 changes: 9 additions & 3 deletions gb/gb.go
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 8 additions & 6 deletions gb/pkg.go
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions gb/usage.go
Expand Up @@ -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
`
Expand Down

0 comments on commit ddb9674

Please sign in to comment.