summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2010-02-08 09:46:53 -0800
committerAndrew Gerrand <adg@golang.org>2010-02-08 09:46:53 -0800
commitb2df86d9a881f5452e0caa2c06630ad1ee940f40 (patch)
tree7e7609931fa03aa19b483f59d07f19e42c08b7c2
parent40e0b0113b3e75005f20206a79a581e11210c5d5 (diff)
downloadgolang-b2df86d9a881f5452e0caa2c06630ad1ee940f40.tar.gz
*l/*c: add -V flag to display version number
R=rsc CC=golang-dev http://codereview.appspot.com/204044
-rw-r--r--src/cmd/5l/doc.go2
-rw-r--r--src/cmd/5l/obj.c3
-rw-r--r--src/cmd/6l/doc.go2
-rw-r--r--src/cmd/6l/obj.c3
-rw-r--r--src/cmd/8l/doc.go2
-rw-r--r--src/cmd/8l/obj.c3
-rw-r--r--src/cmd/gc/doc.go2
-rw-r--r--src/cmd/gc/lex.c4
-rw-r--r--src/lib9/Makefile2
-rw-r--r--src/lib9/goos.c6
-rwxr-xr-xsrc/version.bash22
11 files changed, 50 insertions, 1 deletions
diff --git a/src/cmd/5l/doc.go b/src/cmd/5l/doc.go
index 132426158..b724e7012 100644
--- a/src/cmd/5l/doc.go
+++ b/src/cmd/5l/doc.go
@@ -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
diff --git a/src/cmd/5l/obj.c b/src/cmd/5l/obj.c
index 5dbd7655c..374e3dfd9 100644
--- a/src/cmd/5l/obj.c
+++ b/src/cmd/5l/obj.c
@@ -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);
diff --git a/src/cmd/6l/doc.go b/src/cmd/6l/doc.go
index 6a0a735c8..fb88df500 100644
--- a/src/cmd/6l/doc.go
+++ b/src/cmd/6l/doc.go
@@ -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.
*/
diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c
index 537ef9e9a..d95169697 100644
--- a/src/cmd/6l/obj.c
+++ b/src/cmd/6l/obj.c
@@ -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)
diff --git a/src/cmd/8l/doc.go b/src/cmd/8l/doc.go
index 0de4dfc1b..3a830cb8e 100644
--- a/src/cmd/8l/doc.go
+++ b/src/cmd/8l/doc.go
@@ -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.
*/
diff --git a/src/cmd/8l/obj.c b/src/cmd/8l/obj.c
index 6ab48622c..c3044c256 100644
--- a/src/cmd/8l/obj.c
+++ b/src/cmd/8l/obj.c
@@ -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)
diff --git a/src/cmd/gc/doc.go b/src/cmd/gc/doc.go
index 5250cfcbe..108a091b2 100644
--- a/src/cmd/gc/doc.go
+++ b/src/cmd/gc/doc.go
@@ -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.
diff --git a/src/cmd/gc/lex.c b/src/cmd/gc/lex.c
index 175d7a3ef..9c1cbfcf0 100644
--- a/src/cmd/gc/lex.c
+++ b/src/cmd/gc/lex.c
@@ -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);
diff --git a/src/lib9/Makefile b/src/lib9/Makefile
index 592bc3b1a..3061cfdbb 100644
--- a/src/lib9/Makefile
+++ b/src/lib9/Makefile
@@ -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)
diff --git a/src/lib9/goos.c b/src/lib9/goos.c
index 668dc1941..f3ee1110a 100644
--- a/src/lib9/goos.c
+++ b/src/lib9/goos.c
@@ -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
index 000000000..c2a70ac1f
--- /dev/null
+++ b/src/version.bash
@@ -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
+