mirror of
https://github.com/octoleo/restic.git
synced 2024-10-31 19:02:32 +00:00
Allow building without git
This commit is contained in:
parent
cd4cc1daec
commit
38f1a8d0a9
14
build.go
14
build.go
@ -190,7 +190,8 @@ func gitVersion() string {
|
|||||||
"--long", "--tags", "--dirty", "--always")
|
"--long", "--tags", "--dirty", "--always")
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
die("git describe returned error: %v\n", err)
|
verbosePrintf("git describe returned error: %v\n", err)
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
version := strings.TrimSpace(string(out))
|
version := strings.TrimSpace(string(out))
|
||||||
@ -257,16 +258,19 @@ func main() {
|
|||||||
die("copying files from %v to %v failed: %v\n", root, gopath, err)
|
die("copying files from %v to %v failed: %v\n", root, gopath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
version := getVersion()
|
|
||||||
compileTime := time.Now().Format(timeFormat)
|
|
||||||
output := "restic"
|
output := "restic"
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
output = "restic.exe"
|
output = "restic.exe"
|
||||||
}
|
}
|
||||||
|
version := getVersion()
|
||||||
|
compileTime := time.Now().Format(timeFormat)
|
||||||
|
ldflags := fmt.Sprintf("-s -X main.compiledAt %q", compileTime)
|
||||||
|
if version != "" {
|
||||||
|
ldflags = fmt.Sprintf("%s -X main.version %q", ldflags, version)
|
||||||
|
}
|
||||||
args := []string{
|
args := []string{
|
||||||
"-tags", strings.Join(buildTags, " "),
|
"-tags", strings.Join(buildTags, " "),
|
||||||
"-ldflags", fmt.Sprintf(`-s -X main.version %q -X main.compiledAt %q`, version, compileTime),
|
"-ldflags", ldflags,
|
||||||
"-o", output, "github.com/restic/restic/cmd/restic",
|
"-o", output, "github.com/restic/restic/cmd/restic",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user