1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: golang-build.eclass
6 # William Hubbs <williamh@gentoo.org>
7 # @SUPPORTED_EAPIS: 5 6 7
8 # @BLURB: Eclass for compiling go packages.
10 # This eclass provides default src_compile, src_test and src_install
11 # functions for software written in the Go programming language.
19 die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
23 EXPORT_FUNCTIONS src_compile src_install src_test
25 if [[ -z ${_GOLANG_BUILD} ]]; then
29 # @ECLASS-VARIABLE: EGO_BUILD_FLAGS
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.
39 # EGO_BUILD_FLAGS="-ldflags \"-X main.version ${PV}\""
42 # @ECLASS-VARIABLE: EGO_PN
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.
50 # EGO_PN=github.com/user/package
53 golang-build_src_compile() {
54 debug-print-function ${FUNCNAME} "$@"
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}"
64 golang-build_src_install() {
65 debug-print-function ${FUNCNAME} "$@"
68 set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
69 go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
75 golang-build_src_test() {
76 debug-print-function ${FUNCNAME} "$@"
79 set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
80 go test -v -work -x "${EGO_PN}"