From: Rob Pike Date: Sat, 18 Apr 2009 02:39:45 +0000 (-0700) Subject: add -P pkgdir option to 6l to have it look first in pkgdir for a package. X-Git-Tag: weekly.2009-11-06~1804 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=bfd5ede78def5e6fe0d0f6f9169daed6deee2d91;p=gostls13.git add -P pkgdir option to 6l to have it look first in pkgdir for a package. this allows gotest to find the locally built package when doing make gotest without this option, one would have to say make install gotest which kinda defeats the purpose based on discussions with rsc. R=ken,rsc DELTA=12 (10 added, 1 deleted, 1 changed) OCL=27606 CL=27606 --- diff --git a/src/cmd/6l/l.h b/src/cmd/6l/l.h index 2d3cd535a1..8479156463 100644 --- a/src/cmd/6l/l.h +++ b/src/cmd/6l/l.h @@ -288,6 +288,7 @@ EXTERN vlong INITDAT; EXTERN int32 INITRND; EXTERN vlong INITTEXT; EXTERN char* INITENTRY; /* entry point */ +EXTERN char* PKGDIR; EXTERN Biobuf bso; EXTERN int32 bsssize; EXTERN int cbc; diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c index 3a4208cd22..b65c7f313b 100644 --- a/src/cmd/6l/obj.c +++ b/src/cmd/6l/obj.c @@ -87,6 +87,7 @@ main(int argc, char *argv[]) INITDAT = -1; INITRND = -1; INITENTRY = 0; + PKGDIR = nil; ARGBEGIN { default: @@ -122,6 +123,11 @@ main(int argc, char *argv[]) if(a) INITRND = atolwhex(a); break; + case 'P': + a = ARGF(); + if(a) + PKGDIR = a; + break; case 'x': /* produce export table */ doexp = 1; if(argv[1] != nil && argv[1][0] != '-' && !isobjfile(argv[1])) @@ -684,9 +690,10 @@ addlib(char *src, char *obj) } if(search) { - // try dot and then try goroot. - // going to have to do better (probably a command line flag) later. + // try dot, -P "pkgdir", and then goroot. snprint(pname, sizeof pname, ".%s", name); + if(access(pname, AEXIST) < 0 && PKGDIR != nil) + snprint(pname, sizeof pname, "%s/%s", PKGDIR, name); if(access(pname, AEXIST) < 0) snprint(pname, sizeof pname, "%s/pkg/%s", goroot, name); strcpy(name, pname); diff --git a/src/cmd/gotest/gotest b/src/cmd/gotest/gotest index 2cb08c5290..12db03bf30 100755 --- a/src/cmd/gotest/gotest +++ b/src/cmd/gotest/gotest @@ -13,6 +13,7 @@ GC=${GC:-${O}g} GL=${GL:-${O}l} export GC GL GC="$GC -I _obj" +GL="$GL -P _obj" gofiles="" loop=true