Update golang-base.eclass

This commit is contained in:
KronoZed 2016-10-31 16:59:10 +03:00 committed by GitHub
parent 522582fcf2
commit efe9ec19f8
1 changed files with 28 additions and 21 deletions

View File

@ -159,7 +159,7 @@ GOLANG_PKG_TAGS="${GOLANG_PKG_TAGS:-}"
# Sets additional standard Go workspaces to be appended to the environment
# variable GOPATH, as described in http://golang.org/doc/code.html.
# This eclass defaults to an empty list.
GOLANG_PKG_VENDOR=()
GOLANG_PKG_VENDOR="${GOLANG_PKG_VENDOR:-}"
# @ECLASS-VARIABLE: GOLANG_PKG_STATIK
# @DESCRIPTION:
@ -395,7 +395,6 @@ golang_setup() {
export GOBIN="$_GOBIN"
export CGO_ENABLED
export GOEXPERIMENT
export GO15VENDOREXPERIMENT=0
debug-print "${FUNCNAME}: GOPATH = ${GOPATH}"
debug-print "${FUNCNAME}: GOBIN = ${GOBIN}"
@ -521,7 +520,6 @@ golang-base_src_prepare() {
local VENDOR="${S}/vendor"
if [[ -d "${VENDOR}" ]]; then
golang_add_vendor "${VENDOR}"
export GO15VENDOREXPERIMENT=1
fi
# Auto-detects the presence of Go's vendored
@ -549,7 +547,7 @@ golang-base_src_prepare() {
# (see github.com/tools/godep for more infos).
VENDOR="${S}/Godeps/_workspace"
if [[ -d "${VENDOR}" ]]; then
golang_add_vendor "${VENDOR}"
GOLANG_PKG_VENDOR+=" ${VENDOR}"
fi
@ -678,19 +676,22 @@ golang-base_src_compile() {
[[ ${EGO} ]] || die "No GoLang implementation set (golang_setup not called?)."
# Populates env variable GOPATH with vendored workspaces (if present).
if [[ -n ${GOLANG_PKG_VENDOR} ]]; then
if [[ -n ${GOLANG_PKG_VENDOR} || "1" == ${GO15VENDOREXPERIMENT} ]]; then
einfo "Using vendored dependencies from:"
# Prints Go's vendored directory.
if [[ "1" == ${GO15VENDOREXPERIMENT} ]]; then
einfo "- vendor"
fi
fi
# Prints user defined vendored directories.
if [[ -n ${GOLANG_PKG_VENDOR} ]]; then
for path in "${GOLANG_PKG_VENDOR[@]}"; do
[ -d ${path} ] || continue
if [[ ${path//${S}\//} == "vendor" ]]; then
einfo "- vendor/ (native vendoring support)"
continue
fi
debug-print "$FUNCNAME: GOPATH: Adding vendor path ${path}"
ebegin "- ${path//${S}\//}"
ebegin "- ${path//${WORKDIR}\//}"
GOPATH="${GOPATH}:$( echo ${path} )"
eend
done
@ -831,7 +832,7 @@ golang-base_src_test() {
# Defines sub-packages.
local EGO_SUBPACKAGES="${GOLANG_PKG_IMPORTPATH_ALIAS}/${GOLANG_PKG_NAME}${GOLANG_PKG_BUILDPATH}"
[[ -z ${GOLANG_PKG_IS_MULTIPLE} ]] || EGO_SUBPACKAGES="./..."
[[ -n ${GOLANG_PKG_IS_MULTIPLE} ]] || EGO_SUBPACKAGES="./..."
# Runs the unit tests.
einfo "${EGO} test ${EGO_BUILD_FLAGS} ${EGO_SUBPACKAGES}"
@ -900,16 +901,22 @@ golang_add_vendor() {
[[ ${GOLANG_VERSION} ]] || die "No Golang implementation set (golang_setup not called?)."
[[ ! -d "${1}" ]] && return
case $( get_version_component_range 1-2 ${GOLANG_VERSION} ) in
1.4*)
# TODO: traverse $1 and expose all the bundled /vendor
# sub-directories to GOLANG_PKG_VENDOR
if [[ ! -d "${1}"/src ]]; then
ebegin "Fixing $1"
ln -s "${1}" "${1}"/src || die
eend
fi
# NOTE: this hack is required by Go v1.4 and older versions.
if [[ ! -d "${1}"/src ]]; then
ebegin "Fixing $1"
ln -s "${1}" "${1}"/src || die
eend
fi
GOLANG_PKG_VENDOR+=(${1})
GOLANG_PKG_VENDOR+=" ${1}"
;;
1.5*)
export GO15VENDOREXPERIMENT=1
;;
esac
}