%bcond docs 1
%bcond introspection 1

# The shared library version
%global soversion 0.5

Name:           libipuz
Version:        0.5.2
Release:        1.20250311002901355343.master.99.g2360aa4%{?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
* Tue Mar 11 2025 Packit <hello@packit.dev> - 0.5.2-1.20250311002901355343.master.99.g2360aa4
- ipuz_guesses_set_stride_guess(): don't push empty strings (Federico Mena Quintero)
- Fix types in tests (Federico Mena Quintero)
- Guesses::new_from_value() - translate "" to a Normal cell with guess: None (Federico Mena Quintero)
- Remove obsolete comment (Federico Mena Quintero)
- Convert the guess member of IpuzGuessCell to Option<CString> (Jonathan Blandford)
- get_stride_guess is now const, and not freeable (Jonathan Blandford)
- Convert tests to CStrings (Jonathan Blandford)
- Fix copy-paste error in set_stride_guess (Jonathan Blandford)
- Convert stride_guess to a const gchar * (Jonathan Blandford)
- Clarify docs on strides. Include Class docs as well (Jonathan Blandford)
- Add documentation (Jonathan Blandford)
- test get_count_crossed_off() (Jonathan Blandford)
- Implement get_count_crossed_off () (Jonathan Blandford)
- Fix documentation to indicate we use Puzzle.empty instead of ' ' (Jonathan Blandford)
- Test set_stride_guess() with multibyte empty and block (Jonathan Blandford)
- Change check_stride to use IpuzPuzzle:empty to mark the empty spaces (Jonathan Blandford)
- add `ipuz_nonogram_set_count_crossed_off()` (Jonathan Blandford)
- Change IpuzGrid:width,height properties to unsigned (Philip Chimento)
- Test that the stride in the guesses for nonograms is initialized (Jonathan Blandford)
- Add an implementation fo check_stride (Jonathan Blandford)
- Change order of direction and index in `get_clues()` (Jonathan Blandford)
- Add missing commit (Jonathan Blandford)
- Fix documentation bug (Jonathan Blandford)
- Initialize the strides for each puzzle (Jonathan Blandford)
- Add an example to create_guesses() (Jonathan Blandford)
- New function and vfunc: check_stride() (Jonathan Blandford)
- 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)
- update the nonogram docs to reflect the representation changes (Jonathan Blandford)
- Update nonogram docs to match new approach (Jonathan Blandford)
- Minor docs fix (Jonathan Blandford)
- remove extra space (Jonathan Blandford)
- Fix some docs errors (Jonathan Blandford)
- Add a :space property to IpuzNonogram (Jonathan Blandford)
- Rename stride_data to stride_guess everywhere (Federico Mena Quintero)
- Remove ipuz-rust.h (Federico Mena Quintero)
- Add Cryptic crossword docs (Jonathan Blandford)
- Clean up to grammar on barred docs (Jonathan Blandford)
- add ipuz_crossword_[sg]et_clue_placement (Jonathan Blandford)
- Update crates (Federico Mena Quintero)
- Document the new methods in Rust (Federico Mena Quintero)
- Docstrings for ipuz_guesses_set/get_stride_data() (Federico Mena Quintero)
- Test roundtripping of guesses with stride data (Federico Mena Quintero)
- Test roundtripping of guesses without stride data (Federico Mena Quintero)
- Test that guesses without stride data don't serialize keys for it (Federico Mena Quintero)
- Extract a to_json_value() method (Federico Mena Quintero)
- Import serde_json::Value so we don't have to spell it out everywhere (Federico Mena Quintero)
- Rename constant (Federico Mena Quintero)
- Guesses: extract a to_string() method (Federico Mena Quintero)
- Add temporary variable (Federico Mena Quintero)
- 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)
- Implement ipuz_guesses_get/set_stride_data() (Federico Mena Quintero)
- Add Rust version of IpuzClueDirection (Federico Mena Quintero)
- 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 initial tests for ipuz_guesses_get/set_stride_data() (Federico Mena Quintero)
- Add prototypes for ipuz_guesses_get/set_stride_data (Federico Mena Quintero)
- Add tests for the stride validation function (Federico Mena Quintero)
- Guesses: add fields for the per_row_stride_data / per_column_stride_data (Federico Mena Quintero)
- Extract json content to a temporary variable (Federico Mena Quintero)
- Remove superfluous assignments (Federico Mena Quintero)
- Use a shorter syntax for creating a vector with identical elements (Federico Mena Quintero)
- Avoid a little duplication (Federico Mena Quintero)
- Use usize for the row/column field in Guesses (Federico Mena Quintero)
- Turn resize() into a method (Federico Mena Quintero)
- Use CellCoord for the implementation code instead of IpuzCellCoord (Federico Mena Quintero)
- Add a CellCoord type with usize fields, instead of c_uint (Federico Mena Quintero)
- Fix reversed assertion (Federico Mena Quintero)
- Remove ipuz_noop() (Federico Mena Quintero)
- 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)