1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 CARGO_SNAPSHOT_DATE="2016-03-21"
8 CARGO_INDEX_COMMIT="64a9f2f594cefc2ca652e0cecf7ce6e41c0279ee"
9 CRATES="advapi32-sys-0.1.2
33 libressl-pnacl-sys-2.1.6
47 pnacl-build-helper-1.4.10
51 rustc-serialize-0.3.18
59 unicode-normalization-0.1.2
68 inherit cargo bash-completion-r1
70 DESCRIPTION="The Rust's package manager"
71 HOMEPAGE="http://crates.io"
72 SRC_URI="https://github.com/rust-lang/cargo/archive/${PV}.tar.gz -> ${P}.tar.gz
73 https://github.com/rust-lang/crates.io-index/archive/${CARGO_INDEX_COMMIT}.tar.gz -> cargo-registry-${CARGO_INDEX_COMMIT}.tar.gz
74 $(cargo_crate_uris ${CRATES})
76 https://static.rust-lang.org/cargo-dist/${CARGO_SNAPSHOT_DATE}/cargo-nightly-i686-unknown-linux-gnu.tar.gz ->
77 cargo-snapshot-x86-${CARGO_SNAPSHOT_DATE}.tar.gz
80 https://static.rust-lang.org/cargo-dist/${CARGO_SNAPSHOT_DATE}/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz ->
81 cargo-snapshot-amd64-${CARGO_SNAPSHOT_DATE}.tar.gz
85 LICENSE="|| ( MIT Apache-2.0 )"
87 KEYWORDS="~amd64 ~x86"
91 COMMON_DEPEND="sys-libs/zlib
95 RDEPEND="${COMMON_DEPEND}
98 DEPEND="${COMMON_DEPEND}
99 >=dev-lang/rust-1.1.0:stable
106 # Until cargo bootstraps itself with a version based on 0.13.0, this needs
107 # to stay (these variables and src_unpack)
108 ECARGO_HOME="${WORKDIR}/cargo_home"
109 ECARGO_REPO="github.com-88ac128001ac3a9a"
110 ECARGO_INDEX="${ECARGO_HOME}/registry/index/${ECARGO_REPO}"
111 ECARGO_SRC="${ECARGO_HOME}/registry/src/${ECARGO_REPO}"
112 ECARGO_CACHE="${ECARGO_HOME}/registry/cache/${ECARGO_REPO}"
115 mkdir -p "${ECARGO_INDEX}" || die
116 mkdir -p "${ECARGO_CACHE}" || die
117 mkdir -p "${ECARGO_SRC}" || die
118 mkdir -p "${S}" || die
121 for archive in ${A}; do
124 ebegin "Unpacking ${archive}"
125 cp "${DISTDIR}"/${archive} "${ECARGO_CACHE}/" || die
126 tar -xf "${DISTDIR}"/${archive} -C "${ECARGO_SRC}/" || die
130 ebegin "Unpacking ${archive}"
131 mkdir -p "${S}"/target/snapshot
132 tar -xzf "${DISTDIR}"/${archive} -C "${S}"/target/snapshot --strip-components 2 || die
133 # cargo's makefile needs this otherwise it will try to
135 touch "${S}"/target/snapshot/bin/cargo || die
139 ebegin "Unpacking ${archive}"
140 tar -xzf "${DISTDIR}"/${archive} -C "${ECARGO_INDEX}" --strip-components 1 || die
141 # prevent cargo from attempting to download this again
142 touch "${ECARGO_INDEX}"/.cargo-index-lock || die
153 # Cargo only supports these GNU triples:
154 # - Linux: <arch>-unknown-linux-gnu
155 # - MacOS: <arch>-apple-darwin
156 # - Windows: <arch>-pc-windows-gnu
157 # where <arch> could be 'x86_64' (amd64) or 'i686' (x86)
158 use amd64 && CTARGET="x86_64-unknown-linux-gnu"
159 use x86 && CTARGET="i686-unknown-linux-gnu"
161 # NOTE: 'disable-nightly' is used by crates (such as 'matches') to entirely
162 # skip their internal libraries that make use of unstable rustc features.
163 # Don't use 'enable-nightly' with a stable release of rustc as DEPEND,
164 # otherwise you could get compilation issues.
165 # see: github.com/gentoo/gentoo-rust/issues/13
172 --disable-verify-install
174 --disable-cross-tests
176 econf "${myeconfargs[@]}"
181 export CARGO_HOME="${ECARGO_HOME}"
182 emake VERBOSE=1 PKG_CONFIG_PATH=""
184 # Building HTML documentation
189 emake prepare-image-${CTARGET} IMGDIR_${CTARGET}="${ED}/usr"
191 # Install HTML documentation
192 use doc && HTML_DOCS=("target/doc")
195 dobashcomp "${ED}"/usr/etc/bash_completion.d/cargo
196 rm -rf "${ED}"/usr/etc || die
201 # NOTE: by default 'make test' uses the copy of cargo (v0.0.1-pre-nighyly)
202 # from the installer snapshot instead of the version just built, so the
203 # ebuild needs to override the value of CFG_LOCAL_CARGO to avoid false
204 # positives from unit tests.
206 CFG_ENABLE_OPTIMIZE=1 \
208 CFG_LOCAL_CARGO="${WORKDIR}"/${P}/target/${CTARGET}/release/cargo