dev-qt/qttest: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / eclass / golang-base.eclass
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: golang-base.eclass
5 # @MAINTAINER:
6 # William Hubbs <williamh@gentoo.org>
7 # @SUPPORTED_EAPIS: 5 6 7
8 # @BLURB: Eclass that provides base functions for Go packages.
9 # @DESCRIPTION:
10 # This eclass provides base functions for software written in the Go
11 # programming language; it also provides the build-time dependency on
12 # dev-lang/go.
13
14 case "${EAPI:-0}" in
15         5|6|7)
16                 ;;
17         *)
18                 die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
19                 ;;
20 esac
21
22 if [[ -z ${_GOLANG_BASE} ]]; then
23
24 _GOLANG_BASE=1
25
26 GO_DEPEND=">=dev-lang/go-1.10"
27 if [[ ${EAPI:-0} == [56] ]]; then
28         DEPEND="${GO_DEPEND}"
29 else
30         BDEPEND="${GO_DEPEND}"
31 fi
32
33 # Do not complain about CFLAGS etc since go projects do not use them.
34 QA_FLAGS_IGNORED='.*'
35
36 # Upstream does not support stripping go packages
37 RESTRICT="strip"
38
39 # @ECLASS-VARIABLE: EGO_PN
40 # @REQUIRED
41 # @DESCRIPTION:
42 # This is the import path for the go package to build. Please emerge
43 # dev-lang/go and read "go help importpath" for syntax.
44 #
45 # Example:
46 # @CODE
47 # EGO_PN=github.com/user/package
48 # @CODE
49
50 # @FUNCTION: ego_pn_check
51 # @DESCRIPTION:
52 # Make sure EGO_PN has a value.
53 ego_pn_check() {
54         [[ -z "${EGO_PN}" ]] &&
55                 die "${ECLASS}.eclass: EGO_PN is not set"
56         return 0
57 }
58
59 # @FUNCTION: get_golibdir
60 # @DESCRIPTION:
61 # Return the non-prefixed library directory where Go packages
62 # should be installed
63 get_golibdir() {
64         echo /usr/lib/go-gentoo
65 }
66
67 # @FUNCTION: get_golibdir_gopath
68 # @DESCRIPTION:
69 # Return the library directory where Go packages should be installed
70 # This is the prefixed version which should be included in GOPATH
71 get_golibdir_gopath() {
72         echo "${EPREFIX}$(get_golibdir)"
73 }
74
75 # @FUNCTION: golang_install_pkgs
76 # @DESCRIPTION:
77 # Install Go packages.
78 # This function assumes that $cwd is a Go workspace.
79 golang_install_pkgs() {
80         debug-print-function ${FUNCNAME} "$@"
81
82         ego_pn_check
83         insinto "$(get_golibdir)"
84         insopts -m0644 -p # preserve timestamps for bug 551486
85         doins -r pkg src
86 }
87
88 fi