Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(75)

Delta Between Two Patch Sets: src/cmd/dist/buildruntime.c

Issue 5608059: code review 5608059: build: dist-based build for Plan 9 (Closed)
Left Patch Set: diff -r e9633053b213 https://code.google.com/p/go/ Created 13 years, 2 months ago
Right Patch Set: diff -r cb5c48bccd5a https://code.google.com/p/go/ Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/dist/buildgc.c ('k') | src/cmd/dist/goc2c.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 <stdio.h>
7 6
8 /* 7 /*
9 * Helpers for building pkg/runtime. 8 * Helpers for building pkg/runtime.
10 */ 9 */
11 10
12 // mkzversion writes zversion.go: 11 // mkzversion writes zversion.go:
13 // 12 //
14 // package runtime 13 // package runtime
15 // const defaultGoroot = <goroot> 14 // const defaultGoroot = <goroot>
16 // const theVersion = <version> 15 // const theVersion = <version>
17 // 16 //
18 void 17 void
19 mkzversion(char *dir, char *file) 18 mkzversion(char *dir, char *file)
20 { 19 {
21 Buf b, out; 20 Buf b, out;
22 ········ 21 ········
23 USED(dir); 22 USED(dir);
24 23
25 binit(&b); 24 binit(&b);
26 binit(&out); 25 binit(&out);
27 ········ 26 ········
28 bwritestr(&out, bprintf(&b, 27 bwritestr(&out, bprintf(&b,
29 "// auto generated by go tool dist\n" 28 "// auto generated by go tool dist\n"
30 "\n" 29 "\n"
31 "package runtime\n" 30 "package runtime\n"
32 "\n" 31 "\n"
33 "const defaultGoroot = `%s`\n" 32 "const defaultGoroot = `%s`\n"
34 » » "const theVersion = `%s`\n", goroot, goversion)); 33 » » "const theVersion = `%s`\n", goroot_final, goversion));
35 34
36 » writefile(&out, file); 35 » writefile(&out, file, 0);
37 ········ 36 ········
38 bfree(&b); 37 bfree(&b);
39 bfree(&out); 38 bfree(&out);
40 } 39 }
41 40
42 // mkzgoarch writes zgoarch_$GOARCH.go: 41 // mkzgoarch writes zgoarch_$GOARCH.go:
43 // 42 //
44 // package runtime 43 // package runtime
45 // const theGoarch = <goarch> 44 // const theGoarch = <goarch>
46 // 45 //
47 void 46 void
48 mkzgoarch(char *dir, char *file) 47 mkzgoarch(char *dir, char *file)
49 { 48 {
50 Buf b, out; 49 Buf b, out;
51 50
52 USED(dir); 51 USED(dir);
53 ········ 52 ········
54 binit(&b); 53 binit(&b);
55 binit(&out); 54 binit(&out);
56 ········ 55 ········
57 bwritestr(&out, bprintf(&b, 56 bwritestr(&out, bprintf(&b,
58 "// auto generated by go tool dist\n" 57 "// auto generated by go tool dist\n"
59 "\n" 58 "\n"
60 "package runtime\n" 59 "package runtime\n"
61 "\n" 60 "\n"
62 "const theGoarch = `%s`\n", goarch)); 61 "const theGoarch = `%s`\n", goarch));
63 62
64 » writefile(&out, file); 63 » writefile(&out, file, 0);
65 ········ 64 ········
66 bfree(&b); 65 bfree(&b);
67 bfree(&out); 66 bfree(&out);
68 } 67 }
69 68
70 // mkzgoos writes zgoos_$GOOS.go: 69 // mkzgoos writes zgoos_$GOOS.go:
71 // 70 //
72 // package runtime 71 // package runtime
73 // const theGoos = <goos> 72 // const theGoos = <goos>
74 // 73 //
75 void 74 void
76 mkzgoos(char *dir, char *file) 75 mkzgoos(char *dir, char *file)
77 { 76 {
78 Buf b, out; 77 Buf b, out;
79 78
80 USED(dir); 79 USED(dir);
81 ········ 80 ········
82 binit(&b); 81 binit(&b);
83 binit(&out); 82 binit(&out);
84 ········ 83 ········
85 bwritestr(&out, bprintf(&b, 84 bwritestr(&out, bprintf(&b,
86 "// auto generated by go tool dist\n" 85 "// auto generated by go tool dist\n"
87 "\n" 86 "\n"
88 "package runtime\n" 87 "package runtime\n"
89 "\n" 88 "\n"
90 "const theGoos = `%s`\n", goos)); 89 "const theGoos = `%s`\n", goos));
91 90
92 » writefile(&out, file); 91 » writefile(&out, file, 0);
93 ········ 92 ········
94 bfree(&b); 93 bfree(&b);
95 bfree(&out); 94 bfree(&out);
96 } 95 }
97 96
98 static struct { 97 static struct {
99 char *goarch; 98 char *goarch;
100 char *goos; 99 char *goos;
101 char *hdr; 100 char *hdr;
102 } zasmhdr[] = { 101 } zasmhdr[] = {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bwritestr(&out, zasmhdr[i].hdr); 189 bwritestr(&out, zasmhdr[i].hdr);
191 goto ok; 190 goto ok;
192 } 191 }
193 } 192 }
194 fatal("unknown $GOOS/$GOARCH in mkzasm"); 193 fatal("unknown $GOOS/$GOARCH in mkzasm");
195 ok: 194 ok:
196 195
197 // Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -a proc.c 196 // Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -a proc.c
198 // to get acid [sic] output. 197 // to get acid [sic] output.
199 vreset(&argv); 198 vreset(&argv);
200 » vadd(&argv, bpathf(&b, "%s/bin/tool/%sc", goroot, gochar)); 199 » vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
201 vadd(&argv, bprintf(&b, "-DGOOS_%s", goos)); 200 vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
202 vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch)); 201 vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
203 vadd(&argv, bprintf(&b, "-I%s", workdir)); 202 vadd(&argv, bprintf(&b, "-I%s", workdir));
204 vadd(&argv, "-a"); 203 vadd(&argv, "-a");
205 vadd(&argv, "proc.c"); 204 vadd(&argv, "proc.c");
206 runv(&in, dir, CheckExit, &argv); 205 runv(&in, dir, CheckExit, &argv);
207 ········ 206 ········
208 // Convert input like 207 // Convert input like
209 // aggr G 208 // aggr G
210 // { 209 // {
(...skipping 23 matching lines...) Expand all
234 if(aggr && hasprefix(lines.p[i], "\t") && fields.len >= 2) { 233 if(aggr && hasprefix(lines.p[i], "\t") && fields.len >= 2) {
235 n = fields.len; 234 n = fields.len;
236 p = fields.p[n-1]; 235 p = fields.p[n-1];
237 if(p[xstrlen(p)-1] == ';') 236 if(p[xstrlen(p)-1] == ';')
238 p[xstrlen(p)-1] = '\0'; 237 p[xstrlen(p)-1] = '\0';
239 bwritestr(&out, bprintf(&b, "#define %s_%s %s\n", aggr, fields.p[n-1], fields.p[n-2])); 238 bwritestr(&out, bprintf(&b, "#define %s_%s %s\n", aggr, fields.p[n-1], fields.p[n-2]));
240 } 239 }
241 } 240 }
242 ········ 241 ········
243 // Write both to file and to workdir/zasm_GOOS_GOARCH.h. 242 // Write both to file and to workdir/zasm_GOOS_GOARCH.h.
244 » writefile(&out, file); 243 » writefile(&out, file, 0);
245 » writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir)); 244 » writefile(&out, bprintf(&b, "%s/zasm_GOOS_GOARCH.h", workdir), 0);
246 245
247 bfree(&in); 246 bfree(&in);
248 bfree(&b); 247 bfree(&b);
249 bfree(&out); 248 bfree(&out);
250 vfree(&argv); 249 vfree(&argv);
251 vfree(&lines); 250 vfree(&lines);
252 vfree(&fields); 251 vfree(&fields);
253 } 252 }
254 253
255 static char *runtimedefs[] = { 254 static char *runtimedefs[] = {
(...skipping 30 matching lines...) Expand all
286 "\n" 285 "\n"
287 "package runtime\n" 286 "package runtime\n"
288 "import \"unsafe\"\n" 287 "import \"unsafe\"\n"
289 "var _ unsafe.Pointer\n" 288 "var _ unsafe.Pointer\n"
290 "\n" 289 "\n"
291 ); 290 );
292 291
293 ········ 292 ········
294 // Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -q 293 // Run 6c -DGOOS_goos -DGOARCH_goarch -Iworkdir -q
295 // on each of the runtimedefs C files. 294 // on each of the runtimedefs C files.
296 » vadd(&argv, bpathf(&b, "%s/bin/tool/%sc", goroot, gochar)); 295 » vadd(&argv, bpathf(&b, "%s/%sc", tooldir, gochar));
297 vadd(&argv, bprintf(&b, "-DGOOS_%s", goos)); 296 vadd(&argv, bprintf(&b, "-DGOOS_%s", goos));
298 vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch)); 297 vadd(&argv, bprintf(&b, "-DGOARCH_%s", goarch));
299 vadd(&argv, bprintf(&b, "-I%s", workdir)); 298 vadd(&argv, bprintf(&b, "-I%s", workdir));
300 vadd(&argv, "-q"); 299 vadd(&argv, "-q");
301 vadd(&argv, ""); 300 vadd(&argv, "");
302 p = argv.p[argv.len-1]; 301 p = argv.p[argv.len-1];
303 for(i=0; i<nelem(runtimedefs); i++) { 302 for(i=0; i<nelem(runtimedefs); i++) {
304 argv.p[argv.len-1] = runtimedefs[i]; 303 argv.p[argv.len-1] = runtimedefs[i];
305 runv(&b, dir, CheckExit, &argv); 304 runv(&b, dir, CheckExit, &argv);
306 bwriteb(&in, &b); 305 bwriteb(&in, &b);
(...skipping 26 matching lines...) Expand all
333 } 332 }
334 if(skip) { 333 if(skip) {
335 if(hasprefix(p, "}")) 334 if(hasprefix(p, "}"))
336 skip = 0; 335 skip = 0;
337 continue; 336 continue;
338 } 337 }
339 ················ 338 ················
340 bwritestr(&out, p); 339 bwritestr(&out, p);
341 } 340 }
342 ········ 341 ········
343 » writefile(&out, file); 342 » writefile(&out, file, 0);
344 343
345 bfree(&in); 344 bfree(&in);
346 bfree(&b); 345 bfree(&b);
347 bfree(&out); 346 bfree(&out);
348 vfree(&argv); 347 vfree(&argv);
349 vfree(&lines); 348 vfree(&lines);
350 vfree(&fields); 349 vfree(&fields);
351 vfree(&seen); 350 vfree(&seen);
352 } 351 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b