summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-29 00:16:18 -0500
committerJeff Carr <[email protected]>2025-10-29 00:16:18 -0500
commitae316f5a4ec8cc8ba29b1bc22b3e563812cb494b (patch)
tree3584a2636750d39992751192ff0421374b86b0f6
parent7dc4eb2609ee5728abd4dc5359a02a058d9c7dab (diff)
use the git version in the binary itself. fix BuildDateHEADv0.22.172v0.22.171masterdevel
-rw-r--r--Makefile4
-rw-r--r--build.go12
2 files changed, 11 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 82a4cb2..43993eb 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,8 @@ VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%s)
run: clean goimports vet install
- # go-deb --buildversion "4"
- VERBOSE=true go-deb --keep-files --arch riscv64 --buildversion "4"
+ VERBOSE=true go-deb --keep-files --buildversion "4"
+ # VERBOSE=true go-deb --keep-files --arch riscv64 --buildversion "4"
# builds a .deb of go-deb and writes the file here in this directory
deb.default:
diff --git a/build.go b/build.go
index 013137b..b47e887 100644
--- a/build.go
+++ b/build.go
@@ -8,12 +8,12 @@ import (
"strings"
"time"
- "go.wit.com/lib/cobol"
"go.wit.com/lib/debian"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/argvpb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
+ "google.golang.org/protobuf/types/known/timestamppb"
)
func buildPackage(repo *gitpb.Repo) (bool, error) {
@@ -102,7 +102,13 @@ func buildPackage(repo *gitpb.Repo) (bool, error) {
// * -s: Omit the symbol table and debug information.
ldflags += "-s -w "
}
- ldflags += "-X main.VERSION=" + version + " "
+ gitversion := repo.GetCurrentVersion()
+ if gitversion == "" {
+ ldflags += "-X main.VERSION=" + version + " "
+ } else {
+ // use the more accurate git version in the binary itself
+ ldflags += "-X main.VERSION=" + gitversion + " "
+ }
ldflags += "-X main.BUILDTIME=" + datestamp + " "
ldflags += "-X main.GUIVERSION=" + version + "" // todo: git this from the filesystem
cmd = append(cmd, "-ldflags", ldflags)
@@ -114,7 +120,7 @@ func buildPackage(repo *gitpb.Repo) (bool, error) {
cmd = append(cmd, "-ldflags", "-X "+flag)
}
- me.pb.DebInfo.BuildDate = cobol.Time(time.Now())
+ me.pb.BuildDate = timestamppb.New(time.Now())
err := repo.RunVerbose(cmd)
if err != nil {
return false, fmt.Errorf("go build err %v", err)