summaryrefslogtreecommitdiff
path: root/dev-games/aseprite/aseprite-1.3.16.1.ebuild
blob: 4ab2d9de8cd5af9088bf3afd32293c59b8d343be (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

PYTHON_COMPAT=( python3_{13..14} )

inherit cmake desktop flag-o-matic python-any-r1 toolchain-funcs xdg-utils

SKIA_VER="m124-08a5439a6b"

DESCRIPTION="Animated sprite editor & pixel art tool"
HOMEPAGE="https://www.aseprite.org"
# Use forked skia sources with local shanges
# Precompiled skia required only for icudtl.dat
SRC_URI="https://github.com/aseprite/aseprite/releases/download/v$(ver_cut 1-3 ${PV})/Aseprite-v${PV}-Source.zip
	https://github.com/aseprite/skia/archive/refs/tags/${SKIA_VER}.tar.gz ->
		skia-${SKIA_VER}-aseprite.tar.gz
	https://github.com/aseprite/skia/releases/download/${SKIA_VER}/Skia-Linux-Release-x64.zip ->
		Skia-Linux-Release-x64-${SKIA_VER}.zip
"

# See https://github.com/aseprite/aseprite#license
LICENSE="Aseprite-EULA BSD MIT"
SLOT="0"
KEYWORDS="amd64 ~x86"

IUSE="test webp"

RESTRICT="bindist mirror !test? ( test )"

COMMON_DEPEND="
	app-arch/libarchive:=
	app-text/cmark:=
	dev-libs/icu:=
	dev-libs/libfmt:=
	dev-libs/tinyxml2:=
	media-libs/fontconfig
	media-libs/freetype
	media-libs/giflib:=
	media-libs/harfbuzz:=[truetype]
	media-libs/libjpeg-turbo:=
	media-libs/libpng:=
	net-misc/curl
	virtual/zlib:=
	virtual/opengl
	x11-libs/libX11
	x11-libs/libXcursor
	x11-libs/libXi
	x11-libs/libxcb:=
	webp? ( media-libs/libwebp:= )
"
RDEPEND="
	${COMMON_DEPEND}
	gnome-extra/zenity
"
DEPEND="
	${COMMON_DEPEND}
	x11-base/xorg-proto"
BDEPEND="
	${PYTHON_DEPS}
	test? ( dev-cpp/gtest )
	app-arch/unzip
	dev-build/gn
	virtual/pkgconfig
"

DOCS=(
	docs/ase-file-specs.md
	docs/gpl-palette-extension.md
	README.md
)

PATCHES=(
	"${FILESDIR}/aseprite-1.3.16.1_shared_libarchive.patch"
	"${FILESDIR}/aseprite-1.3.16.1_shared_json11.patch"
	"${FILESDIR}/aseprite-1.3.16.1_shared_webp.patch"
	"${FILESDIR}/aseprite-1.3.16.1_laf_fixes.patch"
	"${FILESDIR}/aseprite-1.3.16.1_shared_fmt.patch"
	"${FILESDIR}/aseprite-1.3.16.1_shared_tinyxml2.patch"
	"${FILESDIR}/aseprite-1.3.16.1_shared_libjpeg-turbo.patch"
	"${FILESDIR}/aseprite-1.3.16.1_shared_icu.patch"
)

src_unpack() {
	mkdir "${S}" || die
	pushd "${S}" > /dev/null || die
		default
	popd > /dev/null || die
}

src_prepare() {
	cmake_src_prepare
	# Skia: remove custom optimizations
	sed -i -e 's:"\/\/gn\/skia\:optimize",::g' \
		"skia-${SKIA_VER}/gn/BUILDCONFIG.gn" || die
	# Aseprite: don't install targets from third_party projects
	sed -i -e \
		's:add_subdirectory(tga):add_subdirectory(tga EXCLUDE_FROM_ALL):g' \
		src/CMakeLists.txt || die
	sed -i \
		-e 's:add_subdirectory(json11):add_subdirectory(json11 EXCLUDE_FROM_ALL):g' \
		-e 's:add_subdirectory(TinyEXIF):add_subdirectory(TinyEXIF EXCLUDE_FROM_ALL):g' \
			third_party/CMakeLists.txt || die
	# Aseprite: don't use bundled gtest
	cmake_comment_add_subdirectory -f laf/third_party googletest
	# Fix shebang in thumbnailer
	sed -i -e 's:#!/usr/bin/sh:#!/bin/sh:' \
		src/desktop/linux/aseprite-thumbnailer || die
	# Move icudtl.dat to expected location
	mkdir -p "skia-${SKIA_VER}/third_party/externals/icu/flutter" || die
	cp third_party/externals/icu/flutter/icudtl.dat \
		"skia-${SKIA_VER}/third_party/externals/icu/flutter" || die
}

src_configure() {
	# -Werror=strict-aliasing, -Werror=odr, -Werror=lto-type-mismatch
	# https://bugs.gentoo.org/924692
	# https://github.com/aseprite/aseprite/issues/4413
	#
	# There is a bundled skia that fails with ODR errors. When excluding just
	# skia from testing, aseprite itself failed with strict-aliasing (before
	# upstream PR#84), and when that is disabled, fails again with ODR and
	# lto-type-mismatch issues.
	#
	# There are a lot of issues, so don't trust any fixes without thorough
	# testing.
	append-flags -fno-strict-aliasing
	filter-lto

	einfo "Skia configuration"
	pushd "skia-${SKIA_VER}" > /dev/null || die
		tc-export AR CC CXX

		passflags() {
			local _f _x
			_f=( ${1} )
			_x="[$(printf '"%s", ' "${_f[@]}")]"
			myconf_gn+=( ${2}="${_x}" )
		}

		local myconf_gn=(
			ar=\"${AR}\"
			cc=\"${CC}\"
			cxx=\"${CXX}\"

			is_official_build=true
			is_component_build=false
			is_debug=false

			skia_use_egl=false
			skia_use_dawn=false
			skia_use_dng_sdk=false
			skia_use_metal=false
			skia_use_wuffs=false

			skia_enable_pdf=false
			skia_enable_svg=false
			skia_enable_skunicode=true
			skia_use_expat=false
			skia_use_ffmpeg=false
			skia_use_fontconfig=true
			skia_use_freetype=true
			skia_use_gl=true
			skia_use_harfbuzz=true
			skia_use_icu=true
			skia_use_libjpeg_turbo_decode=true
			skia_use_libjpeg_turbo_encode=true
			skia_use_libpng_decode=true
			skia_use_libpng_encode=true
			skia_use_libwebp_decode=$(usex webp true false)
			skia_use_libwebp_encode=$(usex webp true false)
			skia_use_lua=false
			skia_use_vulkan=false
			skia_use_x11=false
			skia_use_xps=false
			skia_use_zlib=true
		)

		passflags "${CFLAGS}" extra_cflags_c
		passflags "${CXXFLAGS}" extra_cflags_cc
		passflags "${LDFLAGS}" extra_ldflags
		myconf_gn="${myconf_gn[@]}"
		set -- gn gen --args="${myconf_gn% }" out/Static
		echo "$@"
		"$@" || die
	popd > /dev/null || die

	einfo "Aseprite configuration"
	local mycmakeargs=(
		-DENABLE_CCACHE=OFF
		-DENABLE_DESKTOP_INTEGRATION=ON
		-DENABLE_I18N_STRINGS=OFF
		-DENABLE_SCRIPTING=OFF
		-DENABLE_STEAM=OFF
		-DENABLE_TESTS="$(usex test)"
		-DENABLE_QT_THUMBNAILER=OFF
		-DENABLE_UPDATER=OFF
		-DENABLE_WEBP="$(usex webp)"
		-DLAF_WITH_EXAMPLES=OFF
		-DLAF_WITH_TESTS="$(usex test)"
		-DFULLSCREEN_PLATFORM=ON
		-DSKIA_DIR="${S}/skia-${SKIA_VER}/"
		-DSKIA_LIBRARY_DIR="${S}/skia-${SKIA_VER}/out/Static/"
		-DSKIA_LIBRARY="${S}/skia-${SKIA_VER}/out/Static/libskia.a"
		-DSKSHAPER_LIBRARY="${S}/skia-${SKIA_VER}/out/Static/libskshaper.a"
		-DSKUNICODE_LIBRARY="${S}/skia-${SKIA_VER}/out/Static/libskunicode.a"
		-DUSE_SHARED_CMARK=ON
		-DUSE_SHARED_CURL=ON
		-DUSE_SHARED_FMT=ON
		-DUSE_SHARED_FREETYPE=ON
		-DUSE_SHARED_GIFLIB=ON
		-DUSE_SHARED_HARFBUZZ=ON
		-DUSE_SHARED_JSON11=OFF		# Custom methods added to bundled version
		-DUSE_SHARED_LIBARCHIVE=ON
		-DUSE_SHARED_LIBPNG=ON
		-DUSE_SHARED_PIXMAN=ON
		-DUSE_SHARED_TINYXML=ON
		-DUSE_SHARED_WEBP=ON
		-DUSE_SHARED_ZLIB=ON
	)
	cmake_src_configure
}

src_compile() {
	einfo "Skia compilation"
	pushd "skia-${SKIA_VER}" > /dev/null || die
		eninja -C out/Static
	popd > /dev/null || die

	einfo "Aseprite compilation"
	cmake_src_compile
}

src_install() {
	newicon -s 64 "${S}/data/icons/ase64.png" "${PN}.png"
	cmake_src_install
}

pkg_postinst() {
	xdg_desktop_database_update
	xdg_icon_cache_update
	xdg_mimeinfo_database_update
}

pkg_postrm() {
	xdg_desktop_database_update
	xdg_icon_cache_update
	xdg_mimeinfo_database_update
}