Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(36)

Side by Side Diff: src/cmd/go/build.go

Issue 7794043: code review 7794043: cmd/go: add go1.1 build tag, add -installsuffix flag (Closed)
Patch Set: diff -r fd9e10489786 https://go.googlecode.com/hg/ Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/cmd/dist/build.c ('k') | src/cmd/go/doc.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "container/heap" 9 "container/heap"
10 "errors" 10 "errors"
(...skipping 22 matching lines...) Expand all
33 along with their dependencies, but it does not install the results. 33 along with their dependencies, but it does not install the results.
34 34
35 If the arguments are a list of .go files, build treats them as a list 35 If the arguments are a list of .go files, build treats them as a list
36 of source files specifying a single package. 36 of source files specifying a single package.
37 37
38 When the command line specifies a single main package, 38 When the command line specifies a single main package,
39 build writes the resulting executable to output. 39 build writes the resulting executable to output.
40 Otherwise build compiles the packages but discards the results, 40 Otherwise build compiles the packages but discards the results,
41 serving only as a check that the packages can be built. 41 serving only as a check that the packages can be built.
42 42
43 The -o flag specifies the output file name. If not specified, the 43 The -o flag specifies the output file name. If not specified, the
44 name is packagename.a (for a non-main package) or the base 44 output file name depends on the arguments and derives from the name
45 name of the first source file (for a main package). 45 of the package, such as p.a for package p, unless p is 'main'. If
46 the package is main and file names are provided, the file name
47 derives from the first file name mentioned, such as f1 for 'go build
48 f1.go f2.go'; with no files provided ('go build'), the output file
49 name is the base name of the containing directory.
46 50
47 The build flags are shared by the build, install, run, and test commands: 51 The build flags are shared by the build, install, run, and test commands:
48 52
49 -a 53 -a
50 force rebuilding of packages that are already up-to-date. 54 force rebuilding of packages that are already up-to-date.
51 -n 55 -n
52 print the commands but do not run them. 56 print the commands but do not run them.
53 -p n 57 -p n
54 the number of builds that can be run in parallel. 58 the number of builds that can be run in parallel.
55 The default is the number of CPUs available. 59 The default is the number of CPUs available.
60 -race
61 enable data race detection.
62 Supported only on linux/amd64, darwin/amd64 and windows/amd64.
56 -v 63 -v
57 print the names of packages as they are compiled. 64 print the names of packages as they are compiled.
58 -work 65 -work
59 print the name of the temporary work directory and 66 print the name of the temporary work directory and
60 do not delete it when exiting. 67 do not delete it when exiting.
61 -x 68 -x
62 print the commands. 69 print the commands.
63 -race
64 enable data race detection.
65 Supported only on linux/amd64, darwin/amd64 and windows/amd64.
66 70
67 -ccflags 'arg list' 71 -ccflags 'arg list'
68 » » arguments to pass on each 5c, 6c, or 8c compiler invocation 72 » » arguments to pass on each 5c, 6c, or 8c compiler invocation.
69 -compiler name 73 -compiler name
70 » » name of compiler to use, as in runtime.Compiler (gccgo or gc) 74 » » name of compiler to use, as in runtime.Compiler (gccgo or gc).
71 -gccgoflags 'arg list' 75 -gccgoflags 'arg list'
72 » » arguments to pass on each gccgo compiler/linker invocation 76 » » arguments to pass on each gccgo compiler/linker invocation.
73 -gcflags 'arg list' 77 -gcflags 'arg list'
74 » » arguments to pass on each 5g, 6g, or 8g compiler invocation 78 » » arguments to pass on each 5g, 6g, or 8g compiler invocation.
79 » -installsuffix suffix
80 » » a suffix to use in the name of the package installation director y,
81 » » in order to keep output separate from default builds.
82 » » If using the -race flag, the install suffix is automatically set to race
83 » » or, if set explicitly, has _race appended to it.
75 -ldflags 'flag list' 84 -ldflags 'flag list'
76 » » arguments to pass on each 5l, 6l, or 8l linker invocation 85 » » arguments to pass on each 5l, 6l, or 8l linker invocation.
77 -tags 'tag list' 86 -tags 'tag list'
78 a list of build tags to consider satisfied during the build. 87 a list of build tags to consider satisfied during the build.
79 See the documentation for the go/build package for 88 See the documentation for the go/build package for
80 more information about build tags. 89 more information about build tags.
81 90
82 The list flags accept a space-separated list of strings. To embed spaces 91 The list flags accept a space-separated list of strings. To embed spaces
83 in an element in the list, surround it with either single or double quotes. 92 in an element in the list, surround it with either single or double quotes.
84 93
85 For more about specifying packages, see 'go help packages'. 94 For more about specifying packages, see 'go help packages'.
86 For more about where packages and binaries are installed, 95 For more about where packages and binaries are installed,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 buildToolchain = gccgoToolchain{} 155 buildToolchain = gccgoToolchain{}
147 } 156 }
148 } 157 }
149 158
150 // addBuildFlags adds the flags common to the build and install commands. 159 // addBuildFlags adds the flags common to the build and install commands.
151 func addBuildFlags(cmd *Command) { 160 func addBuildFlags(cmd *Command) {
152 // NOTE: If you add flags here, also add them to testflag.go. 161 // NOTE: If you add flags here, also add them to testflag.go.
153 cmd.Flag.BoolVar(&buildA, "a", false, "") 162 cmd.Flag.BoolVar(&buildA, "a", false, "")
154 cmd.Flag.BoolVar(&buildN, "n", false, "") 163 cmd.Flag.BoolVar(&buildN, "n", false, "")
155 cmd.Flag.IntVar(&buildP, "p", buildP, "") 164 cmd.Flag.IntVar(&buildP, "p", buildP, "")
165 cmd.Flag.StringVar(&buildContext.InstallSuffix, "installsuffix", "", "")
156 cmd.Flag.BoolVar(&buildV, "v", false, "") 166 cmd.Flag.BoolVar(&buildV, "v", false, "")
157 cmd.Flag.BoolVar(&buildX, "x", false, "") 167 cmd.Flag.BoolVar(&buildX, "x", false, "")
158 cmd.Flag.BoolVar(&buildWork, "work", false, "") 168 cmd.Flag.BoolVar(&buildWork, "work", false, "")
159 cmd.Flag.Var((*stringsFlag)(&buildGcflags), "gcflags", "") 169 cmd.Flag.Var((*stringsFlag)(&buildGcflags), "gcflags", "")
160 cmd.Flag.Var((*stringsFlag)(&buildCcflags), "ccflags", "") 170 cmd.Flag.Var((*stringsFlag)(&buildCcflags), "ccflags", "")
161 cmd.Flag.Var((*stringsFlag)(&buildLdflags), "ldflags", "") 171 cmd.Flag.Var((*stringsFlag)(&buildLdflags), "ldflags", "")
162 cmd.Flag.Var((*stringsFlag)(&buildGccgoflags), "gccgoflags", "") 172 cmd.Flag.Var((*stringsFlag)(&buildGccgoflags), "gccgoflags", "")
163 cmd.Flag.Var((*stringsFlag)(&buildContext.BuildTags), "tags", "") 173 cmd.Flag.Var((*stringsFlag)(&buildContext.BuildTags), "tags", "")
164 cmd.Flag.Var(buildCompiler{}, "compiler", "") 174 cmd.Flag.Var(buildCompiler{}, "compiler", "")
165 cmd.Flag.BoolVar(&buildRace, "race", false, "") 175 cmd.Flag.BoolVar(&buildRace, "race", false, "")
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 if !buildRace { 2087 if !buildRace {
2078 return 2088 return
2079 } 2089 }
2080 if goarch != "amd64" || goos != "linux" && goos != "darwin" && goos != " windows" { 2090 if goarch != "amd64" || goos != "linux" && goos != "darwin" && goos != " windows" {
2081 fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/ amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0]) 2091 fmt.Fprintf(os.Stderr, "go %s: -race is only supported on linux/ amd64, darwin/amd64 and windows/amd64\n", flag.Args()[0])
2082 os.Exit(2) 2092 os.Exit(2)
2083 } 2093 }
2084 buildGcflags = append(buildGcflags, "-race") 2094 buildGcflags = append(buildGcflags, "-race")
2085 buildLdflags = append(buildLdflags, "-race") 2095 buildLdflags = append(buildLdflags, "-race")
2086 buildCcflags = append(buildCcflags, "-D", "RACE") 2096 buildCcflags = append(buildCcflags, "-D", "RACE")
2087 » buildContext.InstallTag = "race" 2097 » if buildContext.InstallSuffix != "" {
2098 » » buildContext.InstallSuffix += "_"
2099 » }
2100 » buildContext.InstallSuffix += "race"
2088 buildContext.BuildTags = append(buildContext.BuildTags, "race") 2101 buildContext.BuildTags = append(buildContext.BuildTags, "race")
2089 } 2102 }
OLDNEW
« no previous file with comments | « src/cmd/dist/build.c ('k') | src/cmd/go/doc.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b