commit:     e07fc451a52c104d1e7dfae2207e7cd908b77ccc
Author:     Doug Goldstein <cardoe <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 11 13:43:23 2016 +0000
Commit:     Doug Goldstein <cardoe <AT> gentoo <DOT> org>
CommitDate: Wed Nov 30 17:17:51 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e07fc451

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 <AT> gentoo.org>

 eclass/cargo.eclass | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index a86bb9e..19c66c8 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -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

Reply via email to