2015-06-25 09:17:48 +03:00
|
|
|
# Copyright 1999-2015 Gentoo Foundation
|
|
|
|
# Distributed under the terms of the GNU General Public License v2
|
|
|
|
|
|
|
|
# @ECLASS: golang-build.eclass
|
|
|
|
# @MAINTAINER:
|
|
|
|
# William Hubbs <williamh@gentoo.org>
|
|
|
|
# @BLURB: Eclass for compiling go packages.
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# This eclass provides default src_compile, src_test and src_install
|
|
|
|
# functions for software written in the Go programming language.
|
|
|
|
|
2015-07-28 00:35:20 +03:00
|
|
|
inherit golang-base
|
|
|
|
|
2015-06-25 09:17:48 +03:00
|
|
|
case "${EAPI:-0}" in
|
2016-02-10 08:37:52 +03:00
|
|
|
5|6)
|
2015-06-25 09:17:48 +03:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
EXPORT_FUNCTIONS src_compile src_install src_test
|
|
|
|
|
|
|
|
if [[ -z ${_GOLANG_BUILD} ]]; then
|
|
|
|
|
|
|
|
_GOLANG_BUILD=1
|
|
|
|
|
2015-08-10 23:59:40 +03:00
|
|
|
# @ECLASS-VARIABLE: EGO_BUILD_FLAGS
|
|
|
|
# @DEFAULT_UNSET
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# This allows you to pass build flags to the Go compiler. These flags
|
|
|
|
# are common to the "go build" and "go install" commands used below.
|
|
|
|
# Please emerge dev-lang/go and run "go help build" for the
|
|
|
|
# documentation for these flags.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# @CODE
|
|
|
|
# EGO_BUILD_FLAGS="-ldflags \"-X main.version ${PV}\""
|
|
|
|
# @CODE
|
|
|
|
|
2015-06-25 09:17:48 +03:00
|
|
|
# @ECLASS-VARIABLE: EGO_PN
|
|
|
|
# @REQUIRED
|
|
|
|
# @DESCRIPTION:
|
|
|
|
# This is the import path for the go package(s) to build. Please emerge
|
|
|
|
# dev-lang/go and read "go help importpath" for syntax.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# @CODE
|
|
|
|
# EGO_PN=github.com/user/package
|
|
|
|
# @CODE
|
|
|
|
|
|
|
|
golang-build_src_compile() {
|
|
|
|
debug-print-function ${FUNCNAME} "$@"
|
|
|
|
|
2015-07-28 00:35:20 +03:00
|
|
|
ego_pn_check
|
2015-07-23 22:23:57 +03:00
|
|
|
set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
|
2015-08-10 23:59:40 +03:00
|
|
|
go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
|
2015-06-25 09:17:48 +03:00
|
|
|
echo "$@"
|
|
|
|
"$@" || die
|
|
|
|
}
|
|
|
|
|
|
|
|
golang-build_src_install() {
|
|
|
|
debug-print-function ${FUNCNAME} "$@"
|
|
|
|
|
2015-07-28 00:35:20 +03:00
|
|
|
ego_pn_check
|
2015-07-23 22:23:57 +03:00
|
|
|
set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
|
2015-08-10 23:59:40 +03:00
|
|
|
go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
|
2015-06-25 09:17:48 +03:00
|
|
|
echo "$@"
|
|
|
|
"$@" || die
|
2015-07-23 22:23:57 +03:00
|
|
|
golang_install_pkgs
|
2015-06-25 09:17:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
golang-build_src_test() {
|
|
|
|
debug-print-function ${FUNCNAME} "$@"
|
|
|
|
|
2015-07-28 00:35:20 +03:00
|
|
|
ego_pn_check
|
2015-07-23 22:23:57 +03:00
|
|
|
set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
|
2015-06-25 09:17:48 +03:00
|
|
|
go test -v -work -x "${EGO_PN}"
|
|
|
|
echo "$@"
|
|
|
|
"$@" || die
|
|
|
|
}
|
|
|
|
|
|
|
|
fi
|