diff mbox series

[bug#60939,v2,1/2] gnu: Add skia-for-libreoffice.

Message ID 20230118212735.27131-1-ngraves@ngraves.fr
State New
Headers show
Series [bug#60939,v2,1/2] gnu: Add skia-for-libreoffice. | expand

Commit Message

Nicolas Graves Jan. 18, 2023, 9:27 p.m. UTC
* gnu/packages/libreoffice.scm (skia-for-libreoffice): New variable.
---
 gnu/packages/libreoffice.scm | 66 ++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index b959470d8f..372b18a24f 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -75,6 +75,7 @@  (define-module (gnu packages libreoffice)
   #:use-module (gnu packages image)
   #:use-module (gnu packages java)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
   #:use-module (gnu packages logging)
   #:use-module (gnu packages m4)
   #:use-module (gnu packages maths)
@@ -1155,3 +1156,68 @@  (define (install-appdata app)
      '((release-monitoring-url
         . "https://www.libreoffice.org/download/download-libreoffice/")))
     (license license:mpl2.0)))
+
+(define skia-tarball
+  (origin
+    (method url-fetch)
+    (uri "https://dev-www.libreoffice.org/src/skia-m103-b301ff025004c9cd82816c86c547588e6c24b466.tar.xz")
+    (sha256
+     (base32 "1navlqbm6ja78whj5p1jwnlg3fmnpqjwh00dmbm4n424gqjad560"))))
+
+(define-public skia-for-libreoffice
+  (package
+    (inherit libreoffice)
+    (name "skia-for-libreoffice")
+    (arguments
+     (substitute-keyword-arguments (package-arguments libreoffice)
+       ((#:phases phases '%standard-phases)
+        #~(modify-phases #$phases
+            (delete 'include-built-skia)
+            (delete 'bin-and-desktop-install)
+            (add-after 'insert-external-tarballs 'insert-skia-tarball
+              (lambda _
+                (copy-file
+                 #$skia-tarball
+                 (string-append
+                  "external/tarballs/"
+                  "skia-m103-b301ff025004c9cd82816c86c547588e6c24b466.tar.xz"))))
+            (replace 'build
+              (lambda _ (invoke "make" "Library_skia")))
+            (replace 'install
+              (lambda _
+                (with-directory-excursion "instdir/program"
+                  (for-each
+                   (lambda (lib)
+                     (install-file lib (string-append #$output "/lib")))
+                   (find-files "." "\\.so$")))
+                (define* (install-header header)
+                  (let* ((inc (string-append #$output "/include/"))
+                         (ridx (string-rindex header #\/))
+                         (dir (string-append inc (string-take header ridx))))
+                    (install-file header dir)))
+                (with-directory-excursion "workdir/UnpackedTarball"
+                  (for-each install-header (find-files "skia" "\\.h")))))))
+       ((#:configure-flags flags)
+        ;; Else needs llvm gold linker.
+        `(delete "--enable-lto" ,flags))
+       ((#:validate-runpath? _ #f) #f)))
+    (native-inputs (modify-inputs
+                       (append (package-native-inputs libreoffice)
+                               ;; here because of configure step
+                               (package-inputs libreoffice))
+                     (prepend clang-11)
+                     ;; Avoid circular dependency.
+                     (delete "skia-for-libreoffice")))
+    (inputs (list expat fontconfig freetype harfbuzz mesa libwebp zlib))
+    (home-page "https://skia.org/")
+    (synopsis "2D graphics library")
+    (description
+     "Skia is a 2D graphics library for drawing text, geometries, and images.
+It supports:
+@itemize
+@item 3x3 matrices with perspective
+@item antialiasing, transparency, filters
+@item shaders, xfermodes, maskfilters, patheffects
+@item subpixel text
+@end itemize")
+    (license license:bsd-3)))