fix ldflags

This commit is contained in:
Jeff Carr 2024-11-15 10:51:45 -06:00
parent 2101ed1ae9
commit ff564380a7
4 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,7 @@
.PHONY: debian
VERSION = $(shell git describe --tags)
DATE = $(shell date +%Y.%m.%d)
run: build
./go-deb --repo go.wit.com/apps/autotypist
@ -17,11 +18,11 @@ build:
touch resources/blank.so
-cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ # embed the toolkit plugins
GO111MODULE="off" go build -v \
-ldflags "-X main.VERSION=${VERSION} -X gui.GUIVERSION=${VERSION}"
-ldflags "-X main.VERSION=${VERSION} -X main.DATE=${DATE} -X gui.GUIVERSION=${VERSION}"
install:
GO111MODULE="off" go install -v \
-ldflags "-X main.VERSION=${VERSION} -X gui.GUIVERSION=${VERSION}"
-ldflags "-X main.VERSION=${VERSION} -X main.DATE=${DATE} -X gui.GUIVERSION=${VERSION}"
goimports:
goimports -w *.go

View File

@ -34,5 +34,5 @@ func init() {
}
func (args) Version() string {
return "go-clone " + VERSION
return "go-clone " + VERSION + " Built on " + DATE
}

View File

@ -72,14 +72,19 @@ func (c *controlBox) buildPackage() (bool, error) {
os.Setenv("GO111MODULE", "off")
cmd := []string{"go", "build", "-v", "-x"}
// set standard ldflag options
now := time.Now()
datestamp := now.UTC().Format("2006/01/02_1504_UTC")
log.Info("datestamp =", datestamp)
// add some standard golang flags
vldflag := "-X main.VERSION=" + version
gldflag := "-X main.GUIVERSION=" + version // todo: git this from the filesystem
// timeflag := "-X main.BUILDTIME='${BUILDTIME}'"
cmd = append(cmd, "-ldflags", vldflag)
cmd = append(cmd, "-ldflags", gldflag)
ldflags := "-X main.VERSION=" + version + " "
ldflags += "-X main.BUILDTIME=" + datestamp + " "
ldflags += "-X main.GUIVERSION=" + version + "" // todo: git this from the filesystem
cmd = append(cmd, "-ldflags", ldflags)
// add any flags from the command line
// this might not actually work
// todo: test this
for _, flag := range argv.Ldflags {
cmd = append(cmd, "-ldflags", "-X "+flag)
}

View File

@ -14,6 +14,7 @@ import (
// sent from -ldflags
var VERSION string
var DATE string
// This is the beginning of the binary tree of GUI widgets
var myGui *gui.Node
@ -27,8 +28,6 @@ var basicWindow *gadgets.BasicWindow
var resources embed.FS
func main() {
// RunTest()
// os.Exit(0)
if argv.Repo == "" {
log.Info("You need to tell me what repo you want to work on")
println("")