mantle: build kola

Add support for cgo to the go eclass and start building kola!
This commit is contained in:
Michael Marineau 2015-02-18 09:50:52 -08:00
parent 052c439c52
commit 074f533f93
3 changed files with 20 additions and 5 deletions

View File

@ -9,7 +9,7 @@ COREOS_GO_PACKAGE="github.com/coreos/mantle"
if [[ "${PV}" == 9999 ]]; then
KEYWORDS="~amd64"
else
CROS_WORKON_COMMIT="a1a810b88e4fca2c320a31a740796eaffecab57f"
CROS_WORKON_COMMIT="444fecccb109b5a90765cb1b79311fb10dd5c5e5"
KEYWORDS="amd64"
fi
@ -21,5 +21,7 @@ LICENSE="Apache-2"
SLOT="0"
src_compile() {
go_build "${COREOS_GO_PACKAGE}"/cmd/plume
for cmd in kola plume; do
go_build "${COREOS_GO_PACKAGE}/cmd/${cmd}"
done
}

View File

@ -11,7 +11,7 @@
[[ ${EAPI} != "5" ]] && die "Only EAPI=5 is supported"
inherit multiprocessing
inherit flag-o-matic multiprocessing toolchain-funcs
DEPEND="dev-lang/go"
@ -24,8 +24,8 @@ go_build() {
local package_name="$1"
local binary_name="${package_name##*/}"
# TODO: handle cgo, cross-compiling, etc etc...
CGO_ENABLED=0 go build -x -p "$(makeopts_jobs)" \
go build -x -p "$(makeopts_jobs)" \
-ldflags "-extldflags '${LDFLAGS}'" \
-o "${GOPATH}/bin/${binary_name}" "${package_name}" \
|| die "go build failed"
}
@ -44,6 +44,19 @@ coreos-go_src_prepare() {
local package_path="${GOPATH}/src/${COREOS_GO_PACKAGE}"
mkdir -p "${package_path%/*}" || die
ln -sT "${S}" "${package_path}" || die
# Go's 6l linker does not support PIE, disable so cgo binaries
# which use 6l+gcc for linking can be built correctly.
if gcc-specs-pie; then
append-ldflags -nopie
fi
export CC=$(tc-getCC)
export CGO_ENABLED=1
export CGO_CFLAGS="${CFLAGS}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
}
coreos-go_src_compile() {