From cae2d31df4fda64a0baf89acec3bd2d896902eb9 Mon Sep 17 00:00:00 2001 From: sewn Date: Sat, 11 Nov 2023 12:19:40 +0300 Subject: [PATCH] Makefile: introduce version handling --- Makefile | 4 +++- cmd/vinegar/vinegar.go | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3a9947b6..741755a9 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +VERSION = v1.5.8 + PREFIX = /usr BINPREFIX = $(PREFIX)/libexec/vinegar APPPREFIX = $(PREFIX)/share/applications @@ -9,7 +11,7 @@ GO = go GO_LDFLAGS = -s -w VINEGAR_ICONPATH = $(ICONPREFIX)/64x64/apps/$(FLATPAK).png -VINEGAR_LDFLAGS = $(GO_LDFLAGS) -X main.BinPrefix=$(BINPREFIX) +VINEGAR_LDFLAGS = $(GO_LDFLAGS) -X main.BinPrefix=$(BINPREFIX) -X main.Version=$(VERSION) VINEGAR_GOFLAGS = --tags nowayland,novulkan all: vinegar robloxmutexer.exe diff --git a/cmd/vinegar/vinegar.go b/cmd/vinegar/vinegar.go index 2dec0a45..3553ba2c 100644 --- a/cmd/vinegar/vinegar.go +++ b/cmd/vinegar/vinegar.go @@ -19,12 +19,16 @@ import ( "github.com/vinegarhq/vinegar/wine" ) -var BinPrefix string +var ( + BinPrefix string + Version string +) func usage() { fmt.Fprintln(os.Stderr, "usage: vinegar [-config filepath] player|studio [args...]") - fmt.Fprintln(os.Stderr, "usage: vinegar [-config filepath] exec prog [args...]") - fmt.Fprintln(os.Stderr, " vinegar [-config filepath] edit|kill|uninstall|delete|install-webview2|winetricks|sysinfo") + fmt.Fprintln(os.Stderr, " vinegar [-config filepath] exec prog [args...]") + fmt.Fprintln(os.Stderr, " vinegar [-config filepath] delete|edit|uninstall|version") + fmt.Fprintln(os.Stderr, " vinegar [-config filepath] kill|install-webview2|winetricks|sysinfo") os.Exit(1) } @@ -38,7 +42,7 @@ func main() { switch cmd { // These commands don't require a configuration - case "delete", "edit", "uninstall": + case "delete", "edit", "uninstall", "version": switch cmd { case "delete": Delete() @@ -48,6 +52,8 @@ func main() { } case "uninstall": Uninstall() + case "version": + fmt.Println("Vinegar", Version) } // These commands (except player & studio) don't require a configuration, // but they require a wineprefix, hence wineroot of configuration is required. @@ -132,13 +138,14 @@ func Sysinfo(pfx *wine.Prefix) { } info := `## System information +* Vinegar: %s * Distro: %s * Processor: %s * Supports AVX: %t * Kernel: %s * Wine: %s` - fmt.Printf(info, sysinfo.Distro, sysinfo.CPU, sysinfo.HasAVX, sysinfo.Kernel, ver) + fmt.Printf(info, Version, sysinfo.Distro, sysinfo.CPU, sysinfo.HasAVX, sysinfo.Kernel, ver) if sysinfo.InFlatpak { fmt.Println("* Flatpak: [x]") }