mirror of
https://github.com/golang/go
synced 2024-11-18 22:55:23 -07:00
Reverted changes on build
This commit is contained in:
parent
b131cc5a2a
commit
b3224226a3
@ -317,6 +317,13 @@ func runBuild(cmd *base.Command, args []string) {
|
|||||||
|
|
||||||
pkgs := load.PackagesForBuild(args)
|
pkgs := load.PackagesForBuild(args)
|
||||||
|
|
||||||
|
explicitO := len(cfg.BuildO) > 0
|
||||||
|
|
||||||
|
if len(pkgs) == 1 && pkgs[0].Name == "main" && cfg.BuildO == "" {
|
||||||
|
cfg.BuildO = pkgs[0].DefaultExecName()
|
||||||
|
cfg.BuildO += cfg.ExeSuffix
|
||||||
|
}
|
||||||
|
|
||||||
// sanity check some often mis-used options
|
// sanity check some often mis-used options
|
||||||
switch cfg.BuildContext.Compiler {
|
switch cfg.BuildContext.Compiler {
|
||||||
case "gccgo":
|
case "gccgo":
|
||||||
@ -342,11 +349,16 @@ func runBuild(cmd *base.Command, args []string) {
|
|||||||
// Special case -o /dev/null by not writing at all.
|
// Special case -o /dev/null by not writing at all.
|
||||||
if cfg.BuildO == os.DevNull {
|
if cfg.BuildO == os.DevNull {
|
||||||
cfg.BuildO = ""
|
cfg.BuildO = ""
|
||||||
} else if cfg.BuildO != "" {
|
}
|
||||||
|
|
||||||
|
if cfg.BuildO != "" {
|
||||||
// If the -o name exists and is a directory, then
|
// If the -o name exists and is a directory, then
|
||||||
// write all main packages to that directory.
|
// write all main packages to that directory.
|
||||||
// Otherwise require only a single package be built.
|
// Otherwise require only a single package be built.
|
||||||
if fi, err := os.Stat(cfg.BuildO); err == nil && fi.IsDir() {
|
if fi, err := os.Stat(cfg.BuildO); err == nil && fi.IsDir() {
|
||||||
|
if !explicitO {
|
||||||
|
base.Fatalf("go build: build output %q already exists and is a directory", cfg.BuildO)
|
||||||
|
}
|
||||||
a := &Action{Mode: "go build"}
|
a := &Action{Mode: "go build"}
|
||||||
for _, p := range pkgs {
|
for _, p := range pkgs {
|
||||||
if p.Name != "main" {
|
if p.Name != "main" {
|
||||||
@ -377,14 +389,6 @@ func runBuild(cmd *base.Command, args []string) {
|
|||||||
a := b.AutoAction(ModeInstall, depMode, p)
|
a := b.AutoAction(ModeInstall, depMode, p)
|
||||||
b.Do(a)
|
b.Do(a)
|
||||||
return
|
return
|
||||||
} else if len(pkgs) == 1 && pkgs[0].Name == "main" {
|
|
||||||
p := pkgs[0]
|
|
||||||
p.Target = p.DefaultExecName()
|
|
||||||
p.Target += cfg.ExeSuffix
|
|
||||||
p.Stale = true
|
|
||||||
a := b.AutoAction(ModeInstall, depMode, p)
|
|
||||||
b.Do(a)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a := &Action{Mode: "go build"}
|
a := &Action{Mode: "go build"}
|
||||||
|
Loading…
Reference in New Issue
Block a user