kylelemons avatar kylelemons committed d51abca

goinstall: add -clean flag

R=adg, rsc
CC=golang-dev
http://codereview.appspot.com/3821042

Committer: Russ Cox <rsc@golang.org>;

Comments (0)

Files changed (2)

src/cmd/goinstall/main.go

 	reportToDashboard = flag.Bool("dashboard", true, "report public packages at "+dashboardURL)
 	logPkgs           = flag.Bool("log", true, "log installed packages to $GOROOT/goinstall.log for use by -a")
 	update            = flag.Bool("u", false, "update already-downloaded packages")
+	clean             = flag.Bool("clean", false, "clean the package directory before installing")
 	verbose           = flag.Bool("v", false, "verbose")
 )
 

src/cmd/goinstall/make.go

 // For non-local packages or packages without Makefiles,
 // domake generates a standard Makefile and passes it
 // to make on standard input.
-func domake(dir, pkg string, local bool) os.Error {
+func domake(dir, pkg string, local bool) (err os.Error) {
+	needMakefile := true
 	if local {
 		_, err := os.Stat(dir + "/Makefile")
 		if err == nil {
-			return run(dir, nil, "gomake", "install")
+			needMakefile = false
 		}
 	}
-	makefile, err := makeMakefile(dir, pkg)
-	if err != nil {
-		return err
+	cmd := []string{"gomake"}
+	var makefile []byte
+	if needMakefile {
+		if makefile, err = makeMakefile(dir, pkg); err != nil {
+			return err
+		}
+		cmd = append(cmd, "-f-")
 	}
-	return run(dir, makefile, "gomake", "-f-", "install")
+	if *clean {
+		cmd = append(cmd, "clean")
+	}
+	cmd = append(cmd, "install")
+	return run(dir, makefile, cmd...)
 }
 
 // makeMakefile computes the standard Makefile for the directory dir
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.