2013-08-02 13:20:42 -06:00
|
|
|
// Copyright 2012 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "a.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Helpers for building cmd/go and cmd/cgo.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// mkzdefaultcc writes zdefaultcc.go:
|
|
|
|
//
|
|
|
|
// package main
|
|
|
|
// const defaultCC = <defaultcc>
|
2013-09-23 22:17:08 -06:00
|
|
|
// const defaultCXX = <defaultcxx>
|
2013-08-02 13:20:42 -06:00
|
|
|
//
|
|
|
|
// It is invoked to write cmd/go/zdefaultcc.go
|
|
|
|
// but we also write cmd/cgo/zdefaultcc.go.
|
|
|
|
void
|
|
|
|
mkzdefaultcc(char *dir, char *file)
|
|
|
|
{
|
|
|
|
Buf b, out;
|
|
|
|
|
|
|
|
USED(dir);
|
|
|
|
|
|
|
|
binit(&out);
|
|
|
|
bprintf(&out,
|
|
|
|
"// auto generated by go tool dist\n"
|
|
|
|
"\n"
|
|
|
|
"package main\n"
|
|
|
|
"\n"
|
2013-09-23 22:17:08 -06:00
|
|
|
"const defaultCC = `%s`\n"
|
|
|
|
"const defaultCXX = `%s`\n",
|
2014-02-06 10:11:00 -07:00
|
|
|
defaultcctarget, defaultcxxtarget);
|
2013-08-02 13:20:42 -06:00
|
|
|
|
|
|
|
writefile(&out, file, 0);
|
|
|
|
|
|
|
|
// Convert file name to replace.
|
|
|
|
binit(&b);
|
|
|
|
bwritestr(&b, file);
|
2013-08-03 02:32:14 -06:00
|
|
|
if(slash[0] == '/')
|
|
|
|
bsubst(&b, "/go/zdefaultcc.go", "/cgo/zdefaultcc.go");
|
|
|
|
else
|
|
|
|
bsubst(&b, "\\go\\zdefaultcc.go", "\\cgo\\zdefaultcc.go");
|
2013-08-02 13:20:42 -06:00
|
|
|
writefile(&out, bstr(&b), 0);
|
|
|
|
|
|
|
|
bfree(&b);
|
|
|
|
bfree(&out);
|
|
|
|
}
|