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
|
|
|
|
|
|
|
%cargo_registry %{_usrsrc}/rust
|
|
|
|
|
2017-02-10 21:10:12 +00:00
|
|
|
%__cargo_is_lib() %{expand:%__cargo_inspector --target-kinds Cargo.toml | grep -q -F lib}
|
|
|
|
%__cargo_is_bin() %{expand:%__cargo_inspector --target-kinds Cargo.toml | grep -q -F bin}
|
|
|
|
|
|
|
|
%cargo_prep %{expand:\
|
2017-01-30 17:46:23 +00:00
|
|
|
%{__mkdir} -p .cargo && cat > .cargo/config << EOF \
|
|
|
|
[build]\
|
|
|
|
rustc = "%{__rustc}"\
|
|
|
|
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"\
|
|
|
|
EOF}
|
|
|
|
|
|
|
|
%cargo_build() %{expand:%__cargo build %{__cargo_common_opts} %{?1}}
|
|
|
|
|
|
|
|
%cargo_test() %{expand:%__cargo test %{__cargo_common_opts} %{?1}}
|
|
|
|
|
2017-02-10 21:10:12 +00:00
|
|
|
%cargo_install %{expand:(\
|
|
|
|
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 \
|
|
|
|
mkdir -p $REG_DIR \
|
|
|
|
%__cargo package -l | xargs cp --parents -p -t $REG_DIR \
|
|
|
|
echo '{"files":{},"package":""}' > $REG_DIR/.cargo-checksum.json \
|
|
|
|
fi \
|
|
|
|
if %__cargo_is_bin; then \
|
|
|
|
%__cargo install %{?_smp_mflags} --path . --root %{buildroot}%{_prefix} \
|
|
|
|
rm %{buildroot}%{_prefix}/.crates.toml \
|
|
|
|
fi \
|
|
|
|
)}
|