%bcond docs 1
%bcond introspection 1

# The shared library version
%global soversion 0.5

Name:           libipuz
Version:        0.5.2
Release:        1.20250228072502267259.master.35.gced359f%{?dist}
Summary:        Library for parsing .ipuz puzzle files

License:        LGPL-2.1-or-later OR MIT
URL:            https://gitlab.gnome.org/jrb/libipuz
Source:         libipuz-0.5.2.tar.gz
# rust: bump glib to 0.19.5

BuildRequires:  cargo-rpm-macros >= 24
BuildRequires:  cmake
BuildRequires:  gcc
BuildRequires:  gettext
BuildRequires:  meson
BuildRequires:  python3
BuildRequires:  sed
%if %{with docs}
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(sphinx-rtd-theme)
BuildRequires:  python3dist(myst-parser)
%endif

BuildRequires:  glib2-devel
BuildRequires:  json-glib-devel
%if %{with introspection}
BuildRequires:  gi-docgen
BuildRequires:  gobject-introspection-devel
%endif

%description
This is a library for parsing .ipuz puzzle files, for crossword puzzles,
sudokus, etc. The library only handles crosswords for now.

%package        devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}
%if %{with docs}
Suggests:       %{name}-doc = %{version}-%{release}
%endif

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%if %{with docs}
%package        doc
Summary:        Documentation for %{name}
BuildArch:      noarch

%description    doc
This package contains additional documentation for %{name}.
%endif

%package        tests
Summary:        Tests for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description    tests
The %{name}-tests package contains tests for %{name}.

%prep
%autosetup -p1 -n libipuz-0.5.2
%cargo_prep

# Drop version locks
rm libipuz/rust/Cargo.lock
sed -i '/Cargo.lock/d' libipuz/rust/meson.build

%generate_buildrequires
cd libipuz/rust
%cargo_generate_buildrequires

%build
%meson
%meson_build

%if %{with docs}
sphinx-build-3 docs html
rm -rf html/.{doctrees,buildinfo}
%endif

%install
%meson_install

%check
%meson_test

%files
%license LICENSE COPYING.LGPL COPYING.MIT
%doc README.md NEWS.md
%{_libdir}/lib%{name}-%{soversion}.so

%files devel
%{_includedir}/*
%if %{with introspection}
%{_datadir}/gir-1.0/Ipuz-1.0.gir
%{_libdir}/girepository-1.0/Ipuz-1.0.typelib
%endif
%{_libdir}/pkgconfig/%{name}-%{soversion}.pc

%if %{with docs}
%files doc
%license LICENSE COPYING.LGPL COPYING.MIT
%doc html
%if %{with introspection}
%doc %{_docdir}/%{name}-1.0/
%endif
%endif

%files tests
%dir %{_datadir}/installed-tests
%{_datadir}/installed-tests/%{name}-1.0
%dir %{_libexecdir}/installed-tests
%{_libexecdir}/installed-tests/%{name}-1.0

%changelog
* Fri Feb 28 2025 Packit <hello@packit.dev> - 0.5.2-1.20250228072502267259.master.35.gced359f
- More clean ups. Add the vfuncs, and some text improvements (Jonathan Blandford)
- Finished initial pass of updating crossword methods (Jonathan Blandford)
- Missed this i the valist change (Jonathan Blandford)
- Mark fix_all as being NULL terminated. (Jonathan Blandford)
- standardize dest_coord vs. target_coord (Jonathan Blandford)
- Change the vfunc from fix_all to fix_all_valist (Jonathan Blandford)
- Initial pass at IpuzCrosswords docs (Jonathan Blandford)
- Add Cryptic crossword docs (Jonathan Blandford)
- Clean up to grammar on barred docs (Jonathan Blandford)
- add ipuz_crossword_[sg]et_clue_placement (Jonathan Blandford)
- add some simple tests for cryptics (Jonathan Blandford)
- ipuz_crossword_new() should return a puzzle (Jonathan Blandford)
- Turn show-enumerations on by default when creating a new cryptic (Jonathan Blandford)
- rename showenumerations to show_enumerations (Jonathan Blandford)
- Add constructor docs (Jonathan Blandford)
- Make sure that `set_cell_bars()` has the styles set and available (Jonathan Blandford)
- Docs for IpuzBarred (Jonathan Blandford)
- Minor text cleanup of barred puzzles (Jonathan Blandford)
- Add a couple of "See also" comments (Jonathan Blandford)
- Clean up text (Jonathan Blandford)
- Add descriptions for all the puzzle types (Jonathan Blandford)
- Include the answers with this screenshot (Jonathan Blandford)
- Add an initial gallery of puzzle types (Jonathan Blandford)
- ipuz_acrostic_fix_all() was missing two fix functions (Jonathan Blandford)
- ipuz-acrostic: clear out old coords (Tanmay Patil)
- Docs for ipuz_cell_coord_array_coord_index (Jonathan Blandford)
- New function to find the index of a coord in an array (Jonathan Blandford)
- Post release version bump (Jonathan Blandford)
- rust: bump glib to 0.19.5 (Davide Cavalca)
- Update packit config (take 2) (Davide Cavalca)
- Update packit config (Davide Cavalca)