1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: cargo.eclass
9 # Doug Goldstein <cardoe@gentoo.org>
10 # @BLURB: common functions and variables for cargo builds
12 if [[ -z ${_CARGO_ECLASS} ]]; then
17 *) die "EAPI=${EAPI:-0} is not supported" ;;
20 EXPORT_FUNCTIONS src_unpack
22 ECARGO_HOME="${WORKDIR}/cargo_home"
23 ECARGO_REPO="github.com-88ac128001ac3a9a"
24 ECARGO_INDEX="${ECARGO_HOME}/registry/index/${ECARGO_REPO}"
25 ECARGO_SRC="${ECARGO_HOME}/registry/src/${ECARGO_REPO}"
26 ECARGO_CACHE="${ECARGO_HOME}/registry/cache/${ECARGO_REPO}"
28 # @FUNCTION: cargo_crate_uris
30 # Generates the URIs to put in SRC_URI to help fetch dependencies.
33 local name version url
35 version="${crate##*-}"
36 url="https://crates.io/api/v1/crates/${name}/${version}/download -> ${crate}.crate"
41 # @FUNCTION: cargo_src_unpack
43 # Unpacks the package and the cargo registry
45 debug-print-function ${FUNCNAME} "$@"
47 mkdir -p "${ECARGO_INDEX}" || die
48 mkdir -p "${ECARGO_CACHE}" || die
49 mkdir -p "${ECARGO_SRC}" || die
50 mkdir -p "${S}" || die
53 for archive in ${A}; do
56 ebegin "Unpacking ${archive}"
57 cp "${DISTDIR}"/${archive} "${ECARGO_CACHE}/" || die
58 tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_SRC}/" || die
62 ebegin "Unpacking ${archive}"
63 mkdir -p "${S}"/target/snapshot
64 tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die
65 # cargo's makefile needs this otherwise it will try to
67 touch "${S}"/target/snapshot/bin/cargo || die
71 ebegin "Unpacking ${archive}"
72 tar -xzf "${DISTDIR}"/${archive} -C "${ECARGO_INDEX}" --strip-components 1 || die
73 # prevent cargo from attempting to download this again
74 touch "${ECARGO_INDEX}"/.cargo-index-lock || die