## START: Set by rpmautospec
## (rpmautospec version 0.3.5)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by rust2rpm 24
%bcond_without check

# Apache-2.0 OR MIT
# Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT
# BSD-2-Clause
# BSD-2-Clause AND ISC
# MIT
# MIT OR Apache-2.0
# Unlicense OR MIT
%global binary_license BSD-2-Clause AND ISC AND MIT AND (Apache-2.0 OR MIT) AND (Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT) AND (Unlicense OR MIT)
# LICENSE.dependencies contains a full license breakdown

%global crate rav1e

Name:           rust-rav1e
Version:        0.6.6
Release:        %autorelease
Summary:        Fastest and safest AV1 encoder

# rav1e is published under the terms of the BSD-2-Clause license,
# with the exception of one file: "src/ext/x86/x86inc.asm" (ISC license)
License:        BSD-2-Clause AND ISC
URL:            https://crates.io/crates/rav1e
Source0:        %{crates_source}
Source2:        cargo_config
# Automatically generated patch to strip foreign dependencies
Patch0:          rav1e-fix-metadata-auto.diff
#Patch0:         rav1e-cargo-no-git-default.patch
# Manually created patch for downstream crate metadata changes
# * update license expression in crate metadata
# * drop references to benchmarks
# * relax stricter-than-SemVer version requirements
# * drop unused, no-op rust_hawktracer dependency and tracing feature
# * drop unused and outdated optional clap_lex dependency
# * drop WASM-specific wasm-bindgen dependency and wasm feature
# * drop unused, benchmark-only criterion dev-dependency
Patch1:          rav1e-fix-metadata.diff
Patch2:          0001-remove-references-to-removed-built-and-rust_hawktrac.patch


BuildRequires:  cargo-rpm-macros >= 23
BuildRequires:  cargo-c
BuildRequires:  nasm
BuildRequires:  cargo >= 1.70

%global _description %{expand:
The fastest and safest AV1 encoder.}

%description %{_description}

%package     -n %{crate}
Summary:        %{summary}
License:        %{binary_license}

%description -n %{crate} %{_description}

%files       -n %{crate}
%license LICENSE
%license LICENSE.dependencies
%license PATENTS
%doc README.md
%{_bindir}/rav1e
%{_bindir}/rav1e-ch

%package     -n %{crate}-libs
Summary:        Library files for rav1e
License:        %{binary_license}

%description -n %{crate}-libs
Library files for rav1e, the fastest and safest AV1 encoder.

%files       -n %{crate}-libs
%license LICENSE
%license LICENSE.dependencies
%license PATENTS
%doc README.md
%{_libdir}/librav1e.so.0*

%package     -n %{crate}-devel
Summary:        %{summary}
License:        %{binary_license}
Requires:       %{crate}-libs%{?_isa} = %{version}-%{release}

%description -n %{crate}-devel %{_description}

%files       -n %{crate}-devel
%{_includedir}/rav1e/
%{_libdir}/librav1e.so
%{_libdir}/pkgconfig/rav1e.pc

%package        devel
Summary:        %{summary}
BuildArch:      noarch

%description    devel %{_description}

This package contains library source intended for building other packages which
use the "%{crate}" crate.

%files          devel
%license %{crate_instdir}/LICENSE
%license %{crate_instdir}/PATENTS
%doc %{crate_instdir}/README.md
%{crate_instdir}/


%prep
%autosetup -n %{crate}-%{version_no_tilde} -p1

#mkdir .cargo
#cp %{SOURCE2} .cargo/config

# Disable rav1e_js
#sed -i 's/"rav1e_js", //' Cargo.toml

%build
export RUSTFLAGS="%{build_rustflags}"

%cargo_build -f binaries,channel-api,unstable
%__cargo cbuild --release \
    --destdir=%{buildroot} \
    --prefix=%{_prefix} \
    --libdir=%{_libdir} \
    --includedir=%{_includedir} \
    --pkgconfigdir=%{_libdir}/pkgconfig
%cargo_license_summary -f binaries,channel-api,unstable
%{cargo_license -f binaries,channel-api,unstable} > LICENSE.dependencies

%install
%cargo_install -f binaries,channel-api,unstable
%__cargo cinstall --release \
    --destdir=%{buildroot} \
    --prefix=%{_prefix} \
    --libdir=%{_libdir} \
    --includedir=%{_includedir} \
    --pkgconfigdir=%{_libdir}/pkgconfig
rm -v %{buildroot}%{_libdir}/librav1e.a

mv -f .cargo/bin %{buildroot}%{_prefix}

%if %{with check}
%check
%cargo_test -f binaries,channel-api,unstable
%endif

%changelog
* Wed Jun 28 2023 Fabio Valentini <decathorpe@gmail.com> - 0.6.6-1
- Update to version 0.6.6; Fixes RHBZ#2149770

* Sun Feb 19 2023 Fabio Valentini <decathorpe@gmail.com> - 0.5.1-8
- Ensure default Rust compiler flags apply to the shared library build

* Sun Feb 19 2023 Fabio Valentini <decathorpe@gmail.com> - 0.5.1-7
- Disambiguate code which is ambiguous with Rust 1.67+

* Sun Feb 19 2023 Fabio Valentini <decathorpe@gmail.com> - 0.5.1-6
- Backport upstream patch to fix UB / crash in test code

* Mon Aug 08 2022 Fabio Valentini <decathorpe@gmail.com> - 0.5.1-5
- Remove unused dependencies; split off source-only Rust devel package

* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Sat Jun 25 2022 Robert-André Mauchin <zebob.m@gmail.com> - 0.5.1-3
- Fix devel package name

* Thu Jun 23 2022 Robert-André Mauchin <zebob.m@gmail.com> - 0.5.1-2
- Bump dav1d-sys dep

* Sun Jun 19 2022 Robert-André Mauchin <zebob.m@gmail.com> - 0.5.1-1
- Update to 0.5.1 Close: rhbz#2032033

* Tue Feb 22 2022 Fabio Valentini <decathorpe@gmail.com> - 0.5.0-6
- Hack the workaround of the workaround

* Tue Feb 22 2022 Fabio Valentini <decathorpe@gmail.com> - 0.5.0-5
- Work around codegen issues when compiling doctests with LLVM 13

* Mon Feb 21 2022 Fabio Valentini <decathorpe@gmail.com> - 0.5.0-4
- Bump system-deps from 3.1.2 to 6

* Tue Feb 15 2022 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.5.0-3
- Rebuild with package notes

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Sun Nov 21 2021 Robert-André Mauchin <zebob.m@gmail.com> - 0.5.0-1
- Update to 0.5.0 Close: rhbz#1991588

* Sat Aug 07 2021 Fabio Valentini <decathorpe@gmail.com> - 0.4.1-4
- Rebuild with crossbeam-deque 0.8.1 / 0.7.4 for CVE-2021-32810

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Sat Jul 10 12:15:47 CEST 2021 Robert-André Mauchin <zebob.m@gmail.com> - 0.4.1-2
- Add patch to fix https://github.com/xiph/rav1e/issues/2662

* Wed Apr  7 17:07:05 CEST 2021 Robert-André Mauchin <zebob.m@gmail.com> - 0.4.1-1
- Update to 0.4.1
- Close: rhbz#1915864

* Mon Mar 29 16:18:27 CEST 2021 Robert-André Mauchin <zebob.m@gmail.com> - 0.4.0-1
- Update to 0.4.0
- Close: rhbz#1915864

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.0~alpha-0.3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Mon Dec 28 13:32:03 CET 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 0.4.0~alpha-0.2
- Rebuild

* Wed Dec 09 15:17:53 CET 2020 Robert-André Mauchin <zebob.m@gmail.com> - 0.4.0~alpha-0.1
- Update to 0.4.0~alpha

* Sun Dec 06 04:37:40 CET 2020 Robert-André Mauchin <zebob.m@gmail.com> - 0.3.4-3
- Rebuild with new cargo-c to fix pkgconfig includedir
- Fix: rhbz#1902211

* Tue Oct 20 2020 Fabio Valentini <decathorpe@gmail.com> - 0.3.4-2
- Temporarily skip some broken tests on aarch64.

* Tue Oct 20 2020 Fabio Valentini <decathorpe@gmail.com> - 0.3.4-1
- Update to version 0.3.4.

* Wed Aug 26 2020 Josh Stone <jistone@redhat.com> - 0.3.3-3
- Bump paste to 1.0

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu Jun 11 2020 Josh Stone <jistone@redhat.com> - 0.3.3-1
- Update to 0.3.3

* Mon Mar 09 17:45:25 CET 2020 Robert-André Mauchin <zebob.m@gmail.com> - 0.3.1-2
- Fix pkgconfig prefix path

* Thu Feb 20 21:15:47 CET 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 0.3.1-1
- Update to 0.3.1

* Tue Feb 11 01:28:07 CET 2020 Robert-André Mauchin <zebob.m@gmail.com> - 0.3.0-1
- Initial package