]> Cypherpunks.ru repositories - gostls13.git/blob - src/cmd/dist/buildruntime.go
internal/platform,cmd/dist: export the list of supported platforms
[gostls13.git] / src / cmd / dist / buildruntime.go
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 (
8         "fmt"
9         "strings"
10 )
11
12 /*
13  * Helpers for building runtime.
14  */
15
16 // mkzversion writes zversion.go:
17 //
18 //      package sys
19 //
20 // (Nothing right now!)
21 func mkzversion(dir, file string) {
22         var buf strings.Builder
23         writeHeader(&buf)
24         fmt.Fprintf(&buf, "package sys\n")
25         writefile(buf.String(), file, writeSkipSame)
26 }
27
28 // mkbuildcfg writes internal/buildcfg/zbootstrap.go:
29 //
30 //      package buildcfg
31 //
32 //      const defaultGOROOT = <goroot>
33 //      const defaultGO386 = <go386>
34 //      ...
35 //      const defaultGOOS = runtime.GOOS
36 //      const defaultGOARCH = runtime.GOARCH
37 //
38 // The use of runtime.GOOS and runtime.GOARCH makes sure that
39 // a cross-compiled compiler expects to compile for its own target
40 // system. That is, if on a Mac you do:
41 //
42 //      GOOS=linux GOARCH=ppc64 go build cmd/compile
43 //
44 // the resulting compiler will default to generating linux/ppc64 object files.
45 // This is more useful than having it default to generating objects for the
46 // original target (in this example, a Mac).
47 func mkbuildcfg(file string) {
48         var buf strings.Builder
49         writeHeader(&buf)
50         fmt.Fprintf(&buf, "package buildcfg\n")
51         fmt.Fprintln(&buf)
52         fmt.Fprintf(&buf, "import \"runtime\"\n")
53         fmt.Fprintln(&buf)
54         fmt.Fprintf(&buf, "const defaultGO386 = `%s`\n", go386)
55         fmt.Fprintf(&buf, "const defaultGOAMD64 = `%s`\n", goamd64)
56         fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm)
57         fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips)
58         fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`\n", gomips64)
59         fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`\n", goppc64)
60         fmt.Fprintf(&buf, "const defaultGOEXPERIMENT = `%s`\n", goexperiment)
61         fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
62         fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`\n", defaultldso)
63         fmt.Fprintf(&buf, "const version = `%s`\n", findgoversion())
64         fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
65         fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
66
67         writefile(buf.String(), file, writeSkipSame)
68 }
69
70 // mkobjabi writes cmd/internal/objabi/zbootstrap.go:
71 //
72 //      package objabi
73 //
74 // (Nothing right now!)
75 func mkobjabi(file string) {
76         var buf strings.Builder
77         writeHeader(&buf)
78         fmt.Fprintf(&buf, "package objabi\n")
79
80         writefile(buf.String(), file, writeSkipSame)
81 }