diff --git a/.editorconfig b/.editorconfig index 82f774362..481621f76 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,10 +8,7 @@ end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true -[Makefile] -indent_style = tab - -[*.sh] +[*.{sh,Makefile}] indent_style = tab [*.proto] diff --git a/Makefile b/Makefile index 413d76ae6..fb15dfc4a 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,24 @@ GOTOOLS = \ github.com/mitchellh/gox \ github.com/tcnksm/ghr \ - github.com/Masterminds/glide \ github.com/alecthomas/gometalinter PACKAGES=$(shell go list ./... | grep -v '/vendor/') BUILD_TAGS?=tendermint TMHOME = $${TMHOME:-$$HOME/.tendermint} -all: install test +BUILD_FLAGS = -ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short HEAD`" -install: get_vendor_deps - @go install --ldflags '-extldflags "-static"' \ - --ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse HEAD`" ./cmd/tendermint +all: get_vendor_deps install test + +install: + CGO_ENABLED=0 go install $(BUILD_FLAGS) ./cmd/tendermint build: - go build \ - --ldflags "-X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse HEAD`" -o build/tendermint ./cmd/tendermint/ + CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/tendermint ./cmd/tendermint/ build_race: - go build -race -o build/tendermint ./cmd/tendermint + CGO_ENABLED=0 go build -race $(BUILD_FLAGS) -o build/tendermint ./cmd/tendermint # dist builds binaries for all platforms and packages them for distribution dist: @@ -38,7 +37,7 @@ test_race: test_integrations: @bash ./test/test.sh -release: +test_release: @go test -tags release $(PACKAGES) test100: @@ -61,24 +60,23 @@ get_deps: grep -v /vendor/ | sort | uniq | \ xargs go get -v -d -get_vendor_deps: ensure_tools +update_deps: + @echo "--> Updating dependencies" + @go get -d -u ./... + +get_vendor_deps: + @hash glide 2>/dev/null || go get github.com/Masterminds/glide @rm -rf vendor/ @echo "--> Running glide install" @glide install -update_deps: tools - @echo "--> Updating dependencies" - @go get -d -u ./... - -revision: - -echo `git rev-parse --verify HEAD` > $(TMHOME)/revision - -echo `git rev-parse --verify HEAD` >> $(TMHOME)/revision_history +update_tools: + @echo "--> Updating tools" + @go get -u $(GOTOOLS) tools: - go get -u -v $(GOTOOLS) - -ensure_tools: - go get $(GOTOOLS) + @echo "--> Installing tools" + @go get $(GOTOOLS) @gometalinter --install ### Formatting, linting, and vetting @@ -115,4 +113,4 @@ metalinter_test: #--enable=vet \ #--enable=vetshadow \ -.PHONY: install build build_race dist test test_race test_integrations test100 draw_deps list_deps get_deps get_vendor_deps update_deps revision tools +.PHONY: install build build_race dist test test_race test_integrations test100 draw_deps list_deps get_deps get_vendor_deps update_deps update_tools tools test_release diff --git a/scripts/dist_build.sh b/scripts/dist_build.sh index 3e6d5abce..873bacf1b 100755 --- a/scripts/dist_build.sh +++ b/scripts/dist_build.sh @@ -11,7 +11,6 @@ cd "$DIR" # Get the git commit GIT_COMMIT="$(git rev-parse --short HEAD)" -GIT_DESCRIBE="$(git describe --tags --always)" GIT_IMPORT="github.com/tendermint/tendermint/version" # Determine the arch/os combos we're building for @@ -25,12 +24,14 @@ make tools make get_vendor_deps # Build! +# ldflags: -s Omit the symbol table and debug information. +# -w Omit the DWARF symbol table. echo "==> Building..." "$(which gox)" \ -os="${XC_OS}" \ -arch="${XC_ARCH}" \ -osarch="!darwin/arm !solaris/amd64 !freebsd/amd64" \ - -ldflags "-X ${GIT_IMPORT}.GitCommit='${GIT_COMMIT}' -X ${GIT_IMPORT}.GitDescribe='${GIT_DESCRIBE}'" \ + -ldflags "-s -w -X ${GIT_IMPORT}.GitCommit='${GIT_COMMIT}'" \ -output "build/pkg/{{.OS}}_{{.Arch}}/tendermint" \ -tags="${BUILD_TAGS}" \ github.com/tendermint/tendermint/cmd/tendermint diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index dcdb404bd..4e98ecc7a 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -17,6 +17,7 @@ WORKDIR $REPO ADD glide.yaml glide.yaml ADD glide.lock glide.lock ADD Makefile Makefile +RUN make tools RUN make get_vendor_deps # Install the apps diff --git a/version/version.go b/version/version.go index 637cc5de5..aa2ebbeb3 100644 --- a/version/version.go +++ b/version/version.go @@ -5,15 +5,16 @@ const Min = "12" const Fix = "1" var ( - // The full version string + // Version is the current version of Tendermint + // Must be a string because scripts like dist.sh read this file. Version = "0.12.1" - // GitCommit is set with --ldflags "-X main.gitCommit=$(git rev-parse HEAD)" + // GitCommit is the current HEAD set using ldflags. GitCommit string ) func init() { if GitCommit != "" { - Version += "-" + GitCommit[:8] + Version += "-" + GitCommit } }