mirror of https://github.com/hashicorp/consul
Remove `gox` usage (#6596)
parent
6439af86eb
commit
a31e7a5d58
|
@ -3,7 +3,6 @@ GOGOVERSION?=$(shell grep github.com/gogo/protobuf go.mod | awk '{print $$2}')
|
||||||
GOTOOLS = \
|
GOTOOLS = \
|
||||||
github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs \
|
github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs \
|
||||||
github.com/hashicorp/go-bindata/go-bindata \
|
github.com/hashicorp/go-bindata/go-bindata \
|
||||||
github.com/mitchellh/gox \
|
|
||||||
golang.org/x/tools/cmd/cover \
|
golang.org/x/tools/cmd/cover \
|
||||||
golang.org/x/tools/cmd/stringer \
|
golang.org/x/tools/cmd/stringer \
|
||||||
github.com/gogo/protobuf/protoc-gen-gofast@$(GOGOVERSION) \
|
github.com/gogo/protobuf/protoc-gen-gofast@$(GOGOVERSION) \
|
||||||
|
@ -123,9 +122,7 @@ else
|
||||||
PUB_WEBSITE_ARG=
|
PUB_WEBSITE_ARG=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
NOGOX?=1
|
|
||||||
|
|
||||||
export NOGOX
|
|
||||||
export GO_BUILD_TAG
|
export GO_BUILD_TAG
|
||||||
export UI_BUILD_TAG
|
export UI_BUILD_TAG
|
||||||
export BUILD_CONTAINER_NAME
|
export BUILD_CONTAINER_NAME
|
||||||
|
|
|
@ -3,12 +3,11 @@ FROM golang:${GOLANG_VERSION}
|
||||||
|
|
||||||
ARG GOTOOLS="github.com/elazarl/go-bindata-assetfs/... \
|
ARG GOTOOLS="github.com/elazarl/go-bindata-assetfs/... \
|
||||||
github.com/hashicorp/go-bindata/... \
|
github.com/hashicorp/go-bindata/... \
|
||||||
github.com/mitchellh/gox \
|
|
||||||
golang.org/x/tools/cmd/cover \
|
golang.org/x/tools/cmd/cover \
|
||||||
golang.org/x/tools/cmd/stringer \
|
golang.org/x/tools/cmd/stringer \
|
||||||
github.com/axw/gocov/gocov \
|
github.com/axw/gocov/gocov \
|
||||||
gopkg.in/matm/v1/gocov-html"
|
gopkg.in/matm/v1/gocov-html"
|
||||||
|
|
||||||
RUN go get -u -v ${GOTOOLS} && mkdir -p /consul
|
RUN GO111MODULE=on go get -u -v ${GOTOOLS} && mkdir -p /consul
|
||||||
|
|
||||||
WORKDIR /consul
|
WORKDIR /consul
|
||||||
|
|
|
@ -60,7 +60,7 @@ function debug {
|
||||||
|
|
||||||
function debug_run {
|
function debug_run {
|
||||||
debug "$@"
|
debug "$@"
|
||||||
$@
|
"$@"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,14 +298,10 @@ function build_consul {
|
||||||
local container_id=$(docker create -it \
|
local container_id=$(docker create -it \
|
||||||
${volume_mount} \
|
${volume_mount} \
|
||||||
-e CGO_ENABLED=0 \
|
-e CGO_ENABLED=0 \
|
||||||
|
-e GOLDFLAGS="${GOLDFLAGS}" \
|
||||||
|
-e GOTAGS="${GOTAGS}" \
|
||||||
${image_name} \
|
${image_name} \
|
||||||
gox \
|
./build-support/scripts/build-local.sh -o "${XC_OS}" -a "${XC_ARCH}")
|
||||||
-os="${XC_OS}" \
|
|
||||||
-arch="${XC_ARCH}" \
|
|
||||||
-osarch="!darwin/arm !freebsd/arm !darwin/arm64" \
|
|
||||||
-ldflags "${GOLDFLAGS}" \
|
|
||||||
-output "pkg/bin/${extra_dir}{{.OS}}_{{.Arch}}/consul" \
|
|
||||||
-tags="${GOTAGS}")
|
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
if test $ret -eq 0
|
if test $ret -eq 0
|
||||||
|
@ -349,8 +345,6 @@ 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.
|
|
||||||
# The GOXPARALLEL environment variable is used if set
|
# The GOXPARALLEL environment variable is used if set
|
||||||
|
|
||||||
if ! test -d "$1"
|
if ! test -d "$1"
|
||||||
|
@ -396,73 +390,75 @@ 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
|
||||||
if is_set "${use_gox}"
|
|
||||||
then
|
|
||||||
status "Using gox for concurrent compilation"
|
|
||||||
|
|
||||||
CGO_ENABLED=0 gox \
|
status "Building sequentially with go install"
|
||||||
-os="${build_os}" \
|
for os in ${build_os}
|
||||||
-arch="${build_arch}" \
|
do
|
||||||
-osarch="!darwin/arm !darwin/arm64 !freebsd/arm" \
|
for arch in ${build_arch}
|
||||||
-ldflags="${GOLDFLAGS}" \
|
|
||||||
-parallel="${GOXPARALLEL:-"-1"}" \
|
|
||||||
-output "pkg.bin.new/${extra_dir}{{.OS}}_{{.Arch}}/consul" \
|
|
||||||
-tags="${GOTAGS}" \
|
|
||||||
.
|
|
||||||
|
|
||||||
if test $? -ne 0
|
|
||||||
then
|
|
||||||
err "ERROR: Failed to build Consul"
|
|
||||||
rm -r pkg.bin.new
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
status "Building sequentially with go install"
|
|
||||||
for os in ${build_os}
|
|
||||||
do
|
do
|
||||||
for arch in ${build_arch}
|
outdir="pkg.bin.new/${extra_dir}${os}_${arch}"
|
||||||
do
|
osarch="${os}/${arch}"
|
||||||
outdir="pkg.bin.new/${extra_dir}${os}_${arch}"
|
|
||||||
osarch="${os}/${arch}"
|
case "${os}" in
|
||||||
if test "${osarch}" == "darwin/arm" -o "${osarch}" == "darwin/arm64" -o "${osarch}" == "freebsd/arm64" -o "${osarch}" == "windows/arm" -o "${osarch}" == "windows/arm64" -o "${osarch}" == "freebsd/arm"
|
"darwin" )
|
||||||
then
|
# Do not build ARM binaries for macOS
|
||||||
|
if test "${arch}" == "arm" -o "${arch}" == "arm64"
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"windows" )
|
||||||
|
# Do not build ARM binaries for Windows
|
||||||
|
if test "${arch}" == "arm" -o "${arch}" == "arm64"
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"freebsd" )
|
||||||
|
# Do not build ARM binaries for FreeBSD
|
||||||
|
if test "${arch}" == "arm" -o "${arch}" == "arm64"
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"solaris" )
|
||||||
|
# Only build amd64 for Solaris
|
||||||
|
if test "${arch}" != "amd64"
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"linux" )
|
||||||
|
# build all the binaries for Linux
|
||||||
|
;;
|
||||||
|
*)
|
||||||
continue
|
continue
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if test "${os}" == "solaris" -a "${arch}" != "amd64"
|
echo "---> ${osarch}"
|
||||||
then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "---> ${osarch}"
|
mkdir -p "${outdir}"
|
||||||
|
GOBIN_EXTRA=""
|
||||||
|
if test "${os}" != "$(go env GOHOSTOS)" -o "${arch}" != "$(go env GOHOSTARCH)"
|
||||||
mkdir -p "${outdir}"
|
then
|
||||||
GOBIN_EXTRA=""
|
GOBIN_EXTRA="${os}_${arch}/"
|
||||||
if test "${os}" != "$(go env GOHOSTOS)" -o "${arch}" != "$(go env GOHOSTARCH)"
|
fi
|
||||||
then
|
binname="consul"
|
||||||
GOBIN_EXTRA="${os}_${arch}/"
|
if [ $os == "windows" ];then
|
||||||
fi
|
binname="consul.exe"
|
||||||
binname="consul"
|
fi
|
||||||
if [ $os == "windows" ];then
|
debug_run env CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go install -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}" && cp "${MAIN_GOPATH}/bin/${GOBIN_EXTRA}${binname}" "${outdir}/${binname}"
|
||||||
binname="consul.exe"
|
if test $? -ne 0
|
||||||
fi
|
then
|
||||||
CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go install -ldflags "${GOLDFLAGS}" -tags "${GOTAGS}" && cp "${MAIN_GOPATH}/bin/${GOBIN_EXTRA}${binname}" "${outdir}/${binname}"
|
err "ERROR: Failed to build Consul for ${osarch}"
|
||||||
if test $? -ne 0
|
rm -r pkg.bin.new
|
||||||
then
|
return 1
|
||||||
err "ERROR: Failed to build Consul for ${osarch}"
|
fi
|
||||||
rm -r pkg.bin.new
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
fi
|
done
|
||||||
|
|
||||||
build_consul_post "${sdir}" "${extra_dir_name}"
|
build_consul_post "${sdir}" "${extra_dir_name}"
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
|
|
Loading…
Reference in New Issue