From 260e52050562281a90b970c44e8816afb5f4dbaf Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 20 Jan 2023 12:00:32 +0100 Subject: intermediate commit * Add static analysis and improve Makefile * Implement hints from static code analysis --- go/Makefile | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'go/Makefile') diff --git a/go/Makefile b/go/Makefile index 6678a0fa..c38e3143 100644 --- a/go/Makefile +++ b/go/Makefile @@ -1,30 +1,42 @@ -PACKAGES := assets game server client webtools ui +PACKAGES := assets game server client ui APPS := server client OBJS := $(foreach app,$(APPS),$(app)/$(app)) WASM := client/client.wasm webtools/webtools.wasm -.PHONY: all fmt test $(OBJS) $(WASM) -all: $(OBJS) $(WASM) +GOFMT := go fmt -server/server: - @echo Building Server ... - pushd $(@D) >/dev/null && go build && popd >/dev/null +.PHONY: all fmt test check $(OBJS) $(WASM) +all: $(OBJS) $(WASM) -client/client: - @echo Building Client ... - pushd $(@D) >/dev/null && go build && popd >/dev/null +.PHONY: client server +client: client/client +server: server/server -client/client.wasm: - @echo Building Client.wasm ... - pushd $(@D) >/dev/null && env GOOS=js GOARCH=wasm go build -o $(@F) && popd >/dev/null +$(OBJS): + @echo Building $(@F) + @pushd $(@D) >/dev/null && go build && popd >/dev/null -webtools/webtools.wasm: - @echo Building Webtools.wasm ... - pushd $(@D) >/dev/null && env GOOS=js GOARCH=wasm go build -o $(@F) && popd >/dev/null +*/*.wasm: + @echo Building $(@F) ... + @pushd $(@D) >/dev/null && env GOOS=js GOARCH=wasm go build -o $(@F) && popd >/dev/null fmt: - set -e; for package in $(PACKAGES); do pushd $$package >/dev/null && go fmt && popd >/dev/null; done + @set -e; for package in $(PACKAGES) webtools; do \ + pushd $$package >/dev/null && $(GOFMT) && popd >/dev/null; \ + done test: - for package in $(PACKAGES); do pushd $$package >/dev/null && go test && popd >/dev/null; done + @STATUS=0; \ + for package in $(PACKAGES); do \ + if pushd "$$package" >/dev/null; then \ + go test; \ + status="$$?"; \ + if [ "$$status" -ne 0 ]; then STATUS="$$status"; fi; \ + popd >/dev/null; \ + fi; \ + done; \ + exit "$$STATUS" + +check: + golangci-lint run --skip-dirs webtools -- cgit v1.2.3