summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog8
-rw-r--r--eclass/golang-base.eclass78
-rw-r--r--eclass/golang-build.eclass52
-rw-r--r--eclass/golang-vcs.eclass9
4 files changed, 94 insertions, 53 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index 81207a092849..5dfdaffd74d7 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for eclass directory
# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1732 2015/07/27 16:35:19 mgorny Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1733 2015/07/27 19:11:00 williamh Exp $
+
+ 27 Jul 2015; William Hubbs <williamh@gentoo.org> +golang-base.eclass,
+ golang-build.eclass, golang-vcs.eclass:
+ Add golang-base.eclass for the basic golang functions and set up the
+ other go eclasses to use it.
+
27 Jul 2015; Michał Górny <mgorny@gentoo.org> python-utils-r1.eclass:
python_wrapper_setup(): make banned helpers exit with 127.
diff --git a/eclass/golang-base.eclass b/eclass/golang-base.eclass
new file mode 100644
index 000000000000..88019cf08c8f
--- /dev/null
+++ b/eclass/golang-base.eclass
@@ -0,0 +1,78 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/golang-base.eclass,v 1.1 2015/07/27 19:11:00 williamh Exp $
+
+# @ECLASS: golang-build.eclass
+# @MAINTAINER:
+# William Hubbs <williamh@gentoo.org>
+# @BLURB: Eclass that provides base functions for Go packages.
+# @DESCRIPTION:
+# This eclass provides base functions for software written in the Go
+# programming language; it also provides the build-time dependency on
+# dev-lang/go.
+
+case "${EAPI:-0}" in
+ 5)
+ ;;
+ *)
+ die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
+ ;;
+esac
+
+if [[ -z ${_GOLANG_BASE} ]]; then
+
+_GOLANG_BASE=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 to build. Please emerge
+# dev-lang/go and read "go help importpath" for syntax.
+#
+# Example:
+# @CODE
+# EGO_PN=github.com/user/package
+# @CODE
+
+# @FUNCTION: ego_pn_check
+# @DESCRIPTION:
+# Make sure EGO_PN has a value.
+ego_pn_check() {
+ [[ -z "${EGO_PN}" ]] &&
+ die "${ECLASS}.eclass: EGO_PN is not set"
+ return 0
+}
+
+# @FUNCTION: get_golibdir
+# @DESCRIPTION:
+# Return the non-prefixed library directory where Go packages
+# should be installed
+get_golibdir() {
+ echo /usr/lib/go-gentoo
+}
+
+# @FUNCTION: get_golibdir_gopath
+# @DESCRIPTION:
+# Return the library directory where Go packages should be installed
+# This is the prefixed version which should be included in GOPATH
+get_golibdir_gopath() {
+ echo "${EPREFIX}$(get_golibdir)"
+}
+
+# @FUNCTION: golang_install_pkgs
+# @DESCRIPTION:
+# Install Go packages.
+# This function assumes that $cwd is a Go workspace.
+golang_install_pkgs() {
+ debug-print-function ${FUNCNAME} "$@"
+
+ ego_pn_check
+ insinto "$(get_golibdir)"
+ insopts -m0644 -p # preserve timestamps for bug 551486
+ doins -r pkg src
+}
+
+fi
diff --git a/eclass/golang-build.eclass b/eclass/golang-build.eclass
index 92dd21e5ce7f..f9fdcb0017b5 100644
--- a/eclass/golang-build.eclass
+++ b/eclass/golang-build.eclass
@@ -1,6 +1,6 @@
# 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.5 2015/07/23 15:42:26 williamh Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/golang-build.eclass,v 1.6 2015/07/27 19:11:00 williamh Exp $
# @ECLASS: golang-build.eclass
# @MAINTAINER:
@@ -10,6 +10,8 @@
# 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)
;;
@@ -24,9 +26,6 @@ if [[ -z ${_GOLANG_BUILD} ]]; then
_GOLANG_BUILD=1
-DEPEND=">=dev-lang/go-1.4.2:="
-STRIP_MASK="*.a"
-
# @ECLASS-VARIABLE: EGO_PN
# @REQUIRED
# @DESCRIPTION:
@@ -38,49 +37,10 @@ STRIP_MASK="*.a"
# 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
-}
-
-# @FUNCTION: get_golibdir
-# @DESCRIPTION:
-# Return the non-prefixed library directory where Go packages
-# should be installed
-get_golibdir() {
- echo /usr/lib/go-gentoo
-}
-
-# @FUNCTION: get_golibdir
-# @DESCRIPTION:
-# Return the library directory where Go packages should be installed
-# This is the prefixed version which should be included in GOPATH
-get_golibdir_gopath() {
- echo "${EPREFIX}$(get_golibdir)"
-}
-
-# @FUNCTION: golang_install_pkgs
-# @DESCRIPTION:
-# Install Go packages.
-# This function assumes that $cwd is a Go workspace.
-golang_install_pkgs() {
- debug-print-function ${FUNCNAME} "$@"
-
- _golang-build_setup
- insinto "$(get_golibdir)"
- insopts -m0644 -p # preserve timestamps for bug 551486
- doins -r pkg src
-}
-
golang-build_src_compile() {
debug-print-function ${FUNCNAME} "$@"
- _golang-build_setup
+ ego_pn_check
set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
go build -v -work -x "${EGO_PN}"
echo "$@"
@@ -90,7 +50,7 @@ golang-build_src_compile() {
golang-build_src_install() {
debug-print-function ${FUNCNAME} "$@"
- _golang-build_setup
+ ego_pn_check
set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
go install -v -work -x "${EGO_PN}"
echo "$@"
@@ -101,7 +61,7 @@ golang-build_src_install() {
golang-build_src_test() {
debug-print-function ${FUNCNAME} "$@"
- _golang-build_setup
+ ego_pn_check
set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
go test -v -work -x "${EGO_PN}"
echo "$@"
diff --git a/eclass/golang-vcs.eclass b/eclass/golang-vcs.eclass
index 7ab739a9d2eb..ea50dd6ad067 100644
--- a/eclass/golang-vcs.eclass
+++ b/eclass/golang-vcs.eclass
@@ -1,6 +1,6 @@
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/golang-vcs.eclass,v 1.3 2015/06/23 18:59:43 williamh Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/golang-vcs.eclass,v 1.4 2015/07/27 19:11:00 williamh Exp $
# @ECLASS: golang-vcs.eclass
# @MAINTAINER:
@@ -10,7 +10,7 @@
# This eclass is written to ease the maintenance of live ebuilds
# of software written in the Go programming language.
-inherit eutils
+inherit eutils golang-base
case "${EAPI:-0}" in
5)
@@ -26,8 +26,6 @@ if [[ -z ${_GOLANG_VCS} ]]; then
_GOLANG_VCS=1
-DEPEND=">=dev-lang/go-1.4.2"
-
# @ECLASS-VARIABLE: EGO_PN
# @REQUIRED
# @DESCRIPTION:
@@ -114,8 +112,7 @@ _golang-vcs_env_setup() {
_golang-vcs_fetch() {
debug-print-function ${FUNCNAME} "$@"
- [[ -z ${EGO_PN} ]] &&
- die "${ECLASS}: EGO_PN is not set"
+ ego_pn_check
if [[ -z ${EVCS_OFFLINE} ]]; then
[[ -n ${EVCS_UMASK} ]] && eumask_push ${EVCS_UMASK}