# crate-type : dylib, proc-macro, cdylib, bin, etc.
# ==========================================================
%build
- %{rustc_std_build} --crate-type=dylib \
- --crate-name=%{real_crate_name} \
- %{?rustc_edition:--edition=%{rustc_edition}} \
- --cfg='feature="with-alloc"' \
- %rust_dylib_extern adler \
- ./src/lib.rs
+%{rustc_std_build} --crate-type=dylib \
+ --crate-name=%{real_crate_name} \
+ %{?rustc_edition:--edition=%{rustc_edition}} \
+ --cfg='feature="with-alloc"' \
+ %rust_dylib_extern adler \
+ ./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}
+%{rustc_std_build} --test --crate-type=dylib \
+ --crate-name=%{real_crate_name} \
+ %{?rustc_edition:--edition=%{rustc_edition}} \
+ --cfg='feature="with-alloc"' \
+ %rust_dylib_extern adler \
+ ./src/lib.rs
+
+./%{real_crate_name}
+%endif
%clean
# ==========================================================
%files
%manifest %{name}.manifest
- %license LICENSE-APACHE.md
- %license LICENSE-MIT.md
- %license LICENSE-ZLIB.md
- %{_rust_dylibdir}/lib%{real_crate_name}.so
+%license LICENSE-APACHE.md
+%license LICENSE-MIT.md
+%license LICENSE-ZLIB.md
+%{_rust_dylibdir}/lib%{real_crate_name}.so