net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / golang-build.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @ECLASS: golang-build.eclass
6 # @MAINTAINER:
7 # William Hubbs <williamh@gentoo.org>
8 # @BLURB: Eclass for compiling go packages.
9 # @DESCRIPTION:
10 # This eclass provides default  src_compile, src_test and src_install
11 # functions for software written in the Go programming language.
12
13 inherit golang-base
14
15 case "${EAPI:-0}" in
16         5)
17                 ;;
18         *)
19                 die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
20                 ;;
21 esac
22
23 EXPORT_FUNCTIONS src_compile src_install src_test
24
25 if [[ -z ${_GOLANG_BUILD} ]]; then
26
27 _GOLANG_BUILD=1
28
29 # @ECLASS-VARIABLE: EGO_BUILD_FLAGS
30 # @DEFAULT_UNSET
31 # @DESCRIPTION:
32 # This allows you to pass build flags to the Go compiler. These flags
33 # are common to the "go build" and "go install" commands used below.
34 # Please emerge dev-lang/go and run "go help build" for the
35 # documentation for these flags.
36 #
37 # Example:
38 # @CODE
39 # EGO_BUILD_FLAGS="-ldflags \"-X main.version ${PV}\""
40 # @CODE
41
42 # @ECLASS-VARIABLE: EGO_PN
43 # @REQUIRED
44 # @DESCRIPTION:
45 # This is the import path for the go package(s) to build. Please emerge
46 # dev-lang/go and read "go help importpath" for syntax.
47 #
48 # Example:
49 # @CODE
50 # EGO_PN=github.com/user/package
51 # @CODE
52
53 golang-build_src_compile() {
54         debug-print-function ${FUNCNAME} "$@"
55
56         ego_pn_check
57         set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
58                 go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
59         echo "$@"
60         "$@" || die
61 }
62
63 golang-build_src_install() {
64         debug-print-function ${FUNCNAME} "$@"
65
66         ego_pn_check
67         set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
68                 go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
69         echo "$@"
70         "$@" || die
71         golang_install_pkgs
72 }
73
74 golang-build_src_test() {
75         debug-print-function ${FUNCNAME} "$@"
76
77         ego_pn_check
78         set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
79                 go test -v -work -x "${EGO_PN}"
80         echo "$@"
81         "$@" || die
82 }
83
84 fi