eclass/cargo: extend to support building packages
authorDoug Goldstein <cardoe@gentoo.org>
Mon, 11 Jul 2016 13:43:23 +0000 (08:43 -0500)
committerDoug Goldstein <cardoe@gentoo.org>
Wed, 30 Nov 2016 17:17:51 +0000 (11:17 -0600)
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>
eclass/cargo.eclass

index a86bb9e037a5327d54871ffc31cc4b0c3ca0dbdb..19c66c8d4aa8578a4b940fe4603c7a62e54d2a00 100644 (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