From 9c6a232bb6c9746678e58d69b2592a52fd118835 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 16 Nov 2024 00:06:21 -0600 Subject: [PATCH] fix build --- Makefile | 35 +++++++++++++++++++++-------------- argv.go | 10 ++++++++-- main.go | 4 ++++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index ec8440a..b01391a 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,28 @@ .PHONY: debian -run: build - reset - cp -f control-panel-dns ~/ - sudo ./control-panel-dns +VERSION = $(shell git describe --tags) +BUILDTIME = $(shell date +%Y.%m.%d) + +all: build + ./control-panel-dns build: - -mkdir -p resources/ - -cp ~/go/src/go.wit.com/toolkits/*.so resources/ - GO111MODULE="off" go build -v + GO111MODULE=off go build \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +verbose: + GO111MODULE=off go build -v -x \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +install: + GO111MODULE=off go install \ + -ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}" + +# embed the toolkit plugins in the binary +embed: + -rm resources/*.so + touch resources/blank.so + cp -a ~/go/src/go.wit.com/toolkits/*.so resources/ goimports: goimports -w *.go @@ -41,9 +55,6 @@ nocui: reset build check-git-clean: @git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1) -install: - go install -v go.wit.com/control-panel-dns@latest - build-release: reset go get -v -u -x . @@ -71,10 +82,6 @@ clean: -rm -f resources/*.so -rm *.deb -debian: - cd debian && make - -wit mirrors - netlink: GO111MODULE="off" go get -v -u github.com/vishvananda/netlink diff --git a/argv.go b/argv.go index e86eb08..f9bb15d 100644 --- a/argv.go +++ b/argv.go @@ -10,12 +10,14 @@ import ( "go.wit.com/log" ) -var args struct { +var argv args + +type args struct { Daemon bool `arg:"--daemon" help:"run without a gui"` } func init() { - arg.MustParse(&args) + arg.MustParse(&argv) if debugger.ArgDebug() { log.Info("cmd line --debugger == true") @@ -25,3 +27,7 @@ func init() { }() } } + +func (args) Version() string { + return "go-clone " + VERSION + " Built on " + BUILDTIME +} diff --git a/main.go b/main.go index 36e98f0..8c46951 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,10 @@ import ( "go.wit.com/lib/gui/linuxstatus" ) +// sent via -ldflags +var VERSION string +var BUILDTIME string + //go:embed resources/* var resToolkit embed.FS