github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/Makefile (about) 1 ELVISH_MAKE_BIN ?= $(shell go env GOPATH)/bin/elvish 2 ELVISH_PLUGIN_SUPPORT ?= 0 3 4 # Treat 0 as false and everything else as true (consistent with CGO_ENABLED). 5 ifeq ($(ELVISH_PLUGIN_SUPPORT), 0) 6 REPRODUCIBLE := true 7 else 8 REPRODUCIBLE := false 9 endif 10 11 default: test get 12 13 get: 14 export CGO_ENABLED=$(ELVISH_PLUGIN_SUPPORT); \ 15 if go env GOOS GOARCH | egrep -qx '(windows .*|linux (amd64|arm64))'; then \ 16 export GOFLAGS=-buildmode=pie; \ 17 fi; \ 18 mkdir -p $(shell dirname $(ELVISH_MAKE_BIN)) 19 go build -o $(ELVISH_MAKE_BIN) -trimpath -ldflags \ 20 "-X github.com/markusbkk/elvish/pkg/buildinfo.VersionSuffix=-dev.$$(git rev-parse HEAD)$$(git diff HEAD --quiet || printf +%s `uname -n`) \ 21 -X github.com/markusbkk/elvish/pkg/buildinfo.Reproducible=$(REPRODUCIBLE)" ./cmd/elvish 22 23 generate: 24 go generate ./... 25 26 # Run unit tests, with race detection if the platform supports it. 27 test: 28 go test $(shell ./tools/run-race.sh) ./... 29 cd website; go test $(shell ./tools/run-race.sh) ./... 30 31 # Generate a basic test coverage report, and open it in the browser. See also 32 # https://apps.codecov.io/gh/elves/elvish/. 33 cover: 34 go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/... 35 ./tools/prune-cover.sh .codecov.yml cover 36 go tool cover -html=cover 37 go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }' 38 39 # Ensure the style of Go and Markdown source files is consistent. 40 style: 41 find . -name '*.go' | xargs goimports -w 42 find . -name '*.go' | xargs gofmt -s -w 43 find . -name '*.md' | xargs prettier --write 44 45 # Check if the style of the Go and Markdown files is correct without modifying 46 # those files. 47 checkstyle: checkstyle-go checkstyle-md 48 49 checkstyle-go: 50 ./tools/checkstyle-go.sh 51 52 checkstyle-md: 53 ./tools/checkstyle-md.sh 54 55 lint: 56 ./tools/lint.sh 57 58 codespell: 59 codespell --skip .git 60 61 check-content: 62 ./tools/check-content.sh 63 64 .SILENT: checkstyle-go checkstyle-md lint 65 .PHONY: default get generate test cover style checkstyle checkstyle-go checkstyle-md lint codespell check-content