...

Text file src/go.uber.org/atomic/Makefile

Documentation: go.uber.org/atomic

     1# Directory to place `go install`ed binaries into.
     2export GOBIN ?= $(shell pwd)/bin
     3
     4GOLINT = $(GOBIN)/golint
     5GEN_ATOMICINT = $(GOBIN)/gen-atomicint
     6GEN_ATOMICWRAPPER = $(GOBIN)/gen-atomicwrapper
     7STATICCHECK = $(GOBIN)/staticcheck
     8
     9GO_FILES ?= $(shell find . '(' -path .git -o -path vendor ')' -prune -o -name '*.go' -print)
    10
    11# Also update ignore section in .codecov.yml.
    12COVER_IGNORE_PKGS = \
    13	go.uber.org/atomic/internal/gen-atomicint \
    14	go.uber.org/atomic/internal/gen-atomicwrapper
    15
    16.PHONY: build
    17build:
    18	go build ./...
    19
    20.PHONY: test
    21test:
    22	go test -race ./...
    23
    24.PHONY: gofmt
    25gofmt:
    26	$(eval FMT_LOG := $(shell mktemp -t gofmt.XXXXX))
    27	gofmt -e -s -l $(GO_FILES) > $(FMT_LOG) || true
    28	@[ ! -s "$(FMT_LOG)" ] || (echo "gofmt failed:" && cat $(FMT_LOG) && false)
    29
    30$(GOLINT):
    31	cd tools && go install golang.org/x/lint/golint
    32
    33$(STATICCHECK):
    34	cd tools && go install honnef.co/go/tools/cmd/staticcheck
    35
    36$(GEN_ATOMICWRAPPER): $(wildcard ./internal/gen-atomicwrapper/*)
    37	go build -o $@ ./internal/gen-atomicwrapper
    38
    39$(GEN_ATOMICINT): $(wildcard ./internal/gen-atomicint/*)
    40	go build -o $@ ./internal/gen-atomicint
    41
    42.PHONY: golint
    43golint: $(GOLINT)
    44	$(GOLINT) ./...
    45
    46.PHONY: staticcheck
    47staticcheck: $(STATICCHECK)
    48	$(STATICCHECK) ./...
    49
    50.PHONY: lint
    51lint: gofmt golint staticcheck generatenodirty
    52
    53# comma separated list of packages to consider for code coverage.
    54COVER_PKG = $(shell \
    55	go list -find ./... | \
    56	grep -v $(foreach pkg,$(COVER_IGNORE_PKGS),-e "^$(pkg)$$") | \
    57	paste -sd, -)
    58
    59.PHONY: cover
    60cover:
    61	go test -coverprofile=cover.out -coverpkg  $(COVER_PKG) -v ./...
    62	go tool cover -html=cover.out -o cover.html
    63
    64.PHONY: generate
    65generate: $(GEN_ATOMICINT) $(GEN_ATOMICWRAPPER)
    66	go generate ./...
    67
    68.PHONY: generatenodirty
    69generatenodirty:
    70	@[ -z "$$(git status --porcelain)" ] || ( \
    71		echo "Working tree is dirty. Commit your changes first."; \
    72		git status; \
    73		exit 1 )
    74	@make generate
    75	@status=$$(git status --porcelain); \
    76		[ -z "$$status" ] || ( \
    77		echo "Working tree is dirty after `make generate`:"; \
    78		echo "$$status"; \
    79		echo "Please ensure that the generated code is up-to-date." )

View as plain text