summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2015-06-24 15:38:33 +0000
committerWilliam Hubbs <williamh@gentoo.org>2015-06-24 15:38:33 +0000
commitac3dcee17ce4571dd6d0b4f9317e22b6e3aeef44 (patch)
tree25806b3e8d38674e55c2d3c720cfe9066867f67e /eclass
parentUpdate HOMEPAGE. (diff)
downloadgentoo-2-ac3dcee17ce4571dd6d0b4f9317e22b6e3aeef44.tar.gz
gentoo-2-ac3dcee17ce4571dd6d0b4f9317e22b6e3aeef44.tar.bz2
gentoo-2-ac3dcee17ce4571dd6d0b4f9317e22b6e3aeef44.zip
Add an eclass for building Go software
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/golang-build.eclass84
2 files changed, 88 insertions, 1 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 7a1e989cd203..2b12ad5ae9e5 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1682 2015/06/24 13:36:03 grknight Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1683 2015/06/24 15:38:33 williamh Exp $
+
+ 24 Jun 2015; William Hubbs <williamh@gentoo.org> +golang-build.eclass:
+ Add an eclass for building Go software
24 Jun 2015; <grknight@gentoo.org> depend.php.eclass:
depend.php.eclass is deprecated and is set to be removed 30 days after bug
diff --git a/eclass/golang-build.eclass b/eclass/golang-build.eclass
new file mode 100644
index 000000000000..cab98ec42e55
--- /dev/null
+++ b/eclass/golang-build.eclass
@@ -0,0 +1,84 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/golang-build.eclass,v 1.1 2015/06/24 15:38:33 williamh Exp $
+
+# @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.
+
+case "${EAPI:-0}" in
+ 5)
+ ;;
+ *)
+ die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
+ ;;
+esac
+
+EXPORT_FUNCTIONS src_compile src_install src_test
+
+if [[ -z ${_GOLANG_BUILD} ]]; then
+
+_GOLANG_BUILD=1
+
+DEPEND=">=dev-lang/go-1.4.2:="
+STRIP_MASK="*.a"
+
+# @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
+
+# @FUNCTION: _golang-build_setup
+# @INTERNAL
+# @DESCRIPTION:
+# Make sure EGO_PN has a value.
+_golang-build_setup() {
+ [ -z "${EGO_PN}" ] &&
+ die "${ECLASS}.eclass: EGO_PN is not set"
+ return 0
+}
+
+golang-build_src_compile() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ _golang-build_setup
+ set -- env GOPATH="${WORKDIR}/${P}:${EPREFIX}/usr/lib/go-gentoo" \
+ go build -v -work -x "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+}
+
+golang-build_src_install() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ _golang-build_setup
+ set -- env GOPATH="${WORKDIR}/${P}:${EPREFIX}/usr/lib/go-gentoo" \
+ go install -v -work -x "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+ insinto /usr/lib/go-gentoo
+ insopts -m0644 -p # preserve timestamps for bug 551486
+ doins -r pkg src
+}
+
+golang-build_src_test() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ _golang-build_setup
+ set -- env GOPATH="${WORKDIR}/${P}:${EPREFIX}/usr/lib/go-gentoo" \
+ go test -v -work -x "${EGO_PN}"
+ echo "$@"
+ "$@" || die
+}
+
+fi