eclass/cargo: extend to support building packages

Originally this eclass only had the bits to build cargo and not other
packages built with cargo. Cargo is a special case and needs to override
some parts. This adds the generic case for normal cargo packages,
allowing for debug and release builds of packages as well.

Signed-off-by: Doug Goldstein <cardoe@gentoo.org>
This commit is contained in:
Doug Goldstein
2016-07-11 08:43:23 -05:00
parent ff78951f17
commit e07fc451a5

View File

@@ -17,10 +17,13 @@ case ${EAPI} in
*) die "EAPI=${EAPI:-0} is not supported" ;;
esac
EXPORT_FUNCTIONS src_unpack
EXPORT_FUNCTIONS src_unpack src_compile src_install
IUSE="${IUSE} debug"
ECARGO_HOME="${WORKDIR}/cargo_home"
ECARGO_REPO="github.com-88ac128001ac3a9a"
#ECARGO_REPO="github.com-88ac128001ac3a9a"
ECARGO_REPO="github.com-1ecc6299db9ec823"
ECARGO_INDEX="${ECARGO_HOME}/registry/index/${ECARGO_REPO}"
ECARGO_SRC="${ECARGO_HOME}/registry/src/${ECARGO_REPO}"
ECARGO_CACHE="${ECARGO_HOME}/registry/cache/${ECARGO_REPO}"
@@ -81,5 +84,26 @@ cargo_src_unpack() {
done
}
# @FUNCTION: cargo_src_compile
# @DESCRIPTION:
# Build the package using cargo build
cargo_src_compile() {
debug-print-function ${FUNCNAME} "$@"
export CARGO_HOME="${ECARGO_HOME}"
cargo build -v $(usex debug "" --release)
}
# @FUNCTION: cargo_src_install
# @DESCRIPTION:
# Installs the binaries generated by cargo
cargo_src_install() {
debug-print-function ${FUNCNAME} "$@"
cargo install --root="${D}/usr" $(usex debug --debug "") \
|| die "cargo install failed"
rm -f "${D}/usr/.crates.toml"
}
fi