]> Cypherpunks repositories - gostls13.git/commitdiff
gobuild:
authorRuss Cox <rsc@golang.org>
Mon, 24 Nov 2008 19:21:56 +0000 (11:21 -0800)
committerRuss Cox <rsc@golang.org>
Mon, 24 Nov 2008 19:21:56 +0000 (11:21 -0800)
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

src/cmd/gobuild/gobuild.c

index 55553ec364b2c5e5a71eff5b546e9bd295589b1c..091e2af6fcb26648c62883a1a41872e2c858cf63 100644 (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;