From 00f822df8bcecc3b40bdc39f0cd5dfb6d1efc45e Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 15 Aug 2024 07:33:43 -0300 Subject: Add src/version.go --- .gitignore | 1 + Makefile | 17 ++++++++++++----- src/wscat.go | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 75d542a..f4905f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /*.bin +/src/version.go /src/*.a /src/*.bin /tests/*.a diff --git a/Makefile b/Makefile index 996066e..a170749 100644 --- a/Makefile +++ b/Makefile @@ -38,10 +38,12 @@ objects = \ sources = \ src/$(NAME).go \ + src/version.go \ src/main.go \ derived-assets = \ + src/version.go \ $(objects) \ src/main.bin \ tests/main.bin \ @@ -59,23 +61,28 @@ all: $(derived-assets) $(objects): Makefile -src/$(NAME).a: src/$(NAME).go +src/$(NAME).a: src/$(NAME).go src/version.go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I $(@D) $*.go src/version.go + src/main.a: src/main.go src/$(NAME).a tests/main.a: tests/main.go tests/$(NAME).a -src/$(NAME).a src/main.a tests/main.a: +src/main.a tests/main.a: go tool compile $(GOCFLAGS) -o $@ -p $(*F) -I $(@D) $*.go -tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go - go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go src/$(*F).go +tests/$(NAME).a: tests/$(NAME).go src/$(NAME).go src/version.go + go tool compile $(GOCFLAGS) -o $@ -p $(*F) $*.go src/$(*F).go src/version.go src/main.bin: src/main.a tests/main.bin: tests/main.a src/main.bin tests/main.bin: - go tool link $(GOLDFLAGS) -o $@ -L $(@D) $*.a + go tool link $(GOLDFLAGS) -o $@ -L $(@D) --extldflags '$(LDLIBS)' $*.a $(NAME).bin: src/main.bin ln -fs $? $@ +src/version.go: Makefile + echo 'package $(NAME); var version = "$(VERSION)"' > $@ + tests.bin-check = \ diff --git a/src/wscat.go b/src/wscat.go index 51e5157..2fff3f5 100644 --- a/src/wscat.go +++ b/src/wscat.go @@ -231,6 +231,7 @@ import ( "errors" "fmt" "io" + "log/slog" "net" "net/http" "net/url" @@ -2552,7 +2553,7 @@ func Start(toAddr string, listener net.Listener) { func Main() { - g.Init() + g.Init(slog.Group("versions", "gobang", g.Version, "this", version)) args := parseArgs(os.Args) listener := listen(args.fromAddr) Start(args.toAddr, listener) -- cgit v1.2.3