# Generated by rust2rpm 26
%bcond_without check

%global crate rustc-demangle-capi

Name:           rust-rustc-demangle-capi
# The SONAME version is constructed based on the semantic version; for pre-1.0
# releases, that means MAJOR.MINOR. Still, to avoid undetected SONAME version
# bumps, we document it manually in the spec file rather than constructing it
# from the package version.
%global so_version 0.1
Version:        0.1.0
Release:        %autorelease
Summary:        C API for the rustc-demangle crate

# Upstream license specification: MIT/Apache-2.0
License:        MIT OR Apache-2.0
URL:            https://crates.io/crates/rustc-demangle-capi
Source:         %{crates_source}
# * “Add license files into the capi crate tarball”
#   https://github.com/rust-lang/rustc-demangle/pull/73; fixes “Include LICENSE
#   files in the published rustc-demangle-capi crate”
#   https://github.com/rust-lang/rustc-demangle/issues/72
Source10:       https://github.com/rust-lang/rustc-demangle/raw/refs/tags/0.1.24/LICENSE-APACHE
# * “Add license files into the capi crate tarball”
#   https://github.com/rust-lang/rustc-demangle/pull/73; fixes “Include LICENSE
#   files in the published rustc-demangle-capi crate”
#   https://github.com/rust-lang/rustc-demangle/issues/72
Source11:       https://github.com/rust-lang/rustc-demangle/raw/refs/tags/0.1.24/LICENSE-MIT
# Manually created patch for downstream crate metadata changes
# * “Support building the C library with cargo-c”
#   https://github.com/rust-lang/rustc-demangle/pull/74
Patch:          rustc-demangle-capi-fix-metadata.diff

BuildRequires:  cargo-rpm-macros >= 24
BuildRequires:  cargo-c

%global _description %{expand:
C API for the `rustc-demangle` crate.}

%description %{_description}

%package     -n librustc_demangle
Summary:        %{summary}
# MIT OR Apache-2.0
License:        MIT OR Apache-2.0
# LICENSE.dependencies contains a full license breakdown

%description -n librustc_demangle %{_description}

This package contains the shared library providing the C API for
rustc-demangle.

%files       -n librustc_demangle
%license LICENSE-APACHE LICENSE-MIT
%license LICENSE.dependencies
%{_libdir}/librustc_demangle.so.%{so_version}{,.*}

%package     -n librustc_demangle-devel
Summary:        %{summary}

Requires:       librustc_demangle%{?_isa} = %{version}-%{release}

%description -n librustc_demangle-devel %{_description}

This package contains headers and other files needed to develop and build
programs that use the C API for rustc-demangle.

%files       -n librustc_demangle-devel
%{_includedir}/rustc_demangle/
%{_libdir}/librustc_demangle.so
%{_libdir}/pkgconfig/rustc_demangle.pc

%prep
%autosetup -n %{crate}-%{version} -p1
cp -p '%{SOURCE10}' '%{SOURCE11}' .
%cargo_prep

%generate_buildrequires
%cargo_generate_buildrequires -a

%build
%cargo_build -a
%{cargo_license_summary -a}
%{cargo_license -a} > LICENSE.dependencies
%cargo_cbuild -a

%install
%cargo_cinstall -a
# https://docs.fedoraproject.org/en-US/packaging-guidelines/#packaging-static-libraries
rm '%{buildroot}%{_libdir}/librustc_demangle.a'

%if %{with check}
%check
%cargo_test -a
%endif

%changelog
%autochangelog