github.com/mdempsky/go@v0.0.0-20151201204031-5dd372bd1e70/src/cmd/dist/buildgo.go (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 package main 6 7 import "fmt" 8 9 /* 10 * Helpers for building cmd/go and cmd/cgo. 11 */ 12 13 // mkzdefaultcc writes zdefaultcc.go: 14 // 15 // package main 16 // const defaultCC = <defaultcc> 17 // const defaultCXX = <defaultcxx> 18 // 19 // It is invoked to write cmd/go/zdefaultcc.go 20 // but we also write cmd/cgo/zdefaultcc.go 21 func mkzdefaultcc(dir, file string) { 22 var out string 23 24 out = fmt.Sprintf( 25 "// auto generated by go tool dist\n"+ 26 "\n"+ 27 "package main\n"+ 28 "\n"+ 29 "const defaultCC = `%s`\n"+ 30 "const defaultCXX = `%s`\n", 31 defaultcctarget, defaultcxxtarget) 32 33 writefile(out, file, writeSkipSame) 34 35 // Convert file name to replace: turn go into cgo. 36 i := len(file) - len("go/zdefaultcc.go") 37 file = file[:i] + "c" + file[i:] 38 writefile(out, file, writeSkipSame) 39 }