summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 18:42:28 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-07-08 18:42:28 -0600
commit91bf7111d67c02d9d262f34a6e864ff046f4d1ef (patch)
tree445acc290bf69d6a9b9087d2be77940160b48798 /Makefile
Add a Makefile that runs lint and stuff
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile37
1 files changed, 37 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..73263d0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,37 @@
+# main
+
+build:
+ go build -o bin/ ./cmd/...
+.PHONY: build
+
+check:
+ go test -race ./...
+.PHONY: check
+
+lint: tools/bin/golangci-lint
+ tools/bin/golangci-lint run ./...
+.PHONY: lint
+
+# tools
+
+tools/bin/%: tools/src/%/pin.go tools/src/%/go.mod
+ cd $(<D) && GOOS= GOARCH= go build -o $(abspath $@) $$(sed -En 's,^import "(.*)".*,\1,p' pin.go)
+
+# go mod tidy
+
+goversion = 1.18
+
+go-mod-tidy:
+.PHONY: go-mod-tidy
+
+go-mod-tidy: go-mod-tidy/main
+go-mod-tidy/main:
+ rm -f go.sum
+ go mod tidy -go $(goversion) -compat $(goversion)
+.PHONY: go-mod-tidy/main
+
+go-mod-tidy: $(patsubst tools/src/%/go.mod,go-mod-tidy/tools/%,$(wildcard tools/src/*/go.mod))
+go-mod-tidy/tools/%: tools/src/%/go.mod
+ rm -f tools/src/$*/go.sum
+ cd tools/src/$* && go mod tidy -go $(goversion) -compat $(goversion)
+.PHONY: go-mod-tidy/tools/%