github.com/kolbycrouch/elvish@v0.14.1-0.20210614162631-215b9ac1c423/Makefile (about)

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