1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:07:00 -07:00
recognize "// package foo" in non-go files
	recognize "gobuild: ignore" to exclude from build

R=r
DELTA=10  (7 added, 2 deleted, 1 changed)
OCL=19878
CL=19905
This commit is contained in:
Russ Cox 2008-11-24 11:21:56 -08:00
parent 0e198da634
commit 6c4d8f8309

View File

@ -206,12 +206,17 @@ getpkg(char *file)
char *p, *q;
int i;
if(!suffix(file, ".go"))
return nil;
if((b = Bopen(file, OREAD)) == nil)
sysfatal("open %s: %r", file);
while((p = Brdline(b, '\n')) != nil) {
p[Blinelen(b)-1] = '\0';
if(!suffix(file, ".go")) {
if(*p != '/' || *(p+1) != '/')
continue;
p += 2;
}
if(strstr(p, "gobuild: ignore"))
return "main";
while(*p == ' ' || *p == '\t')
p++;
if(strncmp(p, "package", 7) == 0 && (p[7] == ' ' || p[7] == '\t')) {
@ -487,7 +492,7 @@ main(int argc, char **argv)
njob = 0;
job = emalloc(argc*sizeof job[0]);
for(i=0; i<argc; i++) {
if(suffix(argv[i], "_test.go") != nil)
if(suffix(argv[i], "_test.go"))
continue;
job[njob].name = argv[i];
job[njob].pass = -1;