File powdertoy.spec of Package powdertoy

#
# spec file for package powdertoy
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


# powdertoy needs a c++20 compiler at least
%if 0%{?sle_version} && 0%{?sle_version} < 160000
%global force_gcc_version 13
%endif
Name:           powdertoy
Version:        99.3.384
Release:        0
Summary:        Physics sandbox game
License:        GPL-3.0-only
URL:            https://powdertoy.co.uk
Source:         https://github.com/The-Powder-Toy/The-Powder-Toy/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  AppStream
BuildRequires:  gcc%{?force_gcc_version}-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  meson >= 0.64.0
BuildRequires:  pkgconfig
BuildRequires:  python3
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(fftw3)
BuildRequires:  pkgconfig(jsoncpp)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(luajit)
BuildRequires:  pkgconfig(sdl2)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(zlib)

%description
The Powder Toy is a free physics sandbox game, which simulates
air pressure and velocity, heat, gravity and a countless number
of interactions between different substances! The game provides
you with various building materials, liquids, gases and electronic
components which can be used to construct complex machines, guns,
bombs, realistic terrains and almost anything else.

%prep
%autosetup -n The-Powder-Toy-%{version} -p1

sed -e 's/<screenshot>/<screenshot type="default">/' \
    -i resources/appdata.template.xml

%build
%if 0%{?force_gcc_version}
export CXX="g++-%{force_gcc_version}"
%endif
%meson \
%ifarch %ix86
    -Dx86_sse=avx2 \
%endif
    -Dmanifest_date="$(date --iso-8601 -d@${SOURCE_DATE_EPOCH:-0})"
%meson_build

%install
install -D -m 0755 -t %{buildroot}%{_bindir} %{_vpath_builddir}/powder
install -D -m 0644 %{_vpath_builddir}/resources/powder.desktop \
	%{buildroot}%{_datadir}/applications/uk.co.powdertoy.tpt.desktop
install -D -m 0644 %{_vpath_builddir}/resources/appdata.xml \
	%{buildroot}%{_datadir}/metainfo/uk.co.powdertoy.tpt.metainfo.xml
install -D -m 0644 resources/save.xml %{buildroot}%{_datadir}/mime/packages/powdertoy-save.xml
install -D -m 0644 resources/powder.man %{buildroot}%{_mandir}/man6/powder.6

install -D -m 0644 resources/icon_exe.svg \
	%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/powdertoy-powder.svg
install -D -m 0644 resources/icon_cps.svg \
	%{buildroot}%{_datadir}/icons/hicolor/scalable/mimetypes/application-vnd.powdertoy.save.svg
install -D -m 0644 resources/generated_icons/icon_exe.png \
	%{buildroot}%{_datadir}/icons/hicolor/256x256/apps/powdertoy-powder.png
install -D -m 0644 resources/generated_icons/icon_cps.png \
	%{buildroot}%{_datadir}/icons/hicolor/256x256/mimetypes/application-vnd.powdertoy.save.png

%suse_update_desktop_file uk.co.powdertoy.tpt
appstreamcli validate --no-net \
	%{buildroot}%{_datadir}/metainfo/uk.co.powdertoy.tpt.metainfo.xml

%files
%license LICENSE
%doc README.md
%{_bindir}/powder
%{_datadir}/applications/uk.co.powdertoy.tpt.desktop
%{_datadir}/icons/hicolor/*/apps/powdertoy-powder.{png,svg}
%{_datadir}/icons/hicolor/*/mimetypes/application-vnd.powdertoy.save.{png,svg}
%{_datadir}/metainfo/uk.co.powdertoy.tpt.metainfo.xml
%{_datadir}/mime/packages/powdertoy-save.xml
%{_mandir}/man6/powder.6%{?ext_man}

%changelog
openSUSE Build Service is sponsored by