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 */ |
11 | 11 |
12 // The usual variables. | 12 // The usual variables. |
13 char *goarch; | 13 char *goarch; |
14 char *gobin; | 14 char *gobin; |
15 char *gohostarch; | 15 char *gohostarch; |
16 char *gohostchar; | 16 char *gohostchar; |
17 char *gohostos; | 17 char *gohostos; |
18 char *goos; | 18 char *goos; |
19 char *goroot = GOROOT_FINAL; | 19 char *goroot = GOROOT_FINAL; |
20 char *goroot_final = GOROOT_FINAL; | 20 char *goroot_final = GOROOT_FINAL; |
21 char *workdir; | 21 char *workdir; |
22 char *tooldir; | 22 char *tooldir; |
23 char *gochar; | 23 char *gochar; |
24 char *goversion; | 24 char *goversion; |
25 char *slash; // / for unix, \ for windows | 25 char *slash; // / for unix, \ for windows |
26 | 26 |
27 bool rebuildall = 0; | 27 bool rebuildall = 0; |
28 | 28 |
29 static bool shouldbuild(char*, char*); | 29 static bool shouldbuild(char*, char*); |
30 static void copy(char*, char*); | 30 static void copy(char*, char*, int); |
31 static char *findgoversion(void); | 31 static char *findgoversion(void); |
32 | 32 |
33 // The known architecture letters. | 33 // The known architecture letters. |
34 static char *gochars = "568"; | 34 static char *gochars = "568"; |
35 | 35 |
36 // The known architectures. | 36 // The known architectures. |
37 static char *okgoarch[] = { | 37 static char *okgoarch[] = { |
38 // same order as gochars | 38 // same order as gochars |
39 "arm", | 39 "arm", |
40 "amd64", | 40 "amd64", |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Add extra information. | 238 // Add extra information. |
239 run(&bmore, goroot, CheckExit, "hg", "log", "--template", " +{no
de|short}", "-r", rev, nil); | 239 run(&bmore, goroot, CheckExit, "hg", "log", "--template", " +{no
de|short}", "-r", rev, nil); |
240 chomp(&bmore); | 240 chomp(&bmore); |
241 } | 241 } |
242 ········ | 242 ········ |
243 bprintf(&b, "%s", tag); | 243 bprintf(&b, "%s", tag); |
244 if(bmore.len > 0) | 244 if(bmore.len > 0) |
245 bwriteb(&b, &bmore); | 245 bwriteb(&b, &bmore); |
246 | 246 |
247 // Cache version. | 247 // Cache version. |
248 » writefile(&b, bstr(&path)); | 248 » writefile(&b, bstr(&path), 0); |
249 | 249 |
250 done: | 250 done: |
251 p = btake(&b); | 251 p = btake(&b); |
252 ········ | 252 ········ |
253 ········ | 253 ········ |
254 bfree(&b); | 254 bfree(&b); |
255 bfree(&path); | 255 bfree(&path); |
256 bfree(&bmore); | 256 bfree(&bmore); |
257 bfree(&branch); | 257 bfree(&branch); |
258 vfree(&tags); | 258 vfree(&tags); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 vinit(&lib); | 560 vinit(&lib); |
561 vinit(&extra); | 561 vinit(&extra); |
562 ········ | 562 ········ |
563 // path = full path to dir. | 563 // path = full path to dir. |
564 bpathf(&path, "%s/src/%s", goroot, dir); | 564 bpathf(&path, "%s/src/%s", goroot, dir); |
565 name = lastelem(dir); | 565 name = lastelem(dir); |
566 | 566 |
567 // For misc/prof, copy into the tool directory and we're done. | 567 // For misc/prof, copy into the tool directory and we're done. |
568 if(hasprefix(dir, "misc/")) { | 568 if(hasprefix(dir, "misc/")) { |
569 copy(bpathf(&b, "%s/%s", tooldir, name), | 569 copy(bpathf(&b, "%s/%s", tooldir, name), |
570 » » » bpathf(&b1, "%s/misc/%s", goroot, name)); | 570 » » » bpathf(&b1, "%s/misc/%s", goroot, name), 1); |
571 goto out; | 571 goto out; |
572 } | 572 } |
573 | 573 |
574 // For release, cmd/prof and cmd/cov are not included. | 574 // For release, cmd/prof and cmd/cov are not included. |
575 if((streq(dir, "cmd/cov") || streq(dir, "cmd/prof")) && !isdir(bstr(&pat
h))) { | 575 if((streq(dir, "cmd/cov") || streq(dir, "cmd/prof")) && !isdir(bstr(&pat
h))) { |
576 if(vflag > 1) | 576 if(vflag > 1) |
577 xprintf("skipping %s - does not exist\n", dir); | 577 xprintf("skipping %s - does not exist\n", dir); |
578 goto out; | 578 goto out; |
579 } | 579 } |
580 | 580 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 for(i=0; i<lib.len && !stale; i++) | 743 for(i=0; i<lib.len && !stale; i++) |
744 if(mtime(lib.p[i]) > ttarg) | 744 if(mtime(lib.p[i]) > ttarg) |
745 stale = 1; | 745 stale = 1; |
746 ················ | 746 ················ |
747 if(!stale) | 747 if(!stale) |
748 goto out; | 748 goto out; |
749 | 749 |
750 // For package runtime, copy some files into the work space. | 750 // For package runtime, copy some files into the work space. |
751 if(streq(dir, "pkg/runtime")) { | 751 if(streq(dir, "pkg/runtime")) { |
752 copy(bpathf(&b, "%s/arch_GOARCH.h", workdir), | 752 copy(bpathf(&b, "%s/arch_GOARCH.h", workdir), |
753 » » » bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch)); | 753 » » » bpathf(&b1, "%s/arch_%s.h", bstr(&path), goarch), 0); |
754 copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir), | 754 copy(bpathf(&b, "%s/defs_GOOS_GOARCH.h", workdir), |
755 » » » bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch
)); | 755 » » » bpathf(&b1, "%s/defs_%s_%s.h", bstr(&path), goos, goarch
), 0); |
756 copy(bpathf(&b, "%s/os_GOOS.h", workdir), | 756 copy(bpathf(&b, "%s/os_GOOS.h", workdir), |
757 » » » bpathf(&b1, "%s/os_%s.h", bstr(&path), goos)); | 757 » » » bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0); |
758 copy(bpathf(&b, "%s/signals_GOOS.h", workdir), | 758 copy(bpathf(&b, "%s/signals_GOOS.h", workdir), |
759 » » » bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos)); | 759 » » » bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0); |
760 } | 760 } |
761 | 761 |
762 // Generate any missing files; regenerate existing ones. | 762 // Generate any missing files; regenerate existing ones. |
763 for(i=0; i<files.len; i++) { | 763 for(i=0; i<files.len; i++) { |
764 p = files.p[i]; | 764 p = files.p[i]; |
765 elem = lastelem(p); | 765 elem = lastelem(p); |
766 for(j=0; j<nelem(gentab); j++) { | 766 for(j=0; j<nelem(gentab); j++) { |
767 if(hasprefix(elem, gentab[j].nameprefix)) { | 767 if(hasprefix(elem, gentab[j].nameprefix)) { |
768 if(vflag > 1) | 768 if(vflag > 1) |
769 xprintf("generate %s\n", p); | 769 xprintf("generate %s\n", p); |
(...skipping 12 matching lines...) Expand all Loading... |
782 if(find(p, missing.p, missing.len) >= 0) | 782 if(find(p, missing.p, missing.len) >= 0) |
783 fatal("missing file %s", p); | 783 fatal("missing file %s", p); |
784 built:; | 784 built:; |
785 } | 785 } |
786 | 786 |
787 // One more copy for package runtime. | 787 // One more copy for package runtime. |
788 // The last batch was required for the generators. | 788 // The last batch was required for the generators. |
789 // This one is generated. | 789 // This one is generated. |
790 if(streq(dir, "pkg/runtime")) { | 790 if(streq(dir, "pkg/runtime")) { |
791 copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), | 791 copy(bpathf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), |
792 » » » bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch
)); | 792 » » » bpathf(&b1, "%s/zasm_%s_%s.h", bstr(&path), goos, goarch
), 0); |
793 } | 793 } |
794 ········ | 794 ········ |
795 // Generate .c files from .goc files. | 795 // Generate .c files from .goc files. |
796 if(streq(dir, "pkg/runtime")) {········· | 796 if(streq(dir, "pkg/runtime")) {········· |
797 for(i=0; i<files.len; i++) { | 797 for(i=0; i<files.len; i++) { |
798 p = files.p[i]; | 798 p = files.p[i]; |
799 if(!hassuffix(p, ".goc")) | 799 if(!hassuffix(p, ".goc")) |
800 continue; | 800 continue; |
801 // b = path/zp but with _goarch.c instead of .goc | 801 // b = path/zp but with _goarch.c instead of .goc |
802 bprintf(&b, "%s%sz%s", bstr(&path), slash, lastelem(p)); | 802 bprintf(&b, "%s%sz%s", bstr(&path), slash, lastelem(p)); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 // Remove target before writing it. | 928 // Remove target before writing it. |
929 xremove(link.p[2]); | 929 xremove(link.p[2]); |
930 | 930 |
931 runv(nil, nil, CheckExit, &link); | 931 runv(nil, nil, CheckExit, &link); |
932 | 932 |
933 nobuild: | 933 nobuild: |
934 // In package runtime, we install runtime.h and cgocall.h too, | 934 // In package runtime, we install runtime.h and cgocall.h too, |
935 // for use by cgo compilation. | 935 // for use by cgo compilation. |
936 if(streq(dir, "pkg/runtime")) { | 936 if(streq(dir, "pkg/runtime")) { |
937 copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch), | 937 copy(bpathf(&b, "%s/pkg/%s_%s/cgocall.h", goroot, goos, goarch), |
938 » » » bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot)); | 938 » » » bpathf(&b1, "%s/src/pkg/runtime/cgocall.h", goroot), 0); |
939 copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch), | 939 copy(bpathf(&b, "%s/pkg/%s_%s/runtime.h", goroot, goos, goarch), |
940 » » » bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot)); | 940 » » » bpathf(&b1, "%s/src/pkg/runtime/runtime.h", goroot), 0); |
941 } | 941 } |
942 | 942 |
943 | 943 |
944 out: | 944 out: |
945 for(i=0; i<clean.len; i++) | 945 for(i=0; i<clean.len; i++) |
946 xremove(clean.p[i]); | 946 xremove(clean.p[i]); |
947 | 947 |
948 bfree(&b); | 948 bfree(&b); |
949 bfree(&b1); | 949 bfree(&b1); |
950 bfree(&path); | 950 bfree(&path); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 out: | 1044 out: |
1045 bfree(&b); | 1045 bfree(&b); |
1046 vfree(&lines); | 1046 vfree(&lines); |
1047 vfree(&fields); | 1047 vfree(&fields); |
1048 ········ | 1048 ········ |
1049 return ret; | 1049 return ret; |
1050 } | 1050 } |
1051 | 1051 |
1052 // copy copies the file src to dst, via memory (so only good for small files). | 1052 // copy copies the file src to dst, via memory (so only good for small files). |
1053 static void | 1053 static void |
1054 copy(char *dst, char *src) | 1054 copy(char *dst, char *src, int exec) |
1055 { | 1055 { |
1056 Buf b; | 1056 Buf b; |
1057 ········ | 1057 ········ |
1058 if(vflag > 1) | 1058 if(vflag > 1) |
1059 xprintf("cp %s %s\n", src, dst); | 1059 xprintf("cp %s %s\n", src, dst); |
1060 | 1060 |
1061 binit(&b); | 1061 binit(&b); |
1062 readfile(&b, src); | 1062 readfile(&b, src); |
1063 » writefile(&b, dst); | 1063 » writefile(&b, dst, exec); |
1064 bfree(&b); | 1064 bfree(&b); |
1065 } | 1065 } |
1066 | 1066 |
1067 // buildorder records the order of builds for the 'go bootstrap' command. | 1067 // buildorder records the order of builds for the 'go bootstrap' command. |
1068 static char *buildorder[] = { | 1068 static char *buildorder[] = { |
1069 "lib9", | 1069 "lib9", |
1070 "libbio", | 1070 "libbio", |
1071 "libmach", | 1071 "libmach", |
1072 ········ | 1072 ········ |
1073 "misc/pprof", | 1073 "misc/pprof", |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1511 break; | 1511 break; |
1512 default: | 1512 default: |
1513 usage(); | 1513 usage(); |
1514 }ARGEND | 1514 }ARGEND |
1515 | 1515 |
1516 if(argc > 0) | 1516 if(argc > 0) |
1517 usage(); | 1517 usage(); |
1518 | 1518 |
1519 xprintf("%s\n", goversion); | 1519 xprintf("%s\n", goversion); |
1520 } | 1520 } |
LEFT | RIGHT |