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 # @BLURB: Eclass for compiling go packages.
9 # This eclass provides default src_compile, src_test and src_install
10 # functions for software written in the Go programming language.
18 die "${ECLASS}: Unsupported eapi (EAPI=${EAPI})"
22 EXPORT_FUNCTIONS src_compile src_install src_test
24 if [[ -z ${_GOLANG_BUILD} ]]; then
28 # @ECLASS-VARIABLE: EGO_BUILD_FLAGS
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.
38 # EGO_BUILD_FLAGS="-ldflags \"-X main.version ${PV}\""
41 # @ECLASS-VARIABLE: EGO_PN
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.
49 # EGO_PN=github.com/user/package
52 golang-build_src_compile() {
53 debug-print-function ${FUNCNAME} "$@"
56 set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
57 go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
62 golang-build_src_install() {
63 debug-print-function ${FUNCNAME} "$@"
66 set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
67 go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}"
73 golang-build_src_test() {
74 debug-print-function ${FUNCNAME} "$@"
77 set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" \
78 go test -v -work -x "${EGO_PN}"