Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
mantle: build kola
Browse files Browse the repository at this point in the history
Add support for cgo to the go eclass and start building kola!
  • Loading branch information
marineam committed Feb 18, 2015
1 parent bb72b78 commit de33c55
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 4 additions & 2 deletions coreos-devel/mantle/mantle-9999.ebuild
Expand Up @@ -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

Expand All @@ -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
}
19 changes: 16 additions & 3 deletions eclass/coreos-go.eclass
Expand Up @@ -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"

Expand All @@ -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"
}
Expand All @@ -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() {
Expand Down

0 comments on commit de33c55

Please sign in to comment.