]> Cypherpunks repositories - gostls13.git/commitdiff
*l/*c: add -V flag to display version number
authorAndrew Gerrand <adg@golang.org>
Mon, 8 Feb 2010 17:46:53 +0000 (09:46 -0800)
committerAndrew Gerrand <adg@golang.org>
Mon, 8 Feb 2010 17:46:53 +0000 (09:46 -0800)
R=rsc
CC=golang-dev
https://golang.org/cl/204044

src/cmd/5l/doc.go
src/cmd/5l/obj.c
src/cmd/6l/doc.go
src/cmd/6l/obj.c
src/cmd/8l/doc.go
src/cmd/8l/obj.c
src/cmd/gc/doc.go
src/cmd/gc/lex.c
src/lib9/Makefile
src/lib9/goos.c
src/version.bash [new file with mode: 0755]

index 132426158a7c3eec3cf225679b50605a074d7d69..b724e7012ff4b79d4e97a8744173dd903e7f7b0d 100644 (file)
@@ -23,6 +23,8 @@ Options new in this version:
 -L dir1,dir2,..
        Search for libraries (package files) in the comma-separated list of directories.
        The default is the single location $GOROOT/pkg/$GOOS_arm.
+-V
+       Print the linker version.
 
 */
 package documentation
index 5dbd7655c5c60aa23b4578b76fe49502eea6846c..374e3dfd90d8ab9effa478efc8109d3f3cdaba08 100644 (file)
@@ -141,6 +141,9 @@ main(int argc, char *argv[])
                if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
                        readundefs(ARGF(), SIMPORT);
                break;
+       case 'V':
+               print("%cl version %s\n", thechar, getgoversion());
+               errorexit();
        } ARGEND
 
        USED(argc);
index 6a0a735c8e50c2a1ca80f87ade69263459369a3e..fb88df500d1a933c520ae4f7f442bb78996e5a54 100644 (file)
@@ -35,6 +35,8 @@ Options new in this version:
 -L dir1,dir2,..
        Search for libraries (package files) in the comma-separated list of directories.
        The default is the single location $GOROOT/pkg/$GOOS_amd64.
+-V
+       Print the linker version.
 
 
 */
index 537ef9e9aa7c5ef41a4c84f0ab1fa7fdd6c90413..d95169697802aff338a448b46f38d10a97fd188a 100644 (file)
@@ -136,6 +136,9 @@ main(int argc, char *argv[])
                if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
                        readundefs(ARGF(), SIMPORT);
                break;
+       case 'V':
+               print("%cl version %s\n", thechar, getgoversion());
+               errorexit();
        } ARGEND
 
        if(argc != 1)
index 0de4dfc1b161eddd180d2eccd86127e4ffa9bb24..3a830cb8e12b0ad4a0a925abc26ba65d7c553d69 100644 (file)
@@ -32,6 +32,8 @@ Options new in this version:
 -L dir1,dir2,..
        Search for libraries (package files) in the comma-separated list of directories.
        The default is the single location $GOROOT/pkg/$GOOS_386.
+-V
+       Print the linker version.
 
 
 */
index 6ab48622cd5f8bdd09011986f30d90b6fc5d79e1..c3044c2561f84f7bffc0d32005e8b44c7608cf95 100644 (file)
@@ -142,6 +142,9 @@ main(int argc, char *argv[])
                if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1]))
                        readundefs(ARGF(), SIMPORT);
                break;
+       case 'V':
+               print("%cl version %s\n", thechar, getgoversion());
+               errorexit();
        } ARGEND
 
        if(argc != 1)
index 5250cfcbe869ef39dc196eba586ef67898de5b07..108a091b281fb2518d317ec378ee0aae81d8a709 100644 (file)
@@ -38,6 +38,8 @@ Flags:
                disable optimization
        -S
                write assembly language text to standard output
+       -V
+               print the compiler version
 
 There are also a number of debugging flags; run the command with no arguments
 to get a usage message.
index 175d7a3efca33822fc03aa971349d5c2e871b6cd..9c1cbfcf07386f1798d58315a33ec0bf0d1bbba4 100644 (file)
@@ -65,6 +65,9 @@ main(int argc, char *argv[])
        case 'I':
                addidir(ARGF());
                break;
+       case 'V':
+               print("%cg version %s\n", thechar, getgoversion());
+               errorexit();
        } ARGEND
 
        if(argc < 1)
@@ -168,6 +171,7 @@ usage:
        print("  -h panic on an error\n");
        print("  -o file specify output file\n");
        print("  -S print the assembly language\n");
+       print("  -V print the compiler version\n");
        print("  -w print the parse tree after typing\n");
        print("  -x print lex tokens\n");
        exit(0);
index 592bc3b1a614d879422768c19c0c4f8ecd549029..3061cfdbb43e2ab7a8f49556381a36815d31d026 100644 (file)
@@ -117,7 +117,7 @@ $(LIB): $(OFILES)
        $(CC) -c $(CFLAGS) $<
 
 goos.$O: goos.c
-       $(CC) -c $(CFLAGS) -DGOOS='"$(GOOS)"' -DGOARCH='"$(GOARCH)"' -DGOROOT='"$(GOROOT)"' $<
+       $(CC) -c $(CFLAGS) -DGOOS='"$(GOOS)"' -DGOARCH='"$(GOARCH)"' -DGOROOT='"$(GOROOT)"' -DGOVERSION='"'"$$(../version.bash)"'"' $<
 
 clean:
        rm -f *.$O *.6 6.out $(LIB)
index 668dc1941dff08ee8c4c65e32a2bd085bb917fe8..f3ee1110a0a1286343e4a52406f51be335e079c9 100644 (file)
@@ -33,3 +33,9 @@ getgoroot(void)
 {
        return defgetenv("GOROOT", GOROOT);
 }
+
+char*
+getgoversion(void)
+{
+       return GOVERSION;
+}
diff --git a/src/version.bash b/src/version.bash
new file mode 100755 (executable)
index 0000000..c2a70ac
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+# Copyright 2010 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# Check that we can use 'hg'
+if ! hg version > /dev/null 2>&1; then
+       echo 'hg not installed' 1>&2
+       exit 2
+fi
+
+# Get numerical revision
+VERSION="`hg identify -n`"
+
+# Append tag if not 'tip'
+TAG=$(hg identify -t | sed 's!/release!!')
+if [[ "$TAG" != "tip" ]]; then
+       VERSION="$VERSION $TAG"
+fi
+
+echo $VERSION
+