git.lukeshu.com/go/lowmemjson@v0.3.9-0.20230723050957-72f6d13f6fb2/Makefile (about) 1 # Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com> 2 # 3 # SPDX-License-Identifier: GPL-2.0-or-later 4 5 SHELL = bash 6 7 # main 8 9 check: 10 go test -race ./... 11 .PHONY: check 12 13 lint: tools/bin/golangci-lint 14 tools/bin/golangci-lint run ./... 15 .PHONY: lint 16 17 # generate 18 19 generate/files = LICENSE.gpl-2.0.txt 20 21 generate: generate-clean 22 $(MAKE) $(generate/files) 23 .PHONY: generate 24 25 generate-clean: 26 rm -f $(generate/files) 27 .PHONY: generate-clean 28 29 LICENSE.gpl-2.0.txt: 30 curl https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt > $@ 31 32 # tools 33 34 tools/bin/%: tools/src/%/pin.go tools/src/%/go.mod 35 cd $(<D) && GOOS= GOARCH= go build -o $(abspath $@) $$(sed -En 's,^import "(.*)".*,\1,p' pin.go) 36 37 # go mod tidy 38 39 goversion = 1.18 40 41 go-mod-tidy: 42 .PHONY: go-mod-tidy 43 44 go-mod-tidy: go-mod-tidy/main 45 go-mod-tidy/main: 46 rm -f go.sum 47 go mod tidy -go 1.20 -compat $(goversion) 48 .PHONY: go-mod-tidy/main 49 50 go-mod-tidy: $(patsubst tools/src/%/go.mod,go-mod-tidy/tools/%,$(wildcard tools/src/*/go.mod)) 51 go-mod-tidy/tools/%: tools/src/%/go.mod 52 rm -f tools/src/$*/go.sum 53 cd tools/src/$* && go mod tidy -go $(goversion) -compat $(goversion) 54 .PHONY: go-mod-tidy/tools/% 55 56 # utilities for managing borrowed tests 57 58 borrowed.patch: stock patched 59 diff -ruN $^ > $@ || true 60 stock: FORCE 61 rm -rf $@ $@.tmp 62 mkdir $@.tmp 63 echo module ignore > $@.tmp/go.mod 64 set -e; for file in "$$(go env GOROOT)"/src/encoding/json/{*_test.go,tags.go}; do \ 65 cp "$$file" $@.tmp/borrowed_$${file##*/}; \ 66 done 67 rm -f $@.tmp/borrowed_fold_test.go 68 mv $@.tmp $@ 69 patched: FORCE 70 rm -rf $@ $@.tmp 71 mkdir $@.tmp 72 echo module ignore > $@.tmp/go.mod 73 cp $$(git ls-files :*/borrowed_*.go :borrowed_*.go :!borrowed_misc.go :!*/borrowed_misc.go) $@.tmp 74 mv $@.tmp $@ 75 76 .PHONY: FORCE