1 |
akien |
1861388 |
# Explicitly use bindir tools, in case others are in the PATH, |
2 |
|
|
# like the rustup shims in a user's ~/.cargo/bin/. |
3 |
|
|
# |
4 |
|
|
# Since cargo 1.31, install only uses $CARGO_HOME/config, ignoring $PWD. |
5 |
|
|
# https://github.com/rust-lang/cargo/issues/6397 |
6 |
|
|
# But we can set CARGO_HOME locally, which is a good idea anyway to make sure |
7 |
|
|
# it never writes to ~/.cargo during rpmbuild. |
8 |
|
|
%__cargo %{_bindir}/env CARGO_HOME=.cargo %{_bindir}/cargo |
9 |
|
|
%__rustc %{_bindir}/rustc |
10 |
|
|
%__rustdoc %{_bindir}/rustdoc |
11 |
|
|
|
12 |
|
|
# Enable optimization, debuginfo, and link hardening. |
13 |
|
|
%__global_rustflags -Copt-level=3 -Cdebuginfo=2 -Clink-arg=-Wl,-z,relro,-z,now |
14 |
|
|
|
15 |
|
|
%__global_rustflags_toml [%{lua: |
16 |
|
|
for arg in string.gmatch(rpm.expand("%{__global_rustflags}"), "%S+") do |
17 |
|
|
print('"' .. arg .. '", ') |
18 |
|
|
end}] |
19 |
|
|
|
20 |
|
|
%cargo_prep(V:) (\ |
21 |
|
|
%{__mkdir} -p .cargo \ |
22 |
|
|
cat > .cargo/config << EOF \ |
23 |
|
|
[build]\ |
24 |
|
|
rustc = "%{__rustc}"\ |
25 |
|
|
rustdoc = "%{__rustdoc}"\ |
26 |
|
|
rustflags = %{__global_rustflags_toml}\ |
27 |
|
|
\ |
28 |
|
|
[install]\ |
29 |
|
|
root = "%{buildroot}%{_prefix}"\ |
30 |
|
|
\ |
31 |
|
|
[term]\ |
32 |
|
|
verbose = true\ |
33 |
|
|
EOF\ |
34 |
|
|
%if 0%{-V:1}\ |
35 |
|
|
%{__tar} -xoaf %{S:%{-V*}}\ |
36 |
|
|
cat >> .cargo/config << EOF \ |
37 |
|
|
\ |
38 |
|
|
[source.crates-io]\ |
39 |
|
|
replace-with = "vendored-sources"\ |
40 |
|
|
\ |
41 |
|
|
[source.vendored-sources]\ |
42 |
|
|
directory = "./vendor"\ |
43 |
|
|
EOF\ |
44 |
|
|
%endif\ |
45 |
|
|
) |
46 |
|
|
|
47 |
|
|
%cargo_build %__cargo build --release %{?_smp_mflags} |
48 |
|
|
|
49 |
|
|
%cargo_test %__cargo test --release %{?_smp_mflags} --no-fail-fast |
50 |
|
|
|
51 |
|
|
%cargo_install %__cargo install --no-track --path . |