mirror of https://github.com/status-im/consul.git
Fix a couple find warnings on linux
Additionally add the ability to use go install for dev builds rather than gox (travis doesn’t have gox)
This commit is contained in:
parent
12d14f6c54
commit
90e74da6b7
|
@ -16,8 +16,8 @@ GOTEST_PKGS ?= "./..."
|
||||||
else
|
else
|
||||||
GOTEST_PKGS=$(shell go list ./... | sed 's/github.com\/hashicorp\/consul/./' | egrep -v "^($(GOTEST_PKGS_EXCLUDE))$$")
|
GOTEST_PKGS=$(shell go list ./... | sed 's/github.com\/hashicorp\/consul/./' | egrep -v "^($(GOTEST_PKGS_EXCLUDE))$$")
|
||||||
endif
|
endif
|
||||||
GOOS=$(shell go env GOOS)
|
GOOS?=$(shell go env GOOS)
|
||||||
GOARCH=$(shell go env GOARCH)
|
GOARCH?=$(shell go env GOARCH)
|
||||||
GOPATH=$(shell go env GOPATH)
|
GOPATH=$(shell go env GOPATH)
|
||||||
|
|
||||||
ASSETFS_PATH?=agent/bindata_assetfs.go
|
ASSETFS_PATH?=agent/bindata_assetfs.go
|
||||||
|
@ -103,7 +103,7 @@ bin: tools dev-build
|
||||||
dev: changelogfmt vendorfmt dev-build
|
dev: changelogfmt vendorfmt dev-build
|
||||||
|
|
||||||
dev-build:
|
dev-build:
|
||||||
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh
|
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh -o $(GOOS) -a $(GOARCH)
|
||||||
|
|
||||||
dev-docker:
|
dev-docker:
|
||||||
@docker build -t '$(CONSUL_DEV_IMAGE)' --build-arg 'GIT_COMMIT=$(GIT_COMMIT)' --build-arg 'GIT_DIRTY=$(GIT_DIRTY)' --build-arg 'GIT_DESCRIBE=$(GIT_DESCRIBE)' -f $(CURDIR)/build-support/docker/Consul-Dev.dockerfile $(CURDIR)
|
@docker build -t '$(CONSUL_DEV_IMAGE)' --build-arg 'GIT_COMMIT=$(GIT_COMMIT)' --build-arg 'GIT_DIRTY=$(GIT_DIRTY)' --build-arg 'GIT_DESCRIBE=$(GIT_DESCRIBE)' -f $(CURDIR)/build-support/docker/Consul-Dev.dockerfile $(CURDIR)
|
||||||
|
|
|
@ -218,7 +218,7 @@ function build_consul_post {
|
||||||
rm -r pkg.bin.new
|
rm -r pkg.bin.new
|
||||||
|
|
||||||
DEV_PLATFORM="./pkg/bin/${extra_dir}$(go env GOOS)_$(go env GOARCH)"
|
DEV_PLATFORM="./pkg/bin/${extra_dir}$(go env GOOS)_$(go env GOARCH)"
|
||||||
for F in $(find ${DEV_PLATFORM} -mindepth 1 -maxdepth 1 -type f)
|
for F in $(find ${DEV_PLATFORM} -type f -mindepth 1 -maxdepth 1 )
|
||||||
do
|
do
|
||||||
# recreate the bin dir
|
# recreate the bin dir
|
||||||
rm -r bin/* 2> /dev/null
|
rm -r bin/* 2> /dev/null
|
||||||
|
@ -330,6 +330,8 @@ function build_consul_local {
|
||||||
# If the CONSUL_DEV environment var is truthy only the local platform/architecture is built.
|
# If the CONSUL_DEV environment var is truthy only the local platform/architecture is built.
|
||||||
# If the XC_OS or the XC_ARCH environment vars are present then only those platforms/architectures
|
# If the XC_OS or the XC_ARCH environment vars are present then only those platforms/architectures
|
||||||
# will be built. Otherwise all supported platform/architectures are built
|
# will be built. Otherwise all supported platform/architectures are built
|
||||||
|
# The NOGOX environment variable will be used if present. This will prevent using gox and instead
|
||||||
|
# build with go install
|
||||||
|
|
||||||
if ! test -d "$1"
|
if ! test -d "$1"
|
||||||
then
|
then
|
||||||
|
@ -374,22 +376,54 @@ function build_consul_local {
|
||||||
build_arch="${XC_ARCH}"
|
build_arch="${XC_ARCH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local use_gox=1
|
||||||
|
is_set "${NOGOX}" && use_gox=0
|
||||||
|
which gox > /dev/null || use_gox=0
|
||||||
|
|
||||||
status_stage "==> Building Consul - OSes: ${build_os}, Architectures: ${build_arch}"
|
status_stage "==> Building Consul - OSes: ${build_os}, Architectures: ${build_arch}"
|
||||||
mkdir pkg.bin.new 2> /dev/null
|
mkdir pkg.bin.new 2> /dev/null
|
||||||
CGO_ENABLED=0 gox \
|
if is_set "${use_gox}"
|
||||||
-os="${build_os}" \
|
then
|
||||||
-arch="${build_arch}" \
|
status "Using gox for concurrent compilation"
|
||||||
-osarch="!darwin/arm !darwin/arm64" \
|
|
||||||
-ldflags="${GOLDFLAGS}" \
|
CGO_ENABLED=0 gox \
|
||||||
-output "pkg.bin.new/${extra_dir}{{.OS}}_{{.Arch}}${build_suffix}/consul" \
|
-os="${build_os}" \
|
||||||
-tags="${GOTAGS}" \
|
-arch="${build_arch}" \
|
||||||
.
|
-osarch="!darwin/arm !darwin/arm64" \
|
||||||
|
-ldflags="${GOLDFLAGS}" \
|
||||||
|
-output "pkg.bin.new/${extra_dir}{{.OS}}_{{.Arch}}/consul" \
|
||||||
|
-tags="${GOTAGS}" \
|
||||||
|
.
|
||||||
|
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
err "ERROR: Failed to build Consul"
|
err "ERROR: Failed to build Consul"
|
||||||
rm -r pkg.bin.new
|
rm -r pkg.bin.new
|
||||||
return 1
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
status "Building sequentially with go install"
|
||||||
|
for os in ${build_os}
|
||||||
|
do
|
||||||
|
for arch in ${build_arch}
|
||||||
|
do
|
||||||
|
outdir="pkg.bin.new/${extra_dir}${os}_${arch}"
|
||||||
|
osarch="${os}/${arch}"
|
||||||
|
if test "${osarch}" == "darwin/arm" -o "${osarch}" == "darwin/arm64"
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p "${outdir}"
|
||||||
|
GOOS=${os} GOARCH=${arch} go install -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}" && cp "${MAIN_GOPATH}/bin/consul" "${outdir}/consul"
|
||||||
|
if test $? -ne 0
|
||||||
|
then
|
||||||
|
err "ERROR: Failed to build Consul for ${osarch}"
|
||||||
|
rm -r pkg.bin.new
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
build_consul_post "${sdir}" "${extra_dir_name}"
|
build_consul_post "${sdir}" "${extra_dir_name}"
|
||||||
|
|
|
@ -87,7 +87,7 @@ function package_binaries {
|
||||||
|
|
||||||
rm -rf "${ddir}" > /dev/null 2>&1
|
rm -rf "${ddir}" > /dev/null 2>&1
|
||||||
mkdir -p "${ddir}" >/dev/null 2>&1
|
mkdir -p "${ddir}" >/dev/null 2>&1
|
||||||
for platform in $(find "${sdir}" -mindepth 1 -maxdepth 1 -type d)
|
for platform in $(find -type d "${sdir}" -mindepth 1 -maxdepth 1 )
|
||||||
do
|
do
|
||||||
local os_arch=$(basename $platform)
|
local os_arch=$(basename $platform)
|
||||||
local dest="${ddir}/${CONSUL_PKG_NAME}_${vers}_${os_arch}.zip"
|
local dest="${ddir}/${CONSUL_PKG_NAME}_${vers}_${os_arch}.zip"
|
||||||
|
|
Loading…
Reference in New Issue