# ==========================================================
# dev-dependencies
# ==========================================================
-# BuildRequires: rust-libc
-# BuildRequires: rust-static_assertions
+%if 0%{?run_tests}
+BuildRequires: rust-libc
+BuildRequires: rust-static_assertions
+%endif
%description
export RUSTC_TARGET_ARCH=arm
export RUSTC_TARGET_POINTER_WIDTH=32
%endif
- %{rustc_std_build} --crate-type=dylib \
- --crate-name=%{real_crate_name} \
- %{?rustc_edition:--edition=%{rustc_edition}} \
- --cfg="target_arch=\"$RUSTC_TARGET_ARCH\"" \
- --cfg="target_pointer_width=\"$RUSTC_TARGET_POINTER_WIDTH\"" \
- --cfg='feature="std"' \
- --cfg='feature="general"' \
- --cfg='feature="errno"' \
- ./src/lib.rs
+%{rustc_std_build} --crate-type=dylib \
+ --crate-name=%{real_crate_name} \
+ %{?rustc_edition:--edition=%{rustc_edition}} \
+ --cfg="target_arch=\"$RUSTC_TARGET_ARCH\"" \
+ --cfg="target_pointer_width=\"$RUSTC_TARGET_POINTER_WIDTH\"" \
+ --cfg='feature="std"' \
+ --cfg='feature="general"' \
+ --cfg='feature="errno"' \
+ ./src/lib.rs
# ==========================================================
# install section
# ==========================================================
%install
- install -d -m 0755 %{buildroot}%{_rust_dylibdir}
- install -m 0644 lib%{real_crate_name}.so %{buildroot}/%{_rust_dylibdir}/lib%{real_crate_name}.so
+install -d -m 0755 %{buildroot}%{_rust_dylibdir}
+install -m 0644 lib%{real_crate_name}.so %{buildroot}/%{_rust_dylibdir}/lib%{real_crate_name}.so
+
+%check
+%if 0%{?run_tests}
+
+%ifarch %{ix86}
+export RUSTC_TARGET_ARCH=x86
+export RUSTC_TARGET_POINTER_WIDTH=32
+%endif
+%ifarch x86_64
+export RUSTC_TARGET_ARCH=x86_64
+export RUSTC_TARGET_POINTER_WIDTH=64
+%endif
+%ifarch armv7l
+export RUSTC_TARGET_ARCH=arm
+export RUSTC_TARGET_POINTER_WIDTH=32
+%endif
+%ifarch aarch64
+export RUSTC_TARGET_ARCH=aarch64
+export RUSTC_TARGET_POINTER_WIDTH=64
+%endif
+%ifarch armv7hl
+export RUSTC_TARGET_ARCH=arm
+export RUSTC_TARGET_POINTER_WIDTH=32
+%endif
+
+%{rustc_std_build} --test --crate-type=dylib \
+ --crate-name=%{real_crate_name} \
+ %{?rustc_edition:--edition=%{rustc_edition}} \
+ --cfg="target_arch=\"$RUSTC_TARGET_ARCH\"" \
+ --cfg="target_pointer_width=\"$RUSTC_TARGET_POINTER_WIDTH\"" \
+ --cfg='feature="std"' \
+ --cfg='feature="general"' \
+ --cfg='feature="errno"' \
+ %rust_dylib_extern static_assertions \
+ %rust_dylib_extern libc \
+ ./src/lib.rs
+
+./%{real_crate_name}
+%endif
%clean
# ==========================================================
%files
%manifest %{name}.manifest
- %license LICENSE-APACHE
- %license LICENSE-MIT
- %license LICENSE-Apache-2.0_WITH_LLVM-exception
- %{_rust_dylibdir}/lib%{real_crate_name}.so
+%license LICENSE-APACHE
+%license LICENSE-MIT
+%license LICENSE-Apache-2.0_WITH_LLVM-exception
+%{_rust_dylibdir}/lib%{real_crate_name}.so