summaryrefslogtreecommitdiff
path: root/eclass/golang-build.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
committerV3n3RiX <venerix@redcorelinux.org>2017-10-09 18:53:29 +0100
commit4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch)
treeba5f07bf3f9d22d82e54a462313f5d244036c768 /eclass/golang-build.eclass
reinit the tree, so we can have metadata
Diffstat (limited to 'eclass/golang-build.eclass')
-rw-r--r--eclass/golang-build.eclass83
1 files changed, 83 insertions, 0 deletions
diff --git a/eclass/golang-build.eclass b/eclass/golang-build.eclass
new file mode 100644
index 000000000000..2d832114842c
--- /dev/null
+++ b/eclass/golang-build.eclass
@@ -0,0 +1,83 @@
+# 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.
+
+inherit golang-base
+
+case "${EAPI:-0}" in
+ 5|6)
+ ;;
+ *)
+ die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
+ ;;
+esac
+
+EXPORT_FUNCTIONS src_compile src_install src_test
+
+if [[ -z ${_GOLANG_BUILD} ]]; then
+
+_GOLANG_BUILD=1
+
+# @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
+
+# @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} "$@"
+
+ ego_pn_check
+ set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
+ go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+}
+
+golang-build_src_install() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
+ go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+ golang_install_pkgs
+}
+
+golang-build_src_test() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
+ go test -v -work -x "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+}
+
+fi