2017-01-30 17:46:23 +00:00
|
|
|
%__cargo %{_bindir}/cargo
|
|
|
|
%__cargo_common_opts --release %{?_smp_mflags}
|
2017-02-12 10:28:51 +00:00
|
|
|
%__cargo_inspector %{_bindir}/cargo-inspector
|
2017-01-30 17:46:23 +00:00
|
|
|
|
2017-06-20 21:10:28 +00:00
|
|
|
%cargo_registry %{_datadir}/cargo/registry
|
2017-01-30 17:46:23 +00:00
|
|
|
|
2017-02-18 18:53:08 +00:00
|
|
|
%__cargo_is_lib() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F "$(printf 'lib\\\nproc-macro')"
|
|
|
|
%__cargo_is_bin() %__cargo_inspector --target-kinds Cargo.toml | grep -q -F bin
|
2017-02-10 21:10:12 +00:00
|
|
|
|
2017-02-18 15:10:50 +00:00
|
|
|
%cargo_prep (\
|
|
|
|
set -eu \
|
|
|
|
%{__mkdir} -p .cargo \
|
|
|
|
cat > .cargo/config << EOF \
|
2017-01-30 17:46:23 +00:00
|
|
|
[build]\
|
|
|
|
rustc = "%{__rustc}"\
|
2017-06-23 11:35:18 +00:00
|
|
|
rustdoc = "%{__rustdoc}"\
|
2017-01-30 17:46:23 +00:00
|
|
|
rustflags = %{__global_rustflags_toml}\
|
|
|
|
\
|
|
|
|
[term]\
|
|
|
|
verbose = true\
|
|
|
|
\
|
|
|
|
[source]\
|
|
|
|
\
|
|
|
|
[source.local-registry]\
|
|
|
|
directory = "%{cargo_registry}"\
|
|
|
|
\
|
|
|
|
[source.crates-io]\
|
|
|
|
registry = "https://crates.io"\
|
|
|
|
replace-with = "local-registry"\
|
2017-02-18 15:10:50 +00:00
|
|
|
EOF\
|
|
|
|
%if ! %{with check} \
|
|
|
|
# https://github.com/rust-lang/cargo/issues/3732 \
|
2017-02-25 20:39:42 +00:00
|
|
|
%{__awk} -i inplace -v INPLACE_SUFFIX=.orig '/^\\\[dev-dependencies/{f=1;next} /^\\\[/{f=0}; !f' Cargo.toml \
|
2017-02-18 15:10:50 +00:00
|
|
|
%endif \
|
|
|
|
)
|
2017-01-30 17:46:23 +00:00
|
|
|
|
2017-02-18 01:25:21 +00:00
|
|
|
%cargo_build %__cargo build %{__cargo_common_opts}
|
2017-01-30 17:46:23 +00:00
|
|
|
|
2017-02-18 01:25:21 +00:00
|
|
|
%cargo_test %__cargo test %{__cargo_common_opts}
|
2017-01-30 17:46:23 +00:00
|
|
|
|
2017-02-18 15:10:50 +00:00
|
|
|
%cargo_install (\
|
2017-02-10 21:10:12 +00:00
|
|
|
set -eu \
|
|
|
|
if %__cargo_is_lib; then \
|
|
|
|
CRATE_NAME=$(%__cargo_inspector --name Cargo.toml) \
|
|
|
|
CRATE_VERSION=$(%__cargo_inspector --version Cargo.toml) \
|
|
|
|
REG_DIR=%{buildroot}%{cargo_registry}/$CRATE_NAME-$CRATE_VERSION \
|
2017-02-18 15:10:50 +00:00
|
|
|
%{__mkdir} -p $REG_DIR \
|
2017-02-10 21:10:12 +00:00
|
|
|
%__cargo package -l | xargs cp --parents -p -t $REG_DIR \
|
2017-02-18 15:10:50 +00:00
|
|
|
%if ! %{with check} \
|
2017-02-25 20:51:08 +00:00
|
|
|
%{__install} -p Cargo.toml.orig $REG_DIR/Cargo.toml \
|
2017-02-18 15:10:50 +00:00
|
|
|
%endif \
|
2017-02-10 21:10:12 +00:00
|
|
|
echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \
|
|
|
|
fi \
|
|
|
|
if %__cargo_is_bin; then \
|
|
|
|
%__cargo install %{?_smp_mflags} --path . --root %{buildroot}%{_prefix} \
|
2017-02-18 15:10:50 +00:00
|
|
|
%{__rm} %{buildroot}%{_prefix}/.crates.toml \
|
2017-02-10 21:10:12 +00:00
|
|
|
fi \
|
2017-02-18 15:10:50 +00:00
|
|
|
)
|