mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-09 06:33:16 +00:00
simplified reproducible buildsystem (#5477)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@
|
||||
*.bak
|
||||
.DS_Store
|
||||
build/*
|
||||
artifacts/*
|
||||
rpc/test/.tendermint
|
||||
.tendermint
|
||||
remote_dump
|
||||
|
||||
29
Makefile
29
Makefile
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
PACKAGES=$(shell go list ./...)
|
||||
OUTPUT?=build/tendermint
|
||||
BUILDDIR ?= $(CURDIR)/build
|
||||
|
||||
BUILD_TAGS?=tendermint
|
||||
LD_FLAGS = -X github.com/tendermint/tendermint/version.GitCommit=`git rev-parse --short=8 HEAD`
|
||||
@@ -56,14 +58,17 @@ include tests.mk
|
||||
### Build Tendermint ###
|
||||
###############################################################################
|
||||
|
||||
build:
|
||||
CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(OUTPUT) ./cmd/tendermint/
|
||||
build: $(BUILDDIR)/
|
||||
CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o $(BUILDDIR)/ ./cmd/tendermint/
|
||||
.PHONY: build
|
||||
|
||||
install:
|
||||
CGO_ENABLED=$(CGO_ENABLED) go install $(BUILD_FLAGS) -tags $(BUILD_TAGS) ./cmd/tendermint
|
||||
.PHONY: install
|
||||
|
||||
$(BUILDDIR)/:
|
||||
mkdir -p $@
|
||||
|
||||
###############################################################################
|
||||
### Protobuf ###
|
||||
###############################################################################
|
||||
@@ -142,7 +147,7 @@ draw_deps:
|
||||
|
||||
get_deps_bin_size:
|
||||
@# Copy of build recipe with additional flags to perform binary size analysis
|
||||
$(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(OUTPUT) ./cmd/tendermint/ 2>&1))
|
||||
$(eval $(shell go build -work -a $(BUILD_FLAGS) -tags $(BUILD_TAGS) -o $(BUILDDIR)/ ./cmd/tendermint/ 2>&1))
|
||||
@find $(WORK) -type f -name "*.a" | xargs -I{} du -hxs "{}" | sort -rh | sed -e s:${WORK}/::g > deps_bin_size.log
|
||||
@echo "Results can be found here: $(CURDIR)/deps_bin_size.log"
|
||||
.PHONY: get_deps_bin_size
|
||||
@@ -210,7 +215,7 @@ sync-docs:
|
||||
###############################################################################
|
||||
|
||||
build-docker: build-linux
|
||||
cp $(OUTPUT) DOCKER/tendermint
|
||||
cp $(BUILDDIR)/tendermint DOCKER/tendermint
|
||||
docker build --label=tendermint --tag="tendermint/tendermint" DOCKER
|
||||
rm -rf DOCKER/tendermint
|
||||
.PHONY: build-docker
|
||||
@@ -264,3 +269,17 @@ endif
|
||||
contract-tests:
|
||||
dredd
|
||||
.PHONY: contract-tests
|
||||
|
||||
clean:
|
||||
rm -rf $(CURDIR)/artifacts/ $(BUILDDIR)/
|
||||
|
||||
build-reproducible:
|
||||
docker rm latest-build || true
|
||||
docker run --volume=$(CURDIR):/sources:ro \
|
||||
--env TARGET_PLATFORMS='linux/amd64 linux/arm64 darwin/amd64 windows/amd64' \
|
||||
--env APP=tendermint \
|
||||
--env COMMIT=$(shell git rev-parse --short=8 HEAD) \
|
||||
--env VERSION=$(shell git describe --tags) \
|
||||
--name latest-build cosmossdk/rbuilder:latest
|
||||
docker cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/
|
||||
.PHONY: build-reproducible
|
||||
|
||||
40
build.sh
Executable file
40
build.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ue
|
||||
|
||||
# Expect the following envvars to be set:
|
||||
# - APP
|
||||
# - VERSION
|
||||
# - COMMIT
|
||||
# - TARGET_OS
|
||||
# - LEDGER_ENABLED
|
||||
# - DEBUG
|
||||
|
||||
# Source builder's functions library
|
||||
. /usr/local/share/cosmos-sdk/buildlib.sh
|
||||
|
||||
# These variables are now available
|
||||
# - BASEDIR
|
||||
# - OUTDIR
|
||||
|
||||
# Build for each os-architecture pair
|
||||
for platform in ${TARGET_PLATFORMS} ; do
|
||||
# This function sets GOOS, GOARCH, and OS_FILE_EXT environment variables
|
||||
# according to the build target platform. OS_FILE_EXT is empty in all
|
||||
# cases except when the target platform is 'windows'.
|
||||
setup_build_env_for_platform "${platform}"
|
||||
|
||||
make clean
|
||||
echo Building for $(go env GOOS)/$(go env GOARCH) >&2
|
||||
GOROOT_FINAL="$(go env GOROOT)" \
|
||||
make build LDFLAGS=-buildid=${VERSION} COMMIT=${COMMIT}
|
||||
mv ./build/${APP}${OS_FILE_EXT} ${OUTDIR}/${APP}-${VERSION}-$(go env GOOS)-$(go env GOARCH)${OS_FILE_EXT}
|
||||
|
||||
# This function restore the build environment variables to their
|
||||
# original state.
|
||||
restore_build_env
|
||||
done
|
||||
|
||||
# Generate and display build report.
|
||||
generate_build_report
|
||||
cat ${OUTDIR}/build_report
|
||||
Reference in New Issue
Block a user