make.go: allow for installation of genfileembed

With -embed_static, genfileembed is built, and
installed in tmp/build-gopath/bin

Change-Id: Ibca9c90349a7cf8d43e1f865792802772e9a08d3
This commit is contained in:
mpl 2013-06-19 01:04:27 +02:00
parent 3a8dc35241
commit 46d6f4d9ce
1 changed files with 34 additions and 1 deletions

35
make.go
View File

@ -118,7 +118,12 @@ func main() {
log.Fatal(err)
}
wantDestFile[closureEmbed] = true
if err = buildGenfileembed(goPath); err != nil {
log.Fatal(err)
}
}
// because we do not want the main install to install genfileembed as well.
wantDestFile[filepath.Join(buildSrcPath, "pkg", "fileembed", "genfileembed", "genfileembed.go")] = false
deleteUnwantedOldMirrorFiles(buildSrcPath)
@ -175,6 +180,34 @@ func cleanGoEnv() (clean []string) {
return
}
func buildGenfileembed(goPath string) error {
args := []string{"install", "-v"}
if *all {
args = append(args, "-a")
}
args = append(args,
"camlistore.org/pkg/fileembed/genfileembed",
)
cmd := exec.Command("go", args...)
// We don't even need to set GOBIN as it defaults to $GOPATH/bin
// and that is where we want genfileembed to go.
cmd.Env = append(cleanGoEnv(),
"GOPATH="+goPath,
)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if *verbose {
log.Printf("Running go with args %s", args)
}
if err := cmd.Run(); err != nil {
return fmt.Errorf("Error building genfileembed: %v", err)
}
if *verbose {
log.Printf("genfileembed installed in %s", filepath.Join(goPath, "bin"))
}
return nil
}
// getVersion returns the version of Camlistore. Either from a VERSION file at the root,
// or from git.
func getVersion(camRoot string) string {
@ -224,7 +257,7 @@ func mirrorDir(src, dst string) error {
}
base := fi.Name()
if fi.IsDir() {
if base == "testdata" || base == "genfileembed" ||
if base == "testdata" ||
strings.HasSuffix(path, "pkg/misc/closure/genclosuredeps") ||
strings.HasSuffix(path, "third_party/closure") ||
(base == "cmd" && strings.Contains(path, "github.com/camlistore/goexif")) {