Makefile 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ELVISH_MAKE_BIN ?= $(shell go env GOPATH)/bin/elvish
  2. default: test get
  3. get:
  4. export CGO_ENABLED=0; \
  5. if go env GOOS GOARCH | egrep -qx '(windows .*|linux (amd64|arm64))'; then \
  6. export GOFLAGS=-buildmode=pie; \
  7. fi; \
  8. mkdir -p $(shell dirname $(ELVISH_MAKE_BIN))
  9. go build -o $(ELVISH_MAKE_BIN) -trimpath -ldflags \
  10. "-X src.elv.sh/pkg/buildinfo.VersionSuffix=-dev.$$(git rev-parse HEAD)$$(git diff HEAD --quiet || printf +%s `uname -n`) \
  11. -X src.elv.sh/pkg/buildinfo.Reproducible=true" ./cmd/elvish
  12. generate:
  13. go generate ./...
  14. # Run unit tests, with race detection if the platform supports it.
  15. test:
  16. go test $(shell ./tools/run-race.sh) ./...
  17. # Generate a basic test coverage report, and open it in the browser. See also
  18. # https://apps.codecov.io/gh/elves/elvish/.
  19. cover:
  20. go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
  21. ./tools/prune-cover.sh .codecov.yml cover
  22. go tool cover -html=cover
  23. go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }'
  24. # Ensure the style of Go and Markdown source files is consistent.
  25. style:
  26. find . -name '*.go' | xargs goimports -w
  27. find . -name '*.go' | xargs gofmt -s -w
  28. find . -name '*.md' | xargs prettier --tab-width 4 --prose-wrap always --write
  29. # Check if the style of the Go and Markdown files is correct without modifying
  30. # those files.
  31. checkstyle: checkstyle-go checkstyle-md
  32. checkstyle-go:
  33. ./tools/checkstyle-go.sh
  34. checkstyle-md:
  35. ./tools/checkstyle-md.sh
  36. .SILENT: checkstyle-go checkstyle-md
  37. .PHONY: default get generate test style checkstyle checkstyle-go checkstyle-md cover