github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/src/cmd/dist/buildgo.c (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 #include "a.h" 6 7 /* 8 * Helpers for building cmd/go and cmd/cgo. 9 */ 10 11 // mkzdefaultcc writes zdefaultcc.go: 12 // 13 // package main 14 // const defaultCC = <defaultcc> 15 // const defaultCXX = <defaultcxx> 16 // 17 // It is invoked to write cmd/go/zdefaultcc.go 18 // but we also write cmd/cgo/zdefaultcc.go. 19 void 20 mkzdefaultcc(char *dir, char *file) 21 { 22 Buf b, out; 23 24 USED(dir); 25 26 binit(&out); 27 bprintf(&out, 28 "// auto generated by go tool dist\n" 29 "\n" 30 "package main\n" 31 "\n" 32 "const defaultCC = `%s`\n" 33 "const defaultCXX = `%s`\n", 34 defaultcctarget, defaultcxxtarget); 35 36 writefile(&out, file, 0); 37 38 // Convert file name to replace. 39 binit(&b); 40 bwritestr(&b, file); 41 if(slash[0] == '/') 42 bsubst(&b, "/go/zdefaultcc.go", "/cgo/zdefaultcc.go"); 43 else 44 bsubst(&b, "\\go\\zdefaultcc.go", "\\cgo\\zdefaultcc.go"); 45 writefile(&out, bstr(&b), 0); 46 47 bfree(&b); 48 bfree(&out); 49 }