kde-apps/ksirk: x86 stable (bug #661810)
[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 # @BLURB: Eclass that provides base functions for Go packages.
8 # @DESCRIPTION:
9 # This eclass provides base functions for software written in the Go
10 # programming language; it also provides the build-time dependency on
11 # dev-lang/go.
12
13 case "${EAPI:-0}" in
14         5|6)
15                 ;;
16         *)
17                 die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
18                 ;;
19 esac
20
21 if [[ -z ${_GOLANG_BASE} ]]; then
22
23 _GOLANG_BASE=1
24
25 DEPEND=">=dev-lang/go-1.9"
26
27 # Do not complain about CFLAGS etc since go projects do not use them.
28 QA_FLAGS_IGNORED='.*'
29
30 STRIP_MASK="*.a"
31
32 # @ECLASS-VARIABLE: EGO_PN
33 # @REQUIRED
34 # @DESCRIPTION:
35 # This is the import path for the go package to build. Please emerge
36 # dev-lang/go and read "go help importpath" for syntax.
37 #
38 # Example:
39 # @CODE
40 # EGO_PN=github.com/user/package
41 # @CODE
42
43 # @FUNCTION: ego_pn_check
44 # @DESCRIPTION:
45 # Make sure EGO_PN has a value.
46 ego_pn_check() {
47         [[ -z "${EGO_PN}" ]] &&
48                 die "${ECLASS}.eclass: EGO_PN is not set"
49         return 0
50 }
51
52 # @FUNCTION: get_golibdir
53 # @DESCRIPTION:
54 # Return the non-prefixed library directory where Go packages
55 # should be installed
56 get_golibdir() {
57         echo /usr/lib/go-gentoo
58 }
59
60 # @FUNCTION: get_golibdir_gopath
61 # @DESCRIPTION:
62 # Return the library directory where Go packages should be installed
63 # This is the prefixed version which should be included in GOPATH
64 get_golibdir_gopath() {
65         echo "${EPREFIX}$(get_golibdir)"
66 }
67
68 # @FUNCTION: golang_install_pkgs
69 # @DESCRIPTION:
70 # Install Go packages.
71 # This function assumes that $cwd is a Go workspace.
72 golang_install_pkgs() {
73         debug-print-function ${FUNCNAME} "$@"
74
75         ego_pn_check
76         insinto "$(get_golibdir)"
77         insopts -m0644 -p # preserve timestamps for bug 551486
78         doins -r pkg src
79 }
80
81 fi