68140cd502ad4f5007117df13e0baf7406b472e3
[gentoo.git] / dev-util / cargo / cargo-0.12.0.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=6
6
7 CARGO_SNAPSHOT_DATE="2016-03-21"
8 CARGO_INDEX_COMMIT="64a9f2f594cefc2ca652e0cecf7ce6e41c0279ee"
9 CRATES="advapi32-sys-0.1.2
10 aho-corasick-0.5.1
11 bitflags-0.1.1
12 bufstream-0.1.1
13 cmake-0.1.16
14 crossbeam-0.2.8
15 cfg-if-0.1.0
16 curl-0.3.0
17 curl-sys-0.2.0
18 docopt-0.6.78
19 env_logger-0.3.2
20 filetime-0.1.10
21 flate2-0.2.13
22 fs2-0.2.3
23 gcc-0.3.26
24 gdi32-sys-0.1.1
25 git2-0.4.3
26 git2-curl-0.5.0
27 glob-0.2.11
28 hamcrest-0.1.0
29 idna-0.1.0
30 kernel32-sys-0.2.1
31 libc-0.2.8
32 libgit2-sys-0.4.3
33 libressl-pnacl-sys-2.1.6
34 libssh2-sys-0.1.37
35 libz-sys-1.0.2
36 log-0.3.5
37 matches-0.1.2
38 memchr-0.1.10
39 miniz-sys-0.1.7
40 miow-0.1.2
41 net2-0.2.24
42 nom-1.2.2
43 num-0.1.31
44 num_cpus-0.2.11
45 openssl-sys-0.7.8
46 pkg-config-0.3.8
47 pnacl-build-helper-1.4.10
48 rand-0.3.14
49 regex-0.1.58
50 regex-syntax-0.3.0
51 rustc-serialize-0.3.18
52 semver-0.2.3
53 strsim-0.3.0
54 tar-0.4.5
55 tempdir-0.3.4
56 term-0.4.4
57 toml-0.1.30
58 unicode-bidi-0.2.3
59 unicode-normalization-0.1.2
60 url-1.1.0
61 user32-sys-0.1.2
62 utf8-ranges-0.1.3
63 winapi-0.2.6
64 winapi-build-0.1.1
65 ws2_32-sys-0.2.1
66 "
67
68 inherit cargo bash-completion-r1
69
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})
75         x86?   (
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
78         )
79         amd64? (
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
82         )"
83
84 RESTRICT="mirror"
85 LICENSE="|| ( MIT Apache-2.0 )"
86 SLOT="0"
87 KEYWORDS="~amd64 ~x86"
88
89 IUSE="doc"
90
91 COMMON_DEPEND="sys-libs/zlib
92         dev-libs/openssl:0=
93         net-libs/libssh2
94         net-libs/http-parser"
95 RDEPEND="${COMMON_DEPEND}
96         !dev-util/cargo-bin
97         net-misc/curl[ssl]"
98 DEPEND="${COMMON_DEPEND}
99         >=dev-lang/rust-1.1.0:stable
100         dev-util/cmake
101         sys-apps/coreutils
102         sys-apps/diffutils
103         sys-apps/findutils
104         sys-apps/sed"
105
106 src_configure() {
107         # Cargo only supports these GNU triples:
108         # - Linux: <arch>-unknown-linux-gnu
109         # - MacOS: <arch>-apple-darwin
110         # - Windows: <arch>-pc-windows-gnu
111         # where <arch> could be 'x86_64' (amd64) or 'i686' (x86)
112         use amd64 && CTARGET="x86_64-unknown-linux-gnu"
113         use x86 && CTARGET="i686-unknown-linux-gnu"
114
115         # NOTE: 'disable-nightly' is used by crates (such as 'matches') to entirely
116         # skip their internal libraries that make use of unstable rustc features.
117         # Don't use 'enable-nightly' with a stable release of rustc as DEPEND,
118         # otherwise you could get compilation issues.
119         # see: github.com/gentoo/gentoo-rust/issues/13
120         local myeconfargs=(
121                 --host=${CTARGET}
122                 --build=${CTARGET}
123                 --target=${CTARGET}
124                 --enable-optimize
125                 --disable-nightly
126                 --disable-verify-install
127                 --disable-debug
128                 --disable-cross-tests
129         )
130         econf "${myeconfargs[@]}"
131 }
132
133 src_compile() {
134         # Building sources
135         export CARGO_HOME="${ECARGO_HOME}"
136         emake VERBOSE=1 PKG_CONFIG_PATH=""
137
138         # Building HTML documentation
139         use doc && emake doc
140 }
141
142 src_install() {
143         emake prepare-image-${CTARGET} IMGDIR_${CTARGET}="${ED}/usr"
144
145         # Install HTML documentation
146         use doc && HTML_DOCS=("target/doc")
147         einstalldocs
148
149         dobashcomp "${ED}"/usr/etc/bash_completion.d/cargo
150         rm -rf "${ED}"/usr/etc || die
151 }
152
153 src_test() {
154         # Running unit tests
155         # NOTE: by default 'make test' uses the copy of cargo (v0.0.1-pre-nighyly)
156         # from the installer snapshot instead of the version just built, so the
157         # ebuild needs to override the value of CFG_LOCAL_CARGO to avoid false
158         # positives from unit tests.
159         emake test \
160                 CFG_ENABLE_OPTIMIZE=1 \
161                 VERBOSE=1 \
162                 CFG_LOCAL_CARGO="${WORKDIR}"/${P}/target/${CTARGET}/release/cargo
163 }