toolchain.eclass: use https:// for git protocol, bug #717056
[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 # @SUPPORTED_EAPIS: 5 6 7
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|6|7)
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                 GOCACHE="${T}/go-cache" \
59                 go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
60         echo "$@"
61         "$@" || die
62 }
63
64 golang-build_src_install() {
65         debug-print-function ${FUNCNAME} "$@"
66
67         ego_pn_check
68         set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
69                 go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
70         echo "$@"
71         "$@" || die
72         golang_install_pkgs
73 }
74
75 golang-build_src_test() {
76         debug-print-function ${FUNCNAME} "$@"
77
78         ego_pn_check
79         set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
80                 go test -v -work -x "${EGO_PN}"
81         echo "$@"
82         "$@" || die
83 }
84
85 fi