initial trivial macro

Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
Igor Gnatenko 2017-01-30 18:46:23 +01:00
parent 181bd3c689
commit 7c6e1269bf
3 changed files with 47 additions and 0 deletions

37
macros.cargo Normal file
View file

@ -0,0 +1,37 @@
%__cargo %{_bindir}/cargo
%__cargo_common_opts --release %{?_smp_mflags}
%cargo_registry %{_usrsrc}/rust
%cargo_prep() %{expand:\
%{__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}}
%cargo_install() %{expand:%__cargo install %{?_smp_mflags} \\\
--path . \\\
--root %{buildroot}%{_prefix} \\\
%{?1} \\\
&& rm %{buildroot}%{_prefix}/.crates.toml}
%cargo_install_crate() %{expand: mkdir -p %{buildroot}%{cargo_registry}/%{1} && \\\
%__cargo package -l | xargs cp --parents -p -t %{buildroot}%{cargo_registry}/%{1} && \\\
echo '{"files":{},"package":""}' >%{buildroot}%{cargo_registry}/%{1}/.cargo-checksum.json}

9
macros.rust Normal file
View file

@ -0,0 +1,9 @@
%__rustc %{_bindir}/rustc
# Enable optimization, debuginfo, and link hardening.
%__global_rustflags -Copt-level=3 -g -Clink-arg=-Wl,-z,relro,-z,now
%__global_rustflags_toml [%{lua:
for arg in string.gmatch(rpm.expand("%{__global_rustflags}"), "%S+") do
print('"' .. arg .. '", ')
end}]

1
macros.rust-srpm Normal file
View file

@ -0,0 +1 @@
%rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x