mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/internal/obj needs information about the default values of GOROOT, GOARM, GOEXPERIMENT, Version, and so on. It cannot ask package runtime, because during bootstrap package runtime comes from Go 1.4. So it must have its own copy. Change-Id: I73d3e75a3d47210b3184a51a810ebb44826b81e5 Reviewed-on: https://go-review.googlesource.com/3140 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
// 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.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
/*
|
|
* Helpers for building runtime.
|
|
*/
|
|
|
|
// mkzversion writes zversion.go:
|
|
//
|
|
// package runtime
|
|
// const defaultGoroot = <goroot>
|
|
// const theVersion = <version>
|
|
//
|
|
func mkzversion(dir, file string) {
|
|
out := fmt.Sprintf(
|
|
"// auto generated by go tool dist\n"+
|
|
"\n"+
|
|
"package runtime\n"+
|
|
"\n"+
|
|
"const defaultGoroot = `%s`\n"+
|
|
"const theVersion = `%s`\n"+
|
|
"\n"+
|
|
"var buildVersion = theVersion\n", goroot_final, goversion)
|
|
|
|
writefile(out, file, 0)
|
|
}
|
|
|
|
// mkzexperiment writes zaexperiment.h (sic):
|
|
//
|
|
// #define GOEXPERIMENT "experiment string"
|
|
//
|
|
func mkzexperiment(dir, file string) {
|
|
out := fmt.Sprintf(
|
|
"// auto generated by go tool dist\n"+
|
|
"\n"+
|
|
"#define GOEXPERIMENT \"%s\"\n", os.Getenv("GOEXPERIMENT"))
|
|
|
|
writefile(out, file, 0)
|
|
}
|
|
|
|
// mkzbootstrap writes cmd/internal/obj/zbootstrap.go:
|
|
//
|
|
// package obj
|
|
//
|
|
// const defaultGOROOT = <goroot>
|
|
// const defaultGOARM = <goarm>
|
|
// const defaultGOOS = <goos>
|
|
// const defaultGOARCH = <goarch>
|
|
// const version = <version>
|
|
// const goexperiment = <goexperiment>
|
|
//
|
|
func mkzbootstrap(file string) {
|
|
out := fmt.Sprintf(
|
|
"// auto generated by go tool dist\n"+
|
|
"\n"+
|
|
"package obj\n"+
|
|
"\n"+
|
|
"const defaultGOROOT = `%s`\n"+
|
|
"const defaultGOARM = `%s`\n"+
|
|
"const defaultGOOS = `%s`\n"+
|
|
"const defaultGOARCH = `%s`\n"+
|
|
"const version = `%s`\n"+
|
|
"const goexperiment = `%s`\n",
|
|
goroot_final, goarm, gohostos, gohostarch, goversion, os.Getenv("GOEXPERIMENT"))
|
|
|
|
writefile(out, file, 0)
|
|
}
|