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