summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-06-12 10:47:42 -0700
committerRuss Cox <rsc@golang.org>2010-06-12 10:47:42 -0700
commit66d41569837e7319adbf217ceef43203109ce3f1 (patch)
tree93dd47e7e0cf613fd8cabcb0e5908d3b9399814b /src/cmd
parent4321eeca8945da697391dc4fb309a820e1b753cb (diff)
downloadgolang-66d41569837e7319adbf217ceef43203109ce3f1.tar.gz
gopack: add S flag to force marking a package as safe
R=r CC=golang-dev http://codereview.appspot.com/1597044
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/gopack/ar.c16
-rwxr-xr-xsrc/cmd/gotest/gotest4
2 files changed, 16 insertions, 4 deletions
diff --git a/src/cmd/gopack/ar.c b/src/cmd/gopack/ar.c
index be72d305f..377366ec4 100644
--- a/src/cmd/gopack/ar.c
+++ b/src/cmd/gopack/ar.c
@@ -109,7 +109,7 @@ typedef struct Hashchain
/* constants and flags */
char *man = "mrxtdpq";
-char *opt = "uvnbailo";
+char *opt = "uvnbailoS";
char artemp[] = "/tmp/vXXXXX";
char movtemp[] = "/tmp/v1XXXXX";
char tailtemp[] = "/tmp/v2XXXXX";
@@ -123,6 +123,7 @@ int gflag;
int oflag;
int uflag;
int vflag;
+int Sflag; /* force mark Go package as safe */
int errors;
@@ -217,6 +218,7 @@ main(int argc, char *argv[])
case 'u': uflag = 1; break;
case 'v': vflag = 1; break;
case 'x': setcom(xcmd); break;
+ case 'S': Sflag = 1; break;
default:
fprint(2, "gopack: bad option `%c'\n", *cp);
exits("error");
@@ -648,18 +650,25 @@ strstrn(char *line, int len, char *sub)
/*
* package import data
*/
+int safe = 1;
char* pkgname;
char* importblock;
void
getpkgdef(char **datap, int *lenp)
{
+ char *tag;
+
if(pkgname == nil) {
pkgname = "__emptyarchive__";
importblock = "";
}
- *datap = smprint("import\n$$\npackage %s\n%s\n$$\n", pkgname, importblock);
+ tag = "";
+ if(safe || Sflag)
+ tag = "safe";
+
+ *datap = smprint("import\n$$\npackage %s %s\n%s\n$$\n", pkgname, tag, importblock);
*lenp = strlen(*datap);
}
@@ -695,6 +704,7 @@ scanpkg(Biobuf *b, long size)
goto foundstart;
}
// fprint(2, "gopack: warning: no package import section in %s\n", file);
+ safe = 0; // non-Go file (C or assembly)
return;
foundstart:
@@ -728,6 +738,8 @@ foundstart:
pkgname = armalloc(pkg - data + 1);
memmove(pkgname, data, pkg - data);
pkgname[pkg-data] = '\0';
+ if(strcmp(pkg, " safe\n") != 0)
+ safe = 0;
start = Boffset(b); // after package statement
first = 0;
continue;
diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest
index 0a0aafc34..b9626815a 100755
--- a/src/cmd/gotest/gotest
+++ b/src/cmd/gotest/gotest
@@ -100,7 +100,7 @@ if $havex; then
fi
# They all compile; now generate the code to call them.
-trap "rm -f _testmain.go _testmain.$O" 0 1 2 3 14 15
+# trap "rm -f _testmain.go _testmain.$O" 0 1 2 3 14 15
# Suppress output to stdout on Linux
MAKEFLAGS=
@@ -116,7 +116,7 @@ nmgrep() {
# Figure out pkg.
case "$i" in
*.a)
- pkg=$("$GOBIN"/gopack p $i __.PKGDEF | sed -n 's/^package //p' | sed 1q)
+ pkg=$("$GOBIN"/gopack p $i __.PKGDEF | sed -n 's/^package //p' | sed 's/ .*//' | sed 1q)
;;
*)
pkg=$(sed -n 's/^ .* in package "\(.*\)".*/\1/p' $i | sed 1q)