|
|
a40f9b |
# Explicitly use bindir tools, in case others are in the PATH,
|
|
|
a40f9b |
# like the rustup shims in a user's ~/.cargo/bin/.
|
|
|
a40f9b |
#
|
|
|
a40f9b |
# Since cargo 1.31, install only uses $CARGO_HOME/config, ignoring $PWD.
|
|
|
a40f9b |
# https://github.com/rust-lang/cargo/issues/6397
|
|
|
a40f9b |
# But we can set CARGO_HOME locally, which is a good idea anyway to make sure
|
|
|
a40f9b |
# it never writes to ~/.cargo during rpmbuild.
|
|
|
a40f9b |
%__cargo %{_bindir}/env CARGO_HOME=.cargo %{_bindir}/cargo
|
|
|
a40f9b |
%__rustc %{_bindir}/rustc
|
|
|
a40f9b |
%__rustdoc %{_bindir}/rustdoc
|
|
|
a40f9b |
|
|
|
a40f9b |
# Enable optimization, debuginfo, and link hardening.
|
|
|
a40f9b |
%__global_rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now
|
|
|
a40f9b |
|
|
|
a40f9b |
%__global_rustflags_toml [%{lua:
|
|
|
a40f9b |
for arg in string.gmatch(rpm.expand("%{__global_rustflags}"), "%S+") do
|
|
|
a40f9b |
print('"' .. arg .. '", ')
|
|
|
a40f9b |
end}]
|
|
|
a40f9b |
|
|
|
a40f9b |
%cargo_prep(V:) (\
|
|
|
a40f9b |
%{__mkdir} -p .cargo \
|
|
|
a40f9b |
cat > .cargo/config << EOF \
|
|
|
a40f9b |
[build]\
|
|
|
a40f9b |
rustc = "%{__rustc}"\
|
|
|
a40f9b |
rustdoc = "%{__rustdoc}"\
|
|
|
a40f9b |
rustflags = %{__global_rustflags_toml}\
|
|
|
a40f9b |
\
|
|
|
a40f9b |
[install]\
|
|
|
a40f9b |
root = "%{buildroot}%{_prefix}"\
|
|
|
a40f9b |
\
|
|
|
a40f9b |
[term]\
|
|
|
a40f9b |
verbose = true\
|
|
|
a40f9b |
EOF\
|
|
|
a40f9b |
%if 0%{-V:1}\
|
|
|
a40f9b |
%{__tar} -xoaf %{S:%{-V*}}\
|
|
|
a40f9b |
cat >> .cargo/config << EOF \
|
|
|
a40f9b |
\
|
|
|
a40f9b |
[source.crates-io]\
|
|
|
a40f9b |
replace-with = "vendored-sources"\
|
|
|
a40f9b |
\
|
|
|
a40f9b |
[source.vendored-sources]\
|
|
|
a40f9b |
directory = "./vendor"\
|
|
|
a40f9b |
EOF\
|
|
|
a40f9b |
%endif\
|
|
|
a40f9b |
)
|
|
|
a40f9b |
|
|
|
a40f9b |
%cargo_build %__cargo build --release %{?_smp_mflags}
|
|
|
a40f9b |
|
|
|
a40f9b |
%cargo_test %__cargo test --release %{?_smp_mflags} --no-fail-fast
|
|
|
a40f9b |
|
|
|
a40f9b |
%cargo_install %__cargo install --no-track --path .
|