Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. Go's
  15. # Windows port supports race detection, but requires GCC, so we don't enable it
  16. # there.
  17. test:
  18. go test $(shell ./tools/run-race.sh) ./...
  19. # Generate a basic test coverage report. This will open the report in your
  20. # browser. See also https://codecov.io/gh/elves/elvish/.
  21. cover:
  22. go test -coverprofile=cover -coverpkg=./pkg/... ./pkg/...
  23. go tool cover -html=cover
  24. go tool cover -func=cover | tail -1 | awk '{ print "Overall coverage:", $$NF }'
  25. # Ensure the style of Go and Markdown source files is consistent.
  26. style:
  27. find . -name '*.go' | xargs goimports -w
  28. find . -name '*.go' | xargs gofmt -s -w
  29. find . -name '*.md' | xargs prettier --tab-width 4 --prose-wrap always --write
  30. # Check if the style of the Go and Markdown files is correct without modifying
  31. # those files.
  32. checkstyle: checkstyle-go checkstyle-md
  33. checkstyle-go:
  34. ./tools/checkstyle-go.sh
  35. checkstyle-md:
  36. ./tools/checkstyle-md.sh
  37. .SILENT: checkstyle-go checkstyle-md
  38. .PHONY: default get generate test style checkstyle checkstyle-go checkstyle-md cover