From 525a99edef643e31e5cedb5c7a5566d3ccd8afc0 Mon Sep 17 00:00:00 2001
From: ImperatorStorm <imperatorstorm11@protonmail.com>
Date: Fri, 5 Aug 2022 20:28:27 -0700
Subject: [PATCH 1/2] Fix `shared-libwebp.patch`.

---
 .SRCINFO             |  4 ++--
 PKGBUILD             | 10 ++++++++--
 shared-libwebp.patch | 32 +++++++++++++++++---------------
 3 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/.SRCINFO b/.SRCINFO
index 431cf0d..cd7f8ae 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
 pkgbase = aseprite
 	pkgdesc = Create animated sprites and pixel art
 	pkgver = 1.2.39
-	pkgrel = 1
+	pkgrel = 2
 	url = https://www.aseprite.org/
 	arch = x86_64
 	license = custom
@@ -46,7 +46,7 @@ pkgbase = aseprite
 	sha256sums = 8b14e36939e930de581e95abf0591645aa0fcfd47161cf88b062917dbaaef7f9
 	sha256sums = 821f1354dbbc0bb3fa700e63037ed3c89b0d32bd2ab253450f91eeacd7d47c06
 	sha256sums = d7f2f8c43d24382453273ed17b1c0e05928980a36ad0b7c988da3aa0fe32de53
-	sha256sums = 2d6b5f33f23adc4f9912511ac35311a776ce34519ef40e9db3659e4c5457f055
+	sha256sums = 19352033f2e5787229b2b71f7e961aeb24f293fb0b188a774140a7830f2b344b
 	sha256sums = eb9f544e68b41b5cb1a9ab7a6648db51587e67e94f1a452cb5a84f3d224bf5d0
 	sha256sums = c2d14f9738a96a9db3695c00ac3d14b1312b6a595b151bd56e19422c86517654
 
diff --git a/PKGBUILD b/PKGBUILD
index 91ca6d1..78642cf 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -12,7 +12,7 @@ pkgname=aseprite
 pkgver=1.2.39
 _skiaver=m102
 _skiahash=861e4743af
-pkgrel=1
+pkgrel=2
 pkgdesc='Create animated sprites and pixel art'
 arch=('x86_64')
 url="https://www.aseprite.org/"
@@ -56,7 +56,7 @@ sha256sums=('b84e67061a9600c6c508af26944851ce277f4e912bf73d8e9e83a2eba5510c21'
             '8b14e36939e930de581e95abf0591645aa0fcfd47161cf88b062917dbaaef7f9'
             '821f1354dbbc0bb3fa700e63037ed3c89b0d32bd2ab253450f91eeacd7d47c06'
             'd7f2f8c43d24382453273ed17b1c0e05928980a36ad0b7c988da3aa0fe32de53'
-            '2d6b5f33f23adc4f9912511ac35311a776ce34519ef40e9db3659e4c5457f055'
+            '19352033f2e5787229b2b71f7e961aeb24f293fb0b188a774140a7830f2b344b'
             'eb9f544e68b41b5cb1a9ab7a6648db51587e67e94f1a452cb5a84f3d224bf5d0'
             'c2d14f9738a96a9db3695c00ac3d14b1312b6a595b151bd56e19422c86517654')
 
@@ -68,14 +68,20 @@ prepare() {
 	mkdir -p skia
 	bsdtar xf skia-$_skiaver.tar.gz  --strip-components=1 -C skia
 	# Fix up Aseprite's desktop integration
+	echo desktop
 	env -C aseprite patch -tp1 <desktop.patch
 	# Allow using more shared libs
+	echo fmt
 	env -C aseprite patch -tp1 <shared-fmt.patch
+	echo libarchive
 	env -C aseprite patch -tp1 <shared-libarchive.patch
+	echo libwebp
 	env -C aseprite patch -tp1 <shared-libwebp.patch
+	echo pixman
 	env -C aseprite patch -tp1 <optional-pixman.patch
 	# Their "FindSkia" module forcefully tries to use Skia's FreeType and HarfBuzz,
 	# but we don't clone those because we use the shared ones. Avoid overwriting the settings instead.
+	echo skiadeps
 	env -C aseprite patch -tp1 <shared-skia-deps.patch
 }
 
diff --git a/shared-libwebp.patch b/shared-libwebp.patch
index 071327d..e0d992a 100644
--- a/shared-libwebp.patch
+++ b/shared-libwebp.patch
@@ -11,10 +11,10 @@ Making optional linking with shared system webp library with
  2 files changed, 10 insertions(+), 4 deletions(-)
 
 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index f16f09660d..40065905d3 100644
+index af077f6..fed17ff 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -66,6 +66,7 @@ option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
+@@ -58,6 +58,7 @@ option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
  option(USE_SHARED_PIXMAN  "Use your installed copy of pixman" off)
  option(USE_SHARED_FREETYPE "Use shared FreeType library" off)
  option(USE_SHARED_HARFBUZZ "Use shared HarfBuzz library" off)
@@ -22,13 +22,11 @@ index f16f09660d..40065905d3 100644
  option(ENABLE_ASEPRITE_EXE "Compile main Aseprite executable" on)
  option(ENABLE_MEMLEAK      "Enable memory-leaks detector (only for developers)" off)
  option(ENABLE_NEWS         "Enable the news in Home tab" on)
-@@ -229,9 +230,17 @@ add_definitions(-DPNG_NO_MMX_CODE) # Do not use MMX optimizations in PNG code
- 
+@@ -350,14 +353,18 @@ add_subdirectory(laf)
  # libwebp
  if(ENABLE_WEBP)
--  set(WEBP_LIBRARIES webp webpdemux libwebpmux)
--  set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)
--  include_directories(${WEBP_INCLUDE_DIR})
+   # Use libwebp from Skia
+-  if(LAF_BACKEND STREQUAL "skia")
 +  if(USE_SHARED_WEBP)
 +    find_library(WEBP_LIBRARY NAMES webp)
 +    find_library(WEBPDEMUX_LIBRARY NAMES webpdemux)
@@ -36,13 +34,17 @@ index f16f09660d..40065905d3 100644
 +    set(WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBPDEMUX_LIBRARY} ${WEBPMUX_LIBRARY})
 +    find_path(WEBP_INCLUDE_DIRS NAMES decode.h PATH_SUFFIXES webp)
 +  else()
-+    set(WEBP_LIBRARIES webp webpdemux libwebpmux)
-+    set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)
-+    include_directories(${WEBP_INCLUDE_DIR})
-+  endif()
++    if(LAF_BACKEND STREQUAL "skia")
+     find_library(WEBP_LIBRARIES webp
+       NAMES libwebp # required for Windows
+       PATHS "${SKIA_LIBRARY_DIR}" NO_DEFAULT_PATH)
+     set(WEBP_INCLUDE_DIR "${SKIA_DIR}/third_party/externals/libwebp/src")
+-  else()
+-    set(WEBP_LIBRARIES webp webpdemux libwebpmux)
+-    set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)
+   endif()
+   include_directories(${WEBP_INCLUDE_DIR})
  endif()
- 
- # tinyxml
 diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
 index 4839d4097c..e8c3e83cbc 100644
 --- a/third_party/CMakeLists.txt
@@ -51,8 +53,8 @@ index 4839d4097c..e8c3e83cbc 100644
    add_subdirectory(giflib)
  endif()
  
--if(ENABLE_WEBP)
-+if(ENABLE_WEBP AND NOT USE_SHARED_WEBP)
+-if(ENABLE_WEBP AND NOT LAF_BACKEND STREQUAL "skia")
++if(ENABLE_WEBP AND NOT LAF_BACKEND STREQUAL "skia" AND NOT USE_SHARED_WEBP)
    set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "Build extras.")
    add_subdirectory(libwebp)
  endif()

From ae2bd412dc832826daaa00b2a6b95fe9af7d9084 Mon Sep 17 00:00:00 2001
From: ImperatorStorm <imperatorstorm11@protonmail.com>
Date: Fri, 5 Aug 2022 20:40:23 -0700
Subject: [PATCH 2/2] Fix patch again

---
 .SRCINFO             | 2 +-
 PKGBUILD             | 2 +-
 shared-libwebp.patch | 1 +
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/.SRCINFO b/.SRCINFO
index cd7f8ae..090b8f0 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -46,7 +46,7 @@ pkgbase = aseprite
 	sha256sums = 8b14e36939e930de581e95abf0591645aa0fcfd47161cf88b062917dbaaef7f9
 	sha256sums = 821f1354dbbc0bb3fa700e63037ed3c89b0d32bd2ab253450f91eeacd7d47c06
 	sha256sums = d7f2f8c43d24382453273ed17b1c0e05928980a36ad0b7c988da3aa0fe32de53
-	sha256sums = 19352033f2e5787229b2b71f7e961aeb24f293fb0b188a774140a7830f2b344b
+	sha256sums = 6c52f390d486bbd4bd3b7b0c1b835861335c5d9ef4a244f96054e026ad9eabac
 	sha256sums = eb9f544e68b41b5cb1a9ab7a6648db51587e67e94f1a452cb5a84f3d224bf5d0
 	sha256sums = c2d14f9738a96a9db3695c00ac3d14b1312b6a595b151bd56e19422c86517654
 
diff --git a/PKGBUILD b/PKGBUILD
index 78642cf..a873914 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -56,7 +56,7 @@ sha256sums=('b84e67061a9600c6c508af26944851ce277f4e912bf73d8e9e83a2eba5510c21'
             '8b14e36939e930de581e95abf0591645aa0fcfd47161cf88b062917dbaaef7f9'
             '821f1354dbbc0bb3fa700e63037ed3c89b0d32bd2ab253450f91eeacd7d47c06'
             'd7f2f8c43d24382453273ed17b1c0e05928980a36ad0b7c988da3aa0fe32de53'
-            '19352033f2e5787229b2b71f7e961aeb24f293fb0b188a774140a7830f2b344b'
+            '6c52f390d486bbd4bd3b7b0c1b835861335c5d9ef4a244f96054e026ad9eabac'
             'eb9f544e68b41b5cb1a9ab7a6648db51587e67e94f1a452cb5a84f3d224bf5d0'
             'c2d14f9738a96a9db3695c00ac3d14b1312b6a595b151bd56e19422c86517654')
 
diff --git a/shared-libwebp.patch b/shared-libwebp.patch
index e0d992a..c4c5219 100644
--- a/shared-libwebp.patch
+++ b/shared-libwebp.patch
@@ -39,6 +39,7 @@ index af077f6..fed17ff 100644
        NAMES libwebp # required for Windows
        PATHS "${SKIA_LIBRARY_DIR}" NO_DEFAULT_PATH)
      set(WEBP_INCLUDE_DIR "${SKIA_DIR}/third_party/externals/libwebp/src")
++    endif() 
 -  else()
 -    set(WEBP_LIBRARIES webp webpdemux libwebpmux)
 -    set(WEBP_INCLUDE_DIR ${LIBWEBP_DIR}/src)