unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: gemmaro <gemmaro.dev@gmail.com>
To: 64983@debbugs.gnu.org
Cc: gemmaro <gemmaro.dev@gmail.com>
Subject: [bug#64983] [PATCH v2 3/4] gnu: highlight: Add gui output.
Date: Mon,  7 Aug 2023 23:05:41 +0900	[thread overview]
Message-ID: <86cfa707151d8ed32b9acaff3894c182747b8e3f.1691417142.git.gemmaro.dev@gmail.com> (raw)
In-Reply-To: <cover.1691417142.git.gemmaro.dev@gmail.com>

* gnu/packages/pretty-print.scm (highlight): Add gui output.
[source]: Add patch for GUI data directory.
[outputs]: Add gui.
[arguments]<phases>{fix-search-for-lua}: Fix Lua package name for GUI.
{build-gui}: Add phase to build GUI.
{install}: Set PREFIX variable.
{install-gui}: Add phase to install GUI.
[inputs]: Add qtbase-5.
* gnu/packages/patches/highlight-gui-data-dir.patch: Add patch for GUI data directory.
---
 .../patches/highlight-gui-data-dir.patch      | 51 ++++++++++++++
 gnu/packages/pretty-print.scm                 | 66 ++++++++++++++-----
 2 files changed, 102 insertions(+), 15 deletions(-)
 create mode 100644 gnu/packages/patches/highlight-gui-data-dir.patch

diff --git a/gnu/packages/patches/highlight-gui-data-dir.patch b/gnu/packages/patches/highlight-gui-data-dir.patch
new file mode 100644
index 0000000000..33f40d309c
--- /dev/null
+++ b/gnu/packages/patches/highlight-gui-data-dir.patch
@@ -0,0 +1,51 @@
+This patch distinguishes between the data directory path for GUI and the one
+for non-GUI by allowing to set the former path.
+
+highlight package has two outputs: out and gui.  Both outputs have files which
+will be in the same directory /share/highlight/ without this patch (see also
+install and install-gui tasks in makefile).  In the gui's data directory,
+there are GUI specific files in /share/highlight/gui-files/{l10n,ext}/.
+
+diff --git a/src/gui-qt/main.cpp b/src/gui-qt/main.cpp
+index 4700dc1..3567745 100644
+--- a/src/gui-qt/main.cpp
++++ b/src/gui-qt/main.cpp
+@@ -47,8 +47,8 @@ int main(int argc, char *argv[])
+ {
+     QApplication app(argc, argv);
+     QTranslator translator;
+-#ifdef DATA_DIR
+-    translator.load(QString("%1/gui_files/l10n/highlight_%2").arg(DATA_DIR).arg(QLocale::system().name()));
++#ifdef GUI_DATA_DIR
++    translator.load(QString("%1/gui_files/l10n/highlight_%2").arg(GUI_DATA_DIR).arg(QLocale::system().name()));
+ #else
+     translator.load(QString("%1/gui_files/l10n/highlight_%2").arg(QDir::currentPath()).arg(QLocale::system().name()));
+ #endif
+diff --git a/src/gui-qt/mainwindow.cpp b/src/gui-qt/mainwindow.cpp
+index 3a21ad2..f060431 100644
+--- a/src/gui-qt/mainwindow.cpp
++++ b/src/gui-qt/mainwindow.cpp
+@@ -2131,8 +2131,8 @@ QString MainWindow::getDistFileFilterPath(){
+ #ifdef Q_OS_OSX
+     return QCoreApplication::applicationDirPath()+"/../Resources/gui_files/ext/fileopenfilter.conf";
+ #else
+-    #ifdef DATA_DIR
+-    return QString(DATA_DIR) + "/gui_files/ext/fileopenfilter.conf";
++    #ifdef GUI_DATA_DIR
++    return QString(GUI_DATA_DIR) + "/gui_files/ext/fileopenfilter.conf";
+     #else
+     return QDir::currentPath()+"/gui_files/ext/fileopenfilter.conf";
+     #endif
+diff --git a/src/makefile b/src/makefile
+index b1d7988..2963105 100644
+--- a/src/makefile
++++ b/src/makefile
+@@ -118,7 +118,7 @@ gui-qt: highlight-gui
+ 
+ highlight-gui: libhighlight.a ${GUI_OBJECTS}
+ 	cd gui-qt && \
+-	${QMAKE} 'DEFINES+=DATA_DIR=\\\"${HL_DATA_DIR}\\\" CONFIG_DIR=\\\"${HL_CONFIG_DIR}\\\" DOC_DIR=\\\"${HL_DOC_DIR}\\\" ' && \
++	${QMAKE} 'DEFINES+=DATA_DIR=\\\"${HL_DATA_DIR}\\\" CONFIG_DIR=\\\"${HL_CONFIG_DIR}\\\" DOC_DIR=\\\"${HL_DOC_DIR}\\\" GUI_DATA_DIR=\\\"${GUI_DATA_DIR}\\\" ' && \
+ 	$(MAKE)
+ 
+ $(OBJECTFILES) : makefile
diff --git a/gnu/packages/pretty-print.scm b/gnu/packages/pretty-print.scm
index 1b2cf4becf..f8763b7b74 100644
--- a/gnu/packages/pretty-print.scm
+++ b/gnu/packages/pretty-print.scm
@@ -52,7 +52,8 @@ (define-module (gnu packages pretty-print)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
-  #:use-module (gnu packages swig))
+  #:use-module (gnu packages swig)
+  #:use-module (gnu packages qt))
 
 (define-public a2ps
   (package
@@ -352,13 +353,15 @@ (define-public highlight
   (package
     (name "highlight")
     (version "4.7")
+    (outputs (list "out" "gui"))
     (source (origin
               (method url-fetch)
               (uri (string-append "http://www.andre-simon.de/zip/highlight-"
                                   version ".tar.bz2"))
               (sha256
                (base32
-                "1cl21qpgy92w1x53vrn1bgq84mkh6fgayc9k38mz4xmz2yw01nv1"))))
+                "1cl21qpgy92w1x53vrn1bgq84mkh6fgayc9k38mz4xmz2yw01nv1"))
+              (patches (search-patches "highlight-gui-data-dir.patch"))))
     (build-system gnu-build-system)
     (arguments
      (list #:tests? #f ;no tests
@@ -371,17 +374,44 @@ (define-public highlight
                         (delete 'configure) ;no configure script
                         (add-after 'unpack 'fix-search-for-lua
                           (lambda _
-                            (substitute* "src/makefile"
-                              (("(LUA_PKG_NAME=).*" _ assignment)
-                               (string-append assignment "lua-"
-                                              #$(version-major+minor (package-version
-                                                                      lua))
-                                              "\n")))
-                            (substitute* "extras/swig/makefile"
-                              (("lua")
-                               (string-append "lua-"
-                                              #$(version-major+minor (package-version
-                                                                      lua)))))))
+                            (let ((ver #$(version-major+minor (package-version
+                                                               lua))))
+                              (substitute* "src/makefile"
+                                (("(LUA_PKG_NAME=).*" _ assignment)
+                                 (string-append assignment "lua-" ver "\n")))
+                              (substitute* "src/gui-qt/highlight.pro"
+                                (("(PKGCONFIG \\+= lua)" _ assignment)
+                                 (string-append assignment "-" ver)))
+                              (substitute* "extras/swig/makefile"
+                                (("lua")
+                                 (string-append "lua-" ver))))))
+                        (add-after 'build 'build-gui
+                          (lambda* (#:key inputs outputs #:allow-other-keys)
+                            (let* ((out (assoc-ref outputs "out"))
+                                   (data (string-append out
+                                                        "/share/highlight/"))
+                                   (conf (string-append out "/etc/highlight/"))
+                                   (doc (string-append out
+                                         "/share/doc/highlight/"))
+                                   (gui (assoc-ref outputs "gui"))
+                                   (gui-data (string-append gui
+                                              "/share/highlight/")))
+                              ;; modified version of gui task in makefile
+                              (invoke "make"
+                                      "-C"
+                                      "./src"
+                                      "-f"
+                                      "./makefile"
+                                      (string-append "HL_DATA_DIR=" data)
+                                      (string-append "HL_CONFIG_DIR=" conf)
+                                      (string-append "HL_DOC_DIR=" doc)
+                                      (string-append "GUI_DATA_DIR=" gui-data)
+                                      "gui-qt"))))
+                        (replace 'install
+                          (lambda* (#:key outputs #:allow-other-keys)
+                            (let ((out (assoc-ref outputs "out")))
+                              (invoke "make" "install"
+                                      (string-append "PREFIX=" out)))))
                         (add-after 'install 'install-perl-bindings
                           (lambda* (#:key outputs #:allow-other-keys)
                             (let* ((perldir (string-append (assoc-ref outputs
@@ -394,8 +424,14 @@ (define-public highlight
                                 (invoke "make" "perl")
                                 (invoke "perl" "-I" "." "testmod.pl")
                                 (install-file "highlight.pm" perldir)
-                                (install-file "highlight.so" autodir))))))))
-    (inputs (list lua boost perl))
+                                (install-file "highlight.so" autodir)))))
+                        (add-after 'install 'install-gui
+                          (lambda* (#:key outputs #:allow-other-keys)
+                            (let ((gui (assoc-ref outputs "gui")))
+                              (mkdir-p (string-append gui "/bin"))
+                              (invoke "make" "install-gui"
+                                      (string-append "PREFIX=" gui))))))))
+    (inputs (list lua boost perl qtbase-5))
     (native-inputs (list pkg-config swig))
     (home-page "http://www.andre-simon.de/doku/highlight/en/highlight.php")
     (synopsis "Convert code to documents with syntax highlighting")
-- 
2.41.0





  parent reply	other threads:[~2023-08-07 14:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31 23:43 [bug#64983] [PATCH 0/3] gnu: highlight: Update to 4.7 and add GUI package gemmaro
2023-07-31 23:45 ` [bug#64983] [PATCH 1/3] gnu: highlight: Update to 4.7 gemmaro
2023-07-31 23:45 ` [bug#64983] [PATCH 2/3] gnu: highlight: Use new package style gemmaro
2023-07-31 23:45 ` [bug#64983] [PATCH 3/3] gnu: Add highlight-gui gemmaro
2023-08-04  0:42   ` gemmaro
2023-08-07 14:05 ` [bug#64983] [PATCH v2 0/4] gnu: highlight: Add gui output gemmaro
2023-08-07 14:05   ` [bug#64983] [PATCH v2 1/4] gnu: highlight: Update to 4.7 gemmaro
2023-08-07 14:05   ` [bug#64983] [PATCH v2 2/4] gnu: highlight: Use new package style gemmaro
2023-08-07 14:05   ` gemmaro [this message]
2023-08-07 14:05   ` [bug#64983] [PATCH v2 4/4] gnu: highlight: Fix paths for Perl bindings gemmaro
2023-08-14 22:26   ` bug#64983: [PATCH 0/3] gnu: highlight: Update to 4.7 and add GUI package Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86cfa707151d8ed32b9acaff3894c182747b8e3f.1691417142.git.gemmaro.dev@gmail.com \
    --to=gemmaro.dev@gmail.com \
    --cc=64983@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).