mirror of https://github.com/perkeep/perkeep.git
make.go: don't use GOBIN; copy binaries out from temp GOPATH/bin by hand
Fixes http://camlistore.org/issue/229 Change-Id: I7769330e0982a92d4fa90bbce44330b6a473ee0b
This commit is contained in:
parent
db63bcc6d0
commit
bec961cc00
60
make.go
60
make.go
|
@ -36,6 +36,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
pathpkg "path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -208,19 +209,28 @@ func main() {
|
||||||
"--ldflags=-X camlistore.org/pkg/buildinfo.GitInfo "+version,
|
"--ldflags=-X camlistore.org/pkg/buildinfo.GitInfo "+version,
|
||||||
"--tags="+tags)
|
"--tags="+tags)
|
||||||
|
|
||||||
// First install command: build just the final binaries, installed to a GOBIN
|
|
||||||
// under <camlistore_root>/bin:
|
|
||||||
args := append(baseArgs, targs...)
|
|
||||||
if buildAll {
|
if buildAll {
|
||||||
switch *buildOS {
|
switch *buildOS {
|
||||||
case "linux", "darwin":
|
case "linux", "darwin":
|
||||||
args = append(args, "camlistore.org/cmd/cammount")
|
targs = append(targs, "camlistore.org/cmd/cammount")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// First install command: build just the final binaries, installed to a GOBIN
|
||||||
|
// under <camlistore_root>/bin:
|
||||||
|
args := append(baseArgs, targs...)
|
||||||
|
|
||||||
|
if buildAll {
|
||||||
|
args = append(args,
|
||||||
|
"camlistore.org/pkg/...",
|
||||||
|
"camlistore.org/server/...",
|
||||||
|
"camlistore.org/third_party/...",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := exec.Command("go", args...)
|
cmd := exec.Command("go", args...)
|
||||||
cmd.Env = append(cleanGoEnv(),
|
cmd.Env = append(cleanGoEnv(),
|
||||||
"GOPATH="+buildGoPath,
|
"GOPATH="+buildGoPath,
|
||||||
"GOBIN="+binDir,
|
|
||||||
)
|
)
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
if *quiet {
|
if *quiet {
|
||||||
|
@ -237,29 +247,16 @@ func main() {
|
||||||
log.Fatalf("Error building main binaries: %v\n%s", err, output.String())
|
log.Fatalf("Error building main binaries: %v\n%s", err, output.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if buildAll {
|
// Copy the binaries from $CAMROOT/tmp/build-gopath-foo/bin to $CAMROOT/bin.
|
||||||
// Now do another build, but including everything, just to make
|
// This is necessary (instead of just using GOBIN environment variable) so
|
||||||
// sure everything compiles. But if there are any binaries (package main) in here,
|
// each tmp/build-gopath-* has its own binary modtimes for its own build tags.
|
||||||
// put them in a junk GOBIN (the default location), rather than polluting
|
// Otherwise switching sqlite true<->false doesn't necessarily cause a rebuild.
|
||||||
// the GOBIN that the user will look in.
|
// See camlistore.org/issue/229
|
||||||
cmd = exec.Command("go", append(baseArgs,
|
for _, targ := range targs {
|
||||||
"camlistore.org/pkg/...",
|
src := exeName(filepath.Join(actualBinDir(filepath.Join(buildGoPath, "bin")), pathpkg.Base(targ)))
|
||||||
"camlistore.org/server/...",
|
dst := exeName(filepath.Join(actualBinDir(binDir), pathpkg.Base(targ)))
|
||||||
"camlistore.org/third_party/...",
|
if err := mirrorFile(src, dst); err != nil {
|
||||||
)...)
|
log.Fatalf("Error copying %s to %s: %v", src, dst, err)
|
||||||
cmd.Env = append(cleanGoEnv(), "GOPATH="+buildGoPath)
|
|
||||||
if *quiet {
|
|
||||||
cmd.Stdout = &output
|
|
||||||
cmd.Stderr = &output
|
|
||||||
} else {
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
}
|
|
||||||
if *verbose {
|
|
||||||
log.Printf("Running full go install with args %s", cmd.Args)
|
|
||||||
}
|
|
||||||
if err := cmd.Run(); err != nil {
|
|
||||||
log.Fatalf("Error building full install: %v\n%s", err, output.String())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,3 +713,10 @@ func quote(dest *bytes.Buffer, bs []byte) {
|
||||||
}
|
}
|
||||||
dest.WriteByte('"')
|
dest.WriteByte('"')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exeName(s string) string {
|
||||||
|
if *buildOS == "windows" {
|
||||||
|
return s + ".exe"
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue