unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#60939] [PATCH] Add skia-for-libreoffice.
@ 2023-01-18 18:24 Nicolas Graves via Guix-patches via
  2023-01-18 18:34 ` [bug#60939] [PATCH 1/2] gnu: " Nicolas Graves via Guix-patches via
  2023-01-18 21:27 ` [bug#60939] [PATCH v2 1/2] gnu: Add skia-for-libreoffice Nicolas Graves via Guix-patches via
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2023-01-18 18:24 UTC (permalink / raw)
  To: 60939; +Cc: efraim


Hi!

Here is a patch series enabling the skia 2D graphics library for
libreoffice.

It should improve performance of libreoffice, but adds no new
functionality. I will test it in a real environment from now on.

The implementation can be reworked. In particular :
- skia is built by keeping the libreoffice source, adding the skia
tarball, building skia only, and exporting the libraries.
- it builds fine, but relies on many arguments from libreoffice, which
probably implies a rebuild each time libreoffice is updated (while it is
not a strict need, since the skia tarball is not updated for each new
libreoffice version).
- but separating both arguments fields by copying them is fine, but it
  will lead to a lot of duplicated code.


-- 
Best regards,
Nicolas Graves




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#60939] [PATCH 1/2] gnu: Add skia-for-libreoffice.
  2023-01-18 18:24 [bug#60939] [PATCH] Add skia-for-libreoffice Nicolas Graves via Guix-patches via
@ 2023-01-18 18:34 ` Nicolas Graves via Guix-patches via
  2023-01-18 18:35   ` [bug#60939] [PATCH 2/2] gnu: libreoffice: Enable build with skia Nicolas Graves via Guix-patches via
  2023-01-18 21:27 ` [bug#60939] [PATCH v2 1/2] gnu: Add skia-for-libreoffice Nicolas Graves via Guix-patches via
  1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2023-01-18 18:34 UTC (permalink / raw)
  To: 60939; +Cc: ngraves

* gnu/packages/libreoffice.scm (skia-for-libreoffice): New variable.
---
 gnu/packages/libreoffice.scm | 76 ++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index b959470d8f..36d7bc0c66 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,78 @@ (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
+    (name "skia-for-libreoffice")
+    (version (package-version libreoffice))
+    (source
+     (origin
+       (method url-fetch)
+       (uri
+        (string-append
+         "https://download.documentfoundation.org/libreoffice/src/"
+         (version-prefix version 3) "/libreoffice-" version ".tar.xz"))
+       (sha256
+        (base32 "0fyvd4ydh72lmn005h190xa563d4h376pi1fx9lfr5i25qcbpg7z"))))
+    (build-system (package-build-system 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)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#60939] [PATCH 2/2] gnu: libreoffice: Enable build with skia.
  2023-01-18 18:34 ` [bug#60939] [PATCH 1/2] gnu: " Nicolas Graves via Guix-patches via
@ 2023-01-18 18:35   ` Nicolas Graves via Guix-patches via
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2023-01-18 18:35 UTC (permalink / raw)
  To: 60939; +Cc: ngraves

* 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 <ngraves@ngraves.fr>
+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





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#60939] [PATCH v2 1/2] gnu: Add skia-for-libreoffice.
  2023-01-18 18:24 [bug#60939] [PATCH] Add skia-for-libreoffice Nicolas Graves via Guix-patches via
  2023-01-18 18:34 ` [bug#60939] [PATCH 1/2] gnu: " Nicolas Graves via Guix-patches via
@ 2023-01-18 21:27 ` Nicolas Graves via Guix-patches via
  2023-01-18 21:27   ` [bug#60939] [PATCH v2 2/2] gnu: libreoffice: Enable build with skia Nicolas Graves via Guix-patches via
  1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2023-01-18 21:27 UTC (permalink / raw)
  To: 60939; +Cc: ngraves

* gnu/packages/libreoffice.scm (skia-for-libreoffice): New variable.
---
 gnu/packages/libreoffice.scm | 66 ++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)

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)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#60939] [PATCH v2 2/2] gnu: libreoffice: Enable build with skia.
  2023-01-18 21:27 ` [bug#60939] [PATCH v2 1/2] gnu: Add skia-for-libreoffice Nicolas Graves via Guix-patches via
@ 2023-01-18 21:27   ` Nicolas Graves via Guix-patches via
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Graves via Guix-patches via @ 2023-01-18 21:27 UTC (permalink / raw)
  To: 60939; +Cc: ngraves

* gnu/packages/libreoffice.scm (libreoffice): Enable build with skia.
---
 gnu/packages/libreoffice.scm | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index 372b18a24f..72cd17fa09 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -970,6 +970,34 @@ (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"
+                  ;; Delete options that trigger skia build.
+                  (("-DSK_USER_CONFIG_HEADER=\"<\\$\\(BUILDDIR\\)\\/config_host\\/config_skia\\.h>\"")
+                   "")
+                  (("-DSKIA_DLL")
+                   "")
+                  ;; 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 +1070,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 +1165,7 @@ (define (install-appdata app)
            qrcodegen-cpp
            redland
            sane-backends
+           skia-for-libreoffice
            unixodbc
            unzip
            vigra
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-18 21:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 18:24 [bug#60939] [PATCH] Add skia-for-libreoffice Nicolas Graves via Guix-patches via
2023-01-18 18:34 ` [bug#60939] [PATCH 1/2] gnu: " Nicolas Graves via Guix-patches via
2023-01-18 18:35   ` [bug#60939] [PATCH 2/2] gnu: libreoffice: Enable build with skia Nicolas Graves via Guix-patches via
2023-01-18 21:27 ` [bug#60939] [PATCH v2 1/2] gnu: Add skia-for-libreoffice Nicolas Graves via Guix-patches via
2023-01-18 21:27   ` [bug#60939] [PATCH v2 2/2] gnu: libreoffice: Enable build with skia Nicolas Graves via Guix-patches via

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).