aboutsummaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMikhail Pukhlikov <cynede@gentoo.org>2016-11-16 12:16:02 +0400
committerMikhail Pukhlikov <cynede@gentoo.org>2016-11-16 12:16:02 +0400
commit4bad05e70ce40ab2f64a33584dc5be7f1fce2402 (patch)
tree812e27d6f54f4b70370954a184193a9dab70fbfe /eclass
parentMerge pull request #209 from stsydow/master (diff)
downloadrust-4bad05e70ce40ab2f64a33584dc5be7f1fce2402.tar.gz
rust-4bad05e70ce40ab2f64a33584dc5be7f1fce2402.tar.bz2
rust-4bad05e70ce40ab2f64a33584dc5be7f1fce2402.zip
dev-util/cargo: 0.13 version which will work with virtual/rust (compiles with rust-bin)
Diffstat (limited to 'eclass')
-rw-r--r--eclass/cargo.eclass113
1 files changed, 64 insertions, 49 deletions
diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 304ea4c..a86bb9e 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -2,69 +2,84 @@
# Distributed under the terms of the GNU General Public License v2
# $Id$
+# @ECLASS: cargo.eclass
+# @MAINTAINER:
+# rust@gentoo.org
+# @AUTHOR:
+# Doug Goldstein <cardoe@gentoo.org>
+# @BLURB: common functions and variables for cargo builds
+
+if [[ -z ${_CARGO_ECLASS} ]]; then
+_CARGO_ECLASS=1
+
case ${EAPI} in
- 5) : ;;
- 6) : ;;
- *) die "EAPI=${EAPI:-0} is not supported" ;;
+ 6) : ;;
+ *) die "EAPI=${EAPI:-0} is not supported" ;;
esac
-DEPEND="=dev-util/cargo-9999"
+EXPORT_FUNCTIONS src_unpack
-EXPORT_FUNCTIONS src_unpack src_prepare src_compile src_install
-
-CARGO_HOME="${WORKDIR}/cargo_home"
+ECARGO_HOME="${WORKDIR}/cargo_home"
+ECARGO_REPO="github.com-88ac128001ac3a9a"
+ECARGO_INDEX="${ECARGO_HOME}/registry/index/${ECARGO_REPO}"
+ECARGO_SRC="${ECARGO_HOME}/registry/src/${ECARGO_REPO}"
+ECARGO_CACHE="${ECARGO_HOME}/registry/cache/${ECARGO_REPO}"
# @FUNCTION: cargo_crate_uris
# @DESCRIPTION:
# Generates the URIs to put in SRC_URI to help fetch dependencies.
cargo_crate_uris() {
- for crate in $*; do
- local name version url
- name="${crate%-*}"
- version="${crate##*-}"
- url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
- echo $url
- done
+ for crate in $*; do
+ local name version url
+ name="${crate%-*}"
+ version="${crate##*-}"
+ url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
+ echo $url
+ done
}
+# @FUNCTION: cargo_src_unpack
+# @DESCRIPTION:
+# Unpacks the package and the cargo registry
cargo_src_unpack() {
- mkdir -p "${CARGO_HOME}" || die
+ debug-print-function ${FUNCNAME} "$@"
- local archive
- for archive in ${A}; do
- case "${archive}" in
- *.crate)
- ebegin "Unpacking ${archive}"
- tar -xf "${DISTDIR}"/${archive} -C "${CARGO_HOME}" || die
- echo "{\"package\": \"$(sha256sum ${DISTDIR}/${archive} | cut -f1 -d' ')\",\"files\":{}}" > "${CARGO_HOME}"/$(basename ${archive} .crate)/.cargo-checksum.json
- eend $?
- ;;
- *)
- unpack ${archive}
- ;;
- esac
- done
-}
-
-cargo_src_prepare() {
- mkdir .cargo
- cat > .cargo/config <<EOL
-[source.crates-io]
-registry = 'https://github.com/rust-lang/crates.io-index'
-replace-with = 'ebuild-registry'
+ mkdir -p "${ECARGO_INDEX}" || die
+ mkdir -p "${ECARGO_CACHE}" || die
+ mkdir -p "${ECARGO_SRC}" || die
+ mkdir -p "${S}" || die
-[source.ebuild-registry]
-directory = '${CARGO_HOME}'
-EOL
+ local archive
+ for archive in ${A}; do
+ case "${archive}" in
+ *.crate)
+ ebegin "Unpacking ${archive}"
+ cp "${DISTDIR}"/${archive} "${ECARGO_CACHE}/" || die
+ tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_SRC}/" || die
+ eend $?
+ ;;
+ cargo-snapshot*)
+ ebegin "Unpacking ${archive}"
+ mkdir -p "${S}"/target/snapshot
+ tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die
+ # cargo's makefile needs this otherwise it will try to
+ # download it
+ touch "${S}"/target/snapshot/bin/cargo || die
+ eend $?
+ ;;
+ cargo-registry*)
+ ebegin "Unpacking ${archive}"
+ tar -xzf "${DISTDIR}"/${archive} -C "${ECARGO_INDEX}" --strip-components 1 || die
+ # prevent cargo from attempting to download this again
+ touch "${ECARGO_INDEX}"/.cargo-index-lock || die
+ eend $?
+ ;;
+ *)
+ unpack ${archive}
+ ;;
+ esac
+ done
}
-cargo_src_compile() {
- ebegin "Running cargo build"
- cargo build --release --verbose || die
-}
-cargo_src_install() {
- ebegin "Running cargo install"
- cargo install --root="${D}/usr" || die
- rm ${D}/usr/.crates.toml
-}
+fi