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

View File

@ -34,5 +34,5 @@ func init() {
} }
func (args) Version() string { 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") os.Setenv("GO111MODULE", "off")
cmd := []string{"go", "build", "-v", "-x"} 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 // add some standard golang flags
vldflag := "-X main.VERSION=" + version ldflags := "-X main.VERSION=" + version + " "
gldflag := "-X main.GUIVERSION=" + version // todo: git this from the filesystem ldflags += "-X main.BUILDTIME=" + datestamp + " "
// timeflag := "-X main.BUILDTIME='${BUILDTIME}'" ldflags += "-X main.GUIVERSION=" + version + "" // todo: git this from the filesystem
cmd = append(cmd, "-ldflags", vldflag) cmd = append(cmd, "-ldflags", ldflags)
cmd = append(cmd, "-ldflags", gldflag)
// add any flags from the command line // add any flags from the command line
// this might not actually work
// todo: test this
for _, flag := range argv.Ldflags { for _, flag := range argv.Ldflags {
cmd = append(cmd, "-ldflags", "-X "+flag) cmd = append(cmd, "-ldflags", "-X "+flag)
} }

View File

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