summaryrefslogtreecommitdiff
path: root/media-gfx/swayimg/swayimg-5.6.ebuild
blob: 4a02e08b7815021edc35a88866ffcd6e6c141a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# Copyright 2023-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

LUA_COMPAT=( lua5-{1,3,4} luajit )
inherit eapi9-ver lua-single meson xdg

DESCRIPTION="Lightweight image viewer for Wayland display servers"
HOMEPAGE="https://github.com/artemsen/swayimg"
SRC_URI="https://github.com/artemsen/${PN}/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="avif bash-completion drm exif ffmpeg gif heif jpeg jpeg2k jpegxl png raw sixel svg test tiff +wayland webp X"
REQUIRED_USE="
	${LUA_REQUIRED_USE}
	|| ( drm wayland )
"
RESTRICT="!test? ( test )"

# disable exr until #966735 is fixed
#	exr? ( >=media-libs/openexr-3.4:= )
#		$(meson_feature exr)
RDEPEND="
	${LUA_DEPS}
	media-libs/fontconfig
	media-libs/freetype
	x11-libs/libxkbcommon
	avif? ( >=media-libs/libavif-1.0:= )
	bash-completion? ( app-shells/bash-completion )
	drm? ( x11-libs/libdrm )
	exif? ( media-gfx/exiv2:= )
	ffmpeg? ( >=media-video/ffmpeg-6.1:= )
	gif? ( media-libs/giflib:= )
	heif? ( media-libs/libheif:= )
	jpeg? ( media-libs/libjpeg-turbo:= )
	jpeg2k? ( media-libs/openjpeg:= )
	jpegxl? ( media-libs/libjxl:= )
	png? ( media-libs/libpng:= )
	raw? ( media-libs/libraw:= )
	sixel? ( media-libs/libsixel )
	svg? (
		dev-libs/glib:2
		>=gnome-base/librsvg-2.46:2
		x11-libs/cairo[X=]
	)
	tiff? ( media-libs/tiff:= )
	wayland? ( dev-libs/wayland )
	webp? ( media-libs/libwebp:= )
"
DEPEND="
	${RDEPEND}
	svg? ( X? ( x11-base/xorg-proto ) )
	test? ( dev-cpp/gtest )
	wayland? ( >=dev-libs/wayland-protocols-1.35 )
"
BDEPEND="
	wayland? ( dev-util/wayland-scanner )
"

PATCHES=(
	"${FILESDIR}"/${PN}-5.1-precompiled_doc.patch

	# merged
	"${FILESDIR}"/${P}-missing_include.patch
)

DOCS=( CONFIG.md README.md USAGE.md )

src_prepare() {
	default

	if use test; then
		if ! use ffmpeg; then
			sed -e '/video = {.*$/,/^  },$/d' \
				-i extra/example.lua || die
		fi
		if ! use raw; then
			sed -e '/raw = {.*$/,/^  },$/d' \
				-i extra/example.lua || die
		fi
	fi
}

src_configure() {
	local emesonargs=(
		$(meson_feature avif)
		$(meson_feature drm)
		$(meson_feature exif)
		$(meson_feature ffmpeg video)
		$(meson_feature gif)
		$(meson_feature heif)
		$(meson_feature jpeg)
		$(meson_feature jpeg2k jp2)
		$(meson_feature jpegxl jxl)
		$(meson_feature png)
		$(meson_feature raw)
		$(meson_feature sixel)
		$(meson_feature svg)
		$(meson_feature test tests)
		$(meson_feature tiff)
		$(meson_feature wayland)
		$(meson_feature wayland compositor)
		$(meson_feature webp)
		$(meson_feature bash-completion bash)
		-Dliblua=lua
		-Dversion=${PV}
		-Ddesktop=true
		-Ddoc=false
		-Dlicense=false
		-Dluameta=true
		-Dman=true
		-Dzsh=enabled
	)
	meson_src_configure
}

src_test() {
	local skip_tests=()
	# Set LC_COLLATE=en_US.utf8 if available for ImageListTest.SortAlphaUnicode
	if locale -a | grep -iq "en_US.utf8"; then
		local -x LC_COLLATE="en_US.utf8"
	else
		skip_tests+=( ImageListTest.SortAlphaUnicode )
	fi

	local -x GTEST_FILTER=$(echo -$(IFS=:; echo "${skip_tests[*]}"))
	meson_src_test
}

pkg_postinst() {
	xdg_pkg_postinst

	if ver_replacing -lt 5.0; then
		elog "The Swayimg configuration file is now a Lua script."
		elog "${EROOT}/usr/share/swayimg/swayimg.lua contains a description of Lua bindings."
		elog "${EROOT}/usr/share/swayimg/example.lua contains a detailed example."
		elog "The new user config file is ~/.config/swayimg/init.lua"
	fi
}