Subject: [PATCH 2/2] gnu: libreoffice: Enable build with skia.

From: Nicolas Graves <[email-masked]>
Date: Wed, 18 Jan 2023 19:35:00 +0100

* gnu/packages/libreoffice.scm (libreoffice): Enable build with skia.
* gnu/packages/patches/skia-libreoffice.patch
---
 gnu/packages/libreoffice.scm                | 28 +++++++++++++++++++--
 gnu/packages/patches/skia-libreoffice.patch | 27 ++++++++++++++++++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/skia-libreoffice.patch

diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index 36d7bc0c66..d92529d8b5 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -925,7 +925,8 @@ (define-public libreoffice
          "https://download.documentfoundation.org/libreoffice/src/"
          (version-prefix version 3) "/libreoffice-" version ".tar.xz"))
        (sha256
-        (base32 "0fyvd4ydh72lmn005h190xa563d4h376pi1fx9lfr5i25qcbpg7z"))))
+        (base32 "0fyvd4ydh72lmn005h190xa563d4h376pi1fx9lfr5i25qcbpg7z"))
+       (patches (search-patches "skia-libreoffice.patch"))))
     (build-system glib-or-gtk-build-system)
     (arguments
      (list
@@ -970,6 +971,29 @@ (define-public libreoffice
                 (("/usr/bin/xdg-open")
                  (search-input-file inputs "/bin/xdg-open")))
               (setenv "CPPFLAGS" "-std=c++17")))
+          (add-before 'configure 'include-built-skia
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let* ((incdir (search-input-directory inputs "include/skia/"))
+                     (outdir (string-drop-right
+                              incdir
+                              (string-length "include/skia/")))
+                     (libdir (string-append outdir "lib")))
+                (substitute* "RepositoryExternal.mk"
+                  ;; Include skia .h files.
+                  (("\\$\\(call gb_UnpackedTarball_get_dir,skia\\)")
+                   incdir)
+                  ;; Use skia as an external library.
+                  (("\\$\\(call gb_LinkTarget_use_libraries,\\$\\(1\\),skia\\)")
+                   (string-append "$(call gb_LinkTarget_add_libs,$(1),"
+                                  "-L" libdir " -lskialo)")))
+                ;; Delete skia library unpack and build steps.
+                (substitute* "external/skia/Module_skia.mk"
+                  (("UnpackedTarball_skia") "")
+                  (("Library_skia") ""))
+                ;; Symlink the library (used in make install).
+                (mkdir-p "instdir/program")
+                (symlink (search-input-file inputs "lib/libskialo.so")
+                         "instdir/program/libskialo.so"))))
           (add-after 'install 'reset-zip-timestamps
             (lambda _
               (for-each (lambda (file)
@@ -1042,7 +1066,6 @@ (define (install-appdata app)
          "--without-java"
          ;; FIXME: Enable once the corresponding inputs are packaged.
          "--disable-coinmp"
-         "--disable-skia"
          ;; This could (Debian does this) be a separate output containing only
          ;; program/libfirebird_sdbclo.so, if there's a way to point to it.
          "--enable-firebird-sdbc"
@@ -1138,6 +1161,7 @@ (define (install-appdata app)
            qrcodegen-cpp
            redland
            sane-backends
+           skia-for-libreoffice
            unixodbc
            unzip
            vigra
diff --git a/gnu/packages/patches/skia-libreoffice.patch b/gnu/packages/patches/skia-libreoffice.patch
new file mode 100644
index 0000000000..1818b8f5d8
--- /dev/null
+++ b/gnu/packages/patches/skia-libreoffice.patch
@@ -0,0 +1,27 @@
+From ea381d2468523a1e7b78a0bcf10cf5af0484bd5b Mon Sep 17 00:00:00 2001
+From: Nicolas Graves <[email-masked]>
+Date: Tue, 17 Jan 2023 10:49:56 +0100
+Subject: [PATCH] RepositoryExternal: delete build of skia.
+
+---
+ RepositoryExternal.mk | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
+index ccc92790341e..6f2ea1599f12 100644
+--- a/RepositoryExternal.mk
++++ b/RepositoryExternal.mk
+@@ -136,10 +136,6 @@ $(call gb_LinkTarget_set_include,$(1),\
+ 	$$(INCLUDE) \
+ )
+ $(call gb_LinkTarget_use_libraries,$(1),skia)
+-$(call gb_LinkTarget_add_defs,$(1),\
+-	-DSK_USER_CONFIG_HEADER="<$(BUILDDIR)/config_host/config_skia.h>" \
+-	-DSKIA_DLL \
+-)
+ endef
+ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo,\
+         skia \
+-- 
+2.38.1
+
-- 
2.38.1