]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add -v flag to build and install
authorRuss Cox <rsc@golang.org>
Tue, 10 Jan 2012 00:44:01 +0000 (16:44 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 10 Jan 2012 00:44:01 +0000 (16:44 -0800)
The -v flag prints the names of packages as they are built/installed.

Use -v in make.bash/run.bash to avoid a silent pause during
the build while Go code is being compiled.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5532055

src/cmd/go/build.go
src/cmd/go/run.go
src/cmd/go/test.go
src/make.bash
src/run.bash

index 791ec817de27efeea83229d0b01bdab13bdc789a..1fc4a4273a586e4aaa87c41bf5021e0aba4dd55d 100644 (file)
@@ -28,7 +28,7 @@ func init() {
 }
 
 var cmdBuild = &Command{
-       UsageLine: "build [-a] [-n] [-x] [-o output] [importpath... | gofiles...]",
+       UsageLine: "build [-a] [-n] [-v] [-x] [-o output] [importpath... | gofiles...]",
        Short:     "compile packages and dependencies",
        Long: `
 Build compiles the packages named by the import paths,
@@ -44,6 +44,7 @@ serving only as a check that the packages can be built.
 
 The -a flag forces rebuilding of packages that are already up-to-date.
 The -n flag prints the commands but does not run them.
+The -v flag prints the names of packages as they are compiled.
 The -x flag prints the commands.
 The -o flag specifies the output file name.
 It is an error to use -o when the command line specifies multiple packages.
@@ -56,12 +57,13 @@ See also: go install, go get, go clean.
 
 var buildA = cmdBuild.Flag.Bool("a", false, "")
 var buildN = cmdBuild.Flag.Bool("n", false, "")
+var buildV = cmdBuild.Flag.Bool("v", false, "")
 var buildX = cmdBuild.Flag.Bool("x", false, "")
 var buildO = cmdBuild.Flag.String("o", "", "output file")
 
 func runBuild(cmd *Command, args []string) {
        var b builder
-       b.init(*buildA, *buildN, *buildX)
+       b.init(*buildA, *buildN, *buildV, *buildX)
 
        var pkgs []*Package
        if len(args) > 0 && strings.HasSuffix(args[0], ".go") {
@@ -95,7 +97,7 @@ func runBuild(cmd *Command, args []string) {
 }
 
 var cmdInstall = &Command{
-       UsageLine: "install [-a] [-n] [-x] [importpath...]",
+       UsageLine: "install [-a] [-n] [-v] [-x] [importpath...]",
        Short:     "compile and install packages and dependencies",
        Long: `
 Install compiles and installs the packages named by the import paths,
@@ -103,6 +105,7 @@ along with their dependencies.
 
 The -a flag forces reinstallation of packages that are already up-to-date.
 The -n flag prints the commands but does not run them.
+The -v flag prints the names of packages as they are compiled.
 The -x flag prints the commands.
 
 For more about import paths, see 'go help importpath'.
@@ -113,11 +116,12 @@ See also: go build, go get, go clean.
 
 var installA = cmdInstall.Flag.Bool("a", false, "")
 var installN = cmdInstall.Flag.Bool("n", false, "")
+var installV = cmdInstall.Flag.Bool("v", false, "")
 var installX = cmdInstall.Flag.Bool("x", false, "")
 
 func runInstall(cmd *Command, args []string) {
        var b builder
-       b.init(*installA, *installN, *installX)
+       b.init(*installA, *installN, *installV, *installX)
        a := &action{}
        for _, p := range packages(args) {
                a.deps = append(a.deps, b.action(modeInstall, modeInstall, p))
@@ -132,6 +136,7 @@ type builder struct {
        work        string               // the temporary work directory (ends in filepath.Separator)
        aflag       bool                 // the -a flag
        nflag       bool                 // the -n flag
+       vflag       bool                 // the -v flag
        xflag       bool                 // the -x flag
        arch        string               // e.g., "6"
        goroot      string               // the $GOROOT
@@ -190,10 +195,11 @@ const (
        modeInstall
 )
 
-func (b *builder) init(aflag, nflag, xflag bool) {
+func (b *builder) init(aflag, nflag, vflag, xflag bool) {
        var err error
        b.aflag = aflag
        b.nflag = nflag
+       b.vflag = vflag
        b.xflag = xflag
        b.actionCache = make(map[cacheKey]*action)
        b.mkdirCache = make(map[string]bool)
@@ -456,6 +462,10 @@ func (b *builder) build(a *action) error {
                fmt.Printf("\n#\n# %s\n#\n\n", a.p.ImportPath)
        }
 
+       if b.vflag {
+               fmt.Fprintf(os.Stderr, "%s\n", a.p.ImportPath)
+       }
+
        // make build directory
        obj := a.objdir
        if err := b.mkdir(obj); err != nil {
index 3ccb465a6a1dc09d347d606af98458c3eeb98071..371ba165432d2a403ddb65054c3e0a580f285355 100644 (file)
@@ -31,7 +31,7 @@ var runX = cmdRun.Flag.Bool("x", false, "")
 
 func runRun(cmd *Command, args []string) {
        var b builder
-       b.init(*runA, *runN, *runX)
+       b.init(*runA, *runN, false, *runX)
        files, args := splitArgs(args)
        p := goFilesPackage(files, "")
        p.target = "" // must build - not up to date
index fb0ba7b4d0d8d4da817bcbae42dbb15a0d6285b5..e6b70dda4f86569f425bec1e63fb1c73272c9606 100644 (file)
@@ -220,7 +220,7 @@ func runTest(cmd *Command, args []string) {
        }
 
        var b builder
-       b.init(false, false, testX)
+       b.init(false, false, false, testX)
 
        var builds, runs []*action
 
index 10eaade5392f5017a75e2777a26097bbe40237f8..db8cd7cd495766572e420303140663d536e6b7a2 100755 (executable)
@@ -96,7 +96,7 @@ if $USE_GO_TOOL; then
        ./buildscript_${GOOS}_$GOARCH.sh
 
        echo '# Building Go code.'
-       go install -a std
+       go install -a -v std
 else
        echo; echo; echo %%%% making pkg %%%%; echo
        gomake -C pkg install
index 004c66eea2226e67d59660a84a0909c0c34eba93..2741637a80ccffa1095794e0f8accc0d1f8bed9f 100755 (executable)
@@ -34,7 +34,7 @@ if $rebuild; then
        if $USE_GO_TOOL; then
                echo
                echo '# Package builds'
-               time go install -a std
+               time go install -a -v std
        else
                (xcd pkg
                        gomake clean