diff --git a/macros.cargo b/macros.cargo new file mode 100644 index 0000000..2bee8a1 --- /dev/null +++ b/macros.cargo @@ -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} diff --git a/macros.rust b/macros.rust new file mode 100644 index 0000000..c37bb15 --- /dev/null +++ b/macros.rust @@ -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}] diff --git a/macros.rust-srpm b/macros.rust-srpm new file mode 100644 index 0000000..f2bae9d --- /dev/null +++ b/macros.rust-srpm @@ -0,0 +1 @@ +%rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x