LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "a.h" | 5 #include "a.h" |
6 #include "arg.h" | 6 #include "arg.h" |
7 | 7 |
8 /* | 8 /* |
9 * Initialization for any invocation. | 9 * Initialization for any invocation. |
10 */ | 10 */ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 // The known operating systems. | 44 // The known operating systems. |
45 static char *okgoos[] = { | 45 static char *okgoos[] = { |
46 "darwin", | 46 "darwin", |
47 "linux", | 47 "linux", |
48 "freebsd", | 48 "freebsd", |
49 "netbsd", | 49 "netbsd", |
50 "openbsd", | 50 "openbsd", |
51 "plan9", | 51 "plan9", |
52 "windows", | 52 "windows", |
| 53 }; |
| 54 |
| 55 // The known cgo-enabled combinations. |
| 56 // This list is also known to ../../pkg/go/build/build.go. |
| 57 static char *okcgo[] = { |
| 58 "darwin/386", |
| 59 "darwin/amd64", |
| 60 "linux/386", |
| 61 "linux/amd64", |
| 62 "freebsd/386", |
| 63 "freebsd/amd64", |
| 64 "windows/386", |
| 65 "windows/amd64", |
53 }; | 66 }; |
54 | 67 |
55 static void rmworkdir(void); | 68 static void rmworkdir(void); |
56 | 69 |
57 // find reports the first index of p in l[0:n], or else -1. | 70 // find reports the first index of p in l[0:n], or else -1. |
58 int | 71 int |
59 find(char *p, char **l, int n) | 72 find(char *p, char **l, int n) |
60 { | 73 { |
61 int i; | 74 int i; |
62 | 75 |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 | 1314 |
1302 xprintf(format, "GOROOT", goroot); | 1315 xprintf(format, "GOROOT", goroot); |
1303 xprintf(format, "GOBIN", gobin); | 1316 xprintf(format, "GOBIN", gobin); |
1304 xprintf(format, "GOARCH", goarch); | 1317 xprintf(format, "GOARCH", goarch); |
1305 xprintf(format, "GOOS", goos); | 1318 xprintf(format, "GOOS", goos); |
1306 xprintf(format, "GOHOSTARCH", gohostarch); | 1319 xprintf(format, "GOHOSTARCH", gohostarch); |
1307 xprintf(format, "GOHOSTOS", gohostos); | 1320 xprintf(format, "GOHOSTOS", gohostos); |
1308 xprintf(format, "GOTOOLDIR", tooldir); | 1321 xprintf(format, "GOTOOLDIR", tooldir); |
1309 xprintf(format, "GOCHAR", gochar); | 1322 xprintf(format, "GOCHAR", gochar); |
1310 | 1323 |
| 1324 if(find(bprintf(&b, "%s/%s", goos, goarch), okcgo, nelem(okcgo))) |
| 1325 xprintf(format, "CGO_ENABLED", "1"); |
| 1326 else |
| 1327 xprintf(format, "CGO_ENABLED", "0"); |
| 1328 |
1311 if(pflag) { | 1329 if(pflag) { |
1312 sep = ":"; | 1330 sep = ":"; |
1313 if(streq(gohostos, "windows")) | 1331 if(streq(gohostos, "windows")) |
1314 sep = ";"; | 1332 sep = ";"; |
1315 xgetenv(&b, "PATH"); | 1333 xgetenv(&b, "PATH"); |
1316 bprintf(&b1, "%s%s%s", gobin, sep, bstr(&b)); | 1334 bprintf(&b1, "%s%s%s", gobin, sep, bstr(&b)); |
1317 xprintf(format, "PATH", bstr(&b1)); | 1335 xprintf(format, "PATH", bstr(&b1)); |
1318 } | 1336 } |
1319 | 1337 |
1320 bfree(&b); | 1338 bfree(&b); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 break; | 1537 break; |
1520 default: | 1538 default: |
1521 usage(); | 1539 usage(); |
1522 }ARGEND | 1540 }ARGEND |
1523 | 1541 |
1524 if(argc > 0) | 1542 if(argc > 0) |
1525 usage(); | 1543 usage(); |
1526 | 1544 |
1527 xprintf("%s\n", goversion); | 1545 xprintf("%s\n", goversion); |
1528 } | 1546 } |
LEFT | RIGHT |