51 lines
1.3 KiB
Makefile
Raw Normal View History

2017-03-13 19:10:51 +04:00
DIST_DIRS := find * -type d -exec
VERSION := $(shell perl -ne '/^var version.*"([^"]+)".*$$/ && print "v$$1\n"' main.go)
all: build test install
2018-04-03 12:39:58 +02:00
########################################
### Build
2017-03-13 19:10:51 +04:00
build:
2018-04-03 12:39:58 +02:00
@go build
2017-03-13 19:10:51 +04:00
install:
2018-04-03 12:39:58 +02:00
@go install
2017-03-13 19:10:51 +04:00
test:
2018-04-03 12:39:58 +02:00
@go test -race
2017-03-13 19:10:51 +04:00
2018-04-03 12:39:58 +02:00
build-all: check_tools
rm -rf ./dist
2017-03-13 19:10:51 +04:00
gox -verbose \
2017-12-07 13:25:35 -06:00
-ldflags "-s -w" \
2017-12-07 14:13:29 -06:00
-arch="amd64 386 arm arm64" \
-os="linux darwin windows freebsd" \
-osarch="!darwin/arm !darwin/arm64" \
2017-03-13 19:10:51 +04:00
-output="dist/{{.OS}}-{{.Arch}}/{{.Dir}}" .
dist: build-all
cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.rst {} \; && \
2017-03-13 19:10:51 +04:00
$(DIST_DIRS) tar -zcf tm-bench-${VERSION}-{}.tar.gz {} \; && \
shasum -a256 ./*.tar.gz > "./tm-bench_${VERSION}_SHA256SUMS" && \
2017-03-13 19:10:51 +04:00
cd ..
2018-04-03 12:39:58 +02:00
########################################
### Docker
2017-03-13 19:10:51 +04:00
build-docker:
rm -f ./tm-bench
2017-12-07 13:25:35 -06:00
docker run -it --rm -v "$(PWD):/go/src/app" -w "/go/src/app" -e "CGO_ENABLED=0" golang:alpine go build -ldflags "-s -w" -o tm-bench
2017-03-22 15:52:59 +04:00
docker build -t "tendermint/bench" .
2017-03-13 19:10:51 +04:00
clean:
rm -f ./tm-bench
rm -rf ./dist
2018-04-03 12:39:58 +02:00
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: check check_tools get_tools update_tools get_vendor_deps build install test build-all dist fmt metalinter metalinter_all build-docker clean