M Makefile => Makefile +5 -2
@@ 2,8 2,11 @@ proj_dir := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
.DEFAULT_GOAL:= build
-build:
- GOPATH=$$HOME/.local/go go build $(proj_dir)/obpmg.go
+build: clean test
+ GOPATH=$$HOME/.local/go go build -buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags="-linkmode=external -s -w -X 'main.Version=$$(git describe --tags)'" $(proj_dir)/obpmg.go
+
+clean:
+ rm -f $(proj_dir)/obpmg
run:
GOPATH=$$HOME/.local/go go run $(proj_dir)/obpmg.go
M obpmg.go => obpmg.go +3 -3
@@ 24,12 24,12 @@ import (
"sort"
"time"
- //TODO: use this instead of cli https://github.com/skeeto/optparse-go
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v2"
)
-const obpmgVersion = "v0.5"
+// Version is intended to be set at link-time (see the project Makefile)
+var Version string = "0000"
type xmlAction struct {
XMLName xml.Name `xml:"action"`
@@ 106,7 106,7 @@ func cliApp() *cli.App {
app := &cli.App{
Name: "obpmg",
- Version: obpmgVersion,
+ Version: Version,
Compiled: time.Now(),
Usage: "Generate an Openbox pipe menu from a yaml file.",
UsageText: "obpmg [--nosort] -f /path/to/myfile.yml",