* [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system.
2019-11-30 21:59 [bug#38440] [PATCH 0/5] Add the `qt` build-system Hartmut Goebel
@ 2019-11-30 22:00 ` Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 2/5] gnu: sddm: Use qt-build-system Hartmut Goebel
` (3 more replies)
2019-11-30 22:15 ` [bug#38440] [PATCH 0/5] Add the `qt` build-system Brett Gilio
2019-11-30 22:17 ` [bug#38440] [PATCH v2] guix: Add the 'qt' build system Hartmut Goebel
2 siblings, 4 replies; 9+ messages in thread
From: Hartmut Goebel @ 2019-11-30 22:00 UTC (permalink / raw)
To: 38440
* guix/build-system/qt.scm, guix/build/qt-build-system.scm: New files.
* Makefile.am (MODULES): Add them.
* doc/guix.texi (Buiild systems): Add the new build system.
---
Makefile.am | 2 +
doc/guix.texi | 21 ++-
guix/build-system/qt.scm | 295 +++++++++++++++++++++++++++++++++
guix/build/qt-build-system.scm | 109 ++++++++++++
4 files changed, 426 insertions(+), 1 deletion(-)
create mode 100644 guix/build-system/qt.scm
create mode 100644 guix/build/qt-build-system.scm
diff --git a/Makefile.am b/Makefile.am
index b3f03d44c8..97f1ff514b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -132,6 +132,7 @@ MODULES = \
guix/build-system/perl.scm \
guix/build-system/python.scm \
guix/build-system/ocaml.scm \
+ guix/build-system/qt.scm \
guix/build-system/waf.scm \
guix/build-system/r.scm \
guix/build-system/rakudo.scm \
@@ -178,6 +179,7 @@ MODULES = \
guix/build/perl-build-system.scm \
guix/build/python-build-system.scm \
guix/build/ocaml-build-system.scm \
+ guix/build/qt-build-system.scm \
guix/build/r-build-system.scm \
guix/build/rakudo-build-system.scm \
guix/build/ruby-build-system.scm \
diff --git a/doc/guix.texi b/doc/guix.texi
index 23a30ce553..cf1d38afc9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -47,7 +47,7 @@ Copyright @copyright{} 2017 Thomas Danckaert@*
Copyright @copyright{} 2017 humanitiesNerd@*
Copyright @copyright{} 2017 Christopher Allan Webber@*
Copyright @copyright{} 2017, 2018 Marius Bakke@*
-Copyright @copyright{} 2017 Hartmut Goebel@*
+Copyright @copyright{} 2017, 2019 Hartmut Goebel@*
Copyright @copyright{} 2017, 2019 Maxim Cournoyer@*
Copyright @copyright{} 2017, 2018, 2019 Tobias Geerinckx-Rice@*
Copyright @copyright{} 2017 George Clemmer@*
@@ -6408,6 +6408,25 @@ passes flags specified by the @code{#:make-maker-flags} or
Which Perl package is used can be specified with @code{#:perl}.
@end defvr
+@defvr {Scheme Variable} qt-build-system
+This variable is exported by @code{(guix build-system qt)}. It
+is intended for use with applications using Qt or KDE.
+
+This build system adds the phase @code{qt-wrap} to the ones defined by
+@var{cmake-build-system}, after the @code{install} phase.
+
+This phase searches for Qt5 plugin paths, QML paths and some XDG in the inputs
+and output. In case some path is found, all programs in the output's
+@file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
+are wrapped in scripts defining the necessary environment variables.
+
+It is possible to exclude specific package outputs from that wrapping process
+by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
+This is useful when an output is known not to contain any Qt binaries, and
+where wrapping would gratuitously add a dependency of that output on Qt, KDE,
+or such.
+@end defvr
+
@defvr {Scheme Variable} r-build-system
This variable is exported by @code{(guix build-system r)}. It
implements the build procedure used by @uref{https://r-project.org, R}
diff --git a/guix/build-system/qt.scm b/guix/build-system/qt.scm
new file mode 100644
index 0000000000..5ce4e91c41
--- /dev/null
+++ b/guix/build-system/qt.scm
@@ -0,0 +1,295 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
+;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system qt)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system cmake)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (%qt-build-system-modules
+ qt-build
+ qt-build-system))
+
+;; Commentary:
+;;
+;; This build system is an extension of the 'cmake-build-system'. It
+;; accommodates the needs of Qt and KDE applications by adding a phase run
+;; after the 'install' phase:
+;;
+;; 'qt-wrap' phase:
+;;
+;; This phase looks for Qt5 plugin paths, QML paths and some XDG paths as well
+;; as the corresponding environment variables. If any of these is found in
+;; the output or if respective environment variables are set, then all
+;; programs in the output's "bin", "sbin", "libexec and "lib/libexec"
+;; directories are wrapped in scripts defining the necessary environment
+;; variables.
+;;
+;; Code:
+
+(define %qt-build-system-modules
+ ;; Build-side modules imported and used by default.
+ `((guix build qt-build-system)
+ ,@%cmake-build-system-modules))
+
+(define (default-cmake)
+ "Return the default CMake package."
+
+ ;; Do not use `@' to avoid introducing circular dependencies.
+ (let ((module (resolve-interface '(gnu packages cmake))))
+ (module-ref module 'cmake-minimal)))
+
+;; This barely is a copy from (guix build-system cmake), only adjusted to use
+;; the variables defined here.
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ (cmake (default-cmake))
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ `(#:source #:cmake #:inputs #:native-inputs #:outputs
+ ,@(if target '() '(#:target))))
+
+ (bag
+ (name name)
+ (system system)
+ (target target)
+ (build-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@`(("cmake" ,cmake))
+ ,@native-inputs
+ ,@(if target
+ ;; Use the standard cross inputs of
+ ;; 'gnu-build-system'.
+ (standard-cross-packages target 'host)
+ '())
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ ,@(standard-packages)))
+ (host-inputs inputs)
+
+ ;; The cross-libc is really a target package, but for bootstrapping
+ ;; reasons, we can't put it in 'host-inputs'. Namely, 'cross-gcc' is a
+ ;; native package, so it would end up using a "native" variant of
+ ;; 'cross-libc' (built with 'gnu-build'), whereas all the other packages
+ ;; would use a target variant (built with 'gnu-cross-build'.)
+ (target-inputs (if target
+ (standard-cross-packages target 'target)
+ '()))
+ (outputs outputs)
+ (build (if target qt-cross-build qt-build))
+ (arguments (strip-keyword-arguments private-keywords arguments))))
+
+
+(define* (qt-build store name inputs
+ #:key (guile #f)
+ (outputs '("out")) (configure-flags ''())
+ (search-paths '())
+ (make-flags ''())
+ (out-of-source? #t)
+ (build-type "RelWithDebInfo")
+ (tests? #t)
+ (test-target "test")
+ (parallel-build? #t) (parallel-tests? #f)
+ (validate-runpath? #t)
+ (patch-shebangs? #t)
+ (strip-binaries? #t)
+ (strip-flags ''("--strip-debug"))
+ (strip-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (phases '(@ (guix build qt-build-system)
+ %qt-standard-phases))
+ (qt-wrap-excluded-outputs ''())
+ (system (%current-system))
+ (imported-modules %qt-build-system-modules)
+ (modules '((guix build cmake-build-system)
+ (guix build utils))))
+ "Build SOURCE using CMAKE, and with INPUTS. This assumes that SOURCE
+provides a 'CMakeLists.txt' file as its build system."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (cmake-build #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:outputs %outputs
+ #:inputs %build-inputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:phases ,phases
+ #:qt-wrap-excluded-outputs ,qt-wrap-excluded-outputs
+ #:configure-flags ,configure-flags
+ #:make-flags ,make-flags
+ #:out-of-source? ,out-of-source?
+ #:build-type ,build-type
+ #:tests? ,tests?
+ #:test-target ,test-target
+ #:parallel-build? ,parallel-build?
+ #:parallel-tests? ,parallel-tests?
+ #:validate-runpath? ,validate-runpath?
+ #:patch-shebangs? ,patch-shebangs?
+ #:strip-binaries? ,strip-binaries?
+ #:strip-flags ,strip-flags
+ #:strip-directories ,strip-directories)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs inputs
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+\f
+;;;
+;;; Cross-compilation.
+;;;
+
+(define* (qt-cross-build store name
+ #:key
+ target native-drvs target-drvs
+ (guile #f)
+ (outputs '("out"))
+ (configure-flags ''())
+ (search-paths '())
+ (native-search-paths '())
+ (make-flags ''())
+ (out-of-source? #t)
+ (build-type "RelWithDebInfo")
+ (tests? #f) ; nothing can be done
+ (test-target "test")
+ (parallel-build? #t) (parallel-tests? #f)
+ (validate-runpath? #t)
+ (patch-shebangs? #t)
+ (strip-binaries? #t)
+ (strip-flags ''("--strip-debug"
+ "--enable-deterministic-archives"))
+ (strip-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (phases '(@ (guix build qt-build-system)
+ %qt-standard-phases))
+ (system (%current-system))
+ (build (nix-system->gnu-triplet system))
+ (imported-modules %qt-build-system-modules)
+ (modules '((guix build cmake-build-system)
+ (guix build utils))))
+ "Cross-build NAME using CMAKE for TARGET, where TARGET is a GNU triplet and
+with INPUTS. This assumes that SOURCE provides a 'CMakeLists.txt' file as its
+build system."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (let ()
+ (define %build-host-inputs
+ ',(map (match-lambda
+ ((name (? derivation? drv) sub ...)
+ `(,name . ,(apply derivation->output-path drv sub)))
+ ((name path)
+ `(,name . ,path)))
+ native-drvs))
+
+ (define %build-target-inputs
+ ',(map (match-lambda
+ ((name (? derivation? drv) sub ...)
+ `(,name . ,(apply derivation->output-path drv sub)))
+ ((name (? package? pkg) sub ...)
+ (let ((drv (package-cross-derivation store pkg
+ target system)))
+ `(,name . ,(apply derivation->output-path drv sub))))
+ ((name path)
+ `(,name . ,path)))
+ target-drvs))
+
+ (cmake-build #:source ,(match (assoc-ref native-drvs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:build ,build
+ #:target ,target
+ #:outputs %outputs
+ #:inputs %build-target-inputs
+ #:native-inputs %build-host-inputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:native-search-paths ',(map
+ search-path-specification->sexp
+ native-search-paths)
+ #:phases ,phases
+ #:configure-flags ,configure-flags
+ #:make-flags ,make-flags
+ #:out-of-source? ,out-of-source?
+ #:build-type ,build-type
+ #:tests? ,tests?
+ #:test-target ,test-target
+ #:parallel-build? ,parallel-build?
+ #:parallel-tests? ,parallel-tests?
+ #:validate-runpath? ,validate-runpath?
+ #:patch-shebangs? ,patch-shebangs?
+ #:strip-binaries? ,strip-binaries?
+ #:strip-flags ,strip-flags
+ #:strip-directories ,strip-directories))))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs (append native-drvs target-drvs)
+ #:outputs outputs
+ #:modules imported-modules
+ #:guile-for-build guile-for-build))
+
+(define qt-build-system
+ (build-system
+ (name 'qt)
+ (description
+ "The CMake build system augmented with definition of suitable environment
+variables for Qt and KDE in program wrappers.")
+ (lower lower)))
diff --git a/guix/build/qt-build-system.scm b/guix/build/qt-build-system.scm
new file mode 100644
index 0000000000..46fcad7848
--- /dev/null
+++ b/guix/build/qt-build-system.scm
@@ -0,0 +1,109 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2019 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build qt-build-system)
+ #:use-module ((guix build cmake-build-system) #:prefix cmake:)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
+ #:use-module (ice-9 ftw)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ qt-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Qt build procedure.
+;;
+;; Code:
+
+(define (variables-for-wrapping base-directories)
+
+ (define (collect-sub-dirs base-directories subdirectory)
+ (filter-map
+ (lambda (dir)
+ (let ((directory (string-append dir subdirectory)))
+ (if (directory-exists? directory) directory #f)))
+ base-directories))
+
+ (filter
+ (lambda (var-to-wrap) (not (null? (last var-to-wrap))))
+ (map
+ (lambda (var-spec)
+ `(,(first var-spec) = ,(collect-sub-dirs base-directories (last var-spec))))
+ (list
+ ;; these shall match the search-path-specification for Qt and KDE
+ ;; libraries
+ '("XDG_DATA_DIRS" "/share")
+ '("XDG_CONFIG_DIRS" "/etc/xdg")
+ '("QT_PLUGIN_PATH" "/lib/qt5/plugins")
+ '("QML2_IMPORT_PATH" "/lib/qt5/qml")))))
+
+(define* (wrap-all-programs #:key inputs outputs
+ (qt-wrap-excluded-outputs '())
+ #:allow-other-keys)
+ "Implement phase \"qt-wrap\": look for GSettings schemas and
+gtk+-v.0 libraries and create wrappers with suitably set environment variables
+if found.
+
+Wrapping is not applied to outputs whose name is listed in
+QT-WRAP-EXCLUDED-OUTPUTS. This is useful when an output is known not
+to contain any Qt binaries, and where wrapping would gratuitously
+add a dependency of that output on Qt."
+ (define (find-files-to-wrap directory)
+ (append-map
+ (lambda (dir)
+ (if (directory-exists? dir) (find-files dir ".*") (list)))
+ (list (string-append directory "/bin")
+ (string-append directory "/sbin")
+ (string-append directory "/libexec")
+ (string-append directory "/lib/libexec"))))
+
+ (define input-directories
+ ;; FIXME: Filter out unwanted inputs, e.g. cmake
+ (match inputs
+ (((_ . dir) ...)
+ dir)))
+
+ (define handle-output
+ (match-lambda
+ ((output . directory)
+ (unless (member output qt-wrap-excluded-outputs)
+ (let ((bin-list (find-files-to-wrap directory))
+ (vars-to-wrap (variables-for-wrapping
+ (append (list output)
+ input-directories))))
+ (when (not (null? vars-to-wrap))
+ (for-each (cut apply wrap-program <> vars-to-wrap)
+ bin-list)))))))
+
+ (for-each handle-output outputs)
+ #t)
+
+(define %standard-phases
+ (modify-phases cmake:%standard-phases
+ (add-after 'install 'qt-wrap wrap-all-programs)))
+
+(define* (qt-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given package, applying all of PHASES in order."
+ (apply cmake:cmake-build #:inputs inputs #:phases phases args))
--
2.21.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#38440] [PATCH 2/5] gnu: sddm: Use qt-build-system.
2019-11-30 22:00 ` [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system Hartmut Goebel
@ 2019-11-30 22:00 ` Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 3/5] gnu: ktouch: " Hartmut Goebel
` (2 subsequent siblings)
3 siblings, 0 replies; 9+ messages in thread
From: Hartmut Goebel @ 2019-11-30 22:00 UTC (permalink / raw)
To: 38440
* gnu/packages/display-managers.scm (sddm): Use qt-build-sytem.
[arguments]<modules, imported-modules>: Remove. <phases>: Base
on phases from qt-build-system. {wrap-programs}: Remove.
---
gnu/packages/display-managers.scm | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/gnu/packages/display-managers.scm b/gnu/packages/display-managers.scm
index 21afc0ec5c..75eab48572 100644
--- a/gnu/packages/display-managers.scm
+++ b/gnu/packages/display-managers.scm
@@ -27,6 +27,7 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix build-system cmake)
+ #:use-module (guix build-system qt)
#:use-module (guix build-system gnu)
#:use-module (guix packages)
#:use-module (guix utils)
@@ -62,7 +63,7 @@
(sha256
(base32
"0nilrhwlyvkngjgxfc08n73c16azgmw80pvx0a78xqww9y3hv4xh"))))
- (build-system cmake-build-system)
+ (build-system qt-build-system)
(native-inputs
`(("extra-cmake-modules" ,extra-cmake-modules)
("pkg-config" ,pkg-config)
@@ -105,24 +106,13 @@
(assoc-ref %outputs "out") "/lib/qt5/qml")
(string-append "-DCMAKE_INSTALL_SYSCONFDIR="
(assoc-ref %outputs "out") "/etc"))
- #:modules ((guix build cmake-build-system)
- (guix build qt-utils)
- (guix build utils))
- #:imported-modules (,@%cmake-build-system-modules
- (guix build qt-utils))
#:phases
- (modify-phases %standard-phases
+ (modify-phases (@ (guix build qt-build-system) %standard-phases)
(add-after 'unpack 'embed-loginctl-reference
(lambda _
(substitute* "CMakeLists.txt"
(("/usr/bin/loginctl") (which "loginctl")))
- #t))
- (add-after 'install 'wrap-programs
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (wrap-qt-program out "sddm")
- (wrap-qt-program out "sddm-greeter")
- #t))))))
+ #t)))))
(synopsis "QML based X11 and Wayland display manager")
(description "SDDM is a display manager for X11 and Wayland aiming to be
fast, simple and beautiful. SDDM is themeable and puts no restrictions on the
--
2.21.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#38440] [PATCH 3/5] gnu: ktouch: Use qt-build-system.
2019-11-30 22:00 ` [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 2/5] gnu: sddm: Use qt-build-system Hartmut Goebel
@ 2019-11-30 22:00 ` Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 4/5] gnu: kdeconnect: " Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 5/5] gnu: quaternion: " Hartmut Goebel
3 siblings, 0 replies; 9+ messages in thread
From: Hartmut Goebel @ 2019-11-30 22:00 UTC (permalink / raw)
To: 38440
* gnu/packages/display-managers.scm (ktouch): Use qt-build-sytem.
[arguments]<modules, imported-modules>: Remove. <phases>: Base
on phases from qt-build-system. {wrap-executables}: Remove.
---
gnu/packages/education.scm | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/gnu/packages/education.scm b/gnu/packages/education.scm
index c84fa54223..5d49bfb42d 100644
--- a/gnu/packages/education.scm
+++ b/gnu/packages/education.scm
@@ -58,6 +58,7 @@
#:use-module (guix build-system cmake)
#:use-module (guix build-system gnu)
#:use-module (guix build-system python)
+ #:use-module (guix build-system qt)
#:use-module (guix build-system trivial)
#:use-module (srfi srfi-1))
@@ -563,15 +564,10 @@ language and very flexible regarding to new or unknown keyboard layouts.")
(sha256
(base32
"19rdk94pls75hdvx11hnfk3qpm6l28p9q45q5f04sknxagrfaznr"))))
- (build-system cmake-build-system)
+ (build-system qt-build-system)
(arguments
- `(#:modules ((guix build cmake-build-system)
- (guix build qt-utils)
- (guix build utils))
- #:imported-modules (,@%cmake-build-system-modules
- (guix build qt-utils))
- #:phases
- (modify-phases %standard-phases
+ `(#:phases
+ (modify-phases (@ (guix build qt-build-system) %standard-phases)
(add-after 'configure 'patch-makefiles
(lambda* (#:key inputs #:allow-other-keys)
(let ((qtdec (assoc-ref inputs "qtdeclarative")))
@@ -579,11 +575,6 @@ language and very flexible regarding to new or unknown keyboard layouts.")
"src/CMakeFiles/ktouch.dir/build.make")
(("/gnu/store/.*qmlcachegen")
(string-append qtdec "/bin/qmlcachegen"))))
- #t))
- (add-after 'install 'wrap-executable
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (wrap-qt-program out "ktouch"))
#t)))))
(native-inputs
`(("extra-cmake-modules" ,extra-cmake-modules)
--
2.21.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#38440] [PATCH 4/5] gnu: kdeconnect: Use qt-build-system.
2019-11-30 22:00 ` [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 2/5] gnu: sddm: Use qt-build-system Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 3/5] gnu: ktouch: " Hartmut Goebel
@ 2019-11-30 22:00 ` Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 5/5] gnu: quaternion: " Hartmut Goebel
3 siblings, 0 replies; 9+ messages in thread
From: Hartmut Goebel @ 2019-11-30 22:00 UTC (permalink / raw)
To: 38440
* gnu/packages/display-managers.scm (kdeconnect): Use qt-build-sytem.
[arguments]<modules, imported-modules>: Remove. <phases>: Base
on phases from qt-build-system. {wrap-executable}: Remove.
---
gnu/packages/kde.scm | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/gnu/packages/kde.scm b/gnu/packages/kde.scm
index 778873e99c..a9cb6ad114 100644
--- a/gnu/packages/kde.scm
+++ b/gnu/packages/kde.scm
@@ -24,6 +24,7 @@
(define-module (gnu packages kde)
#:use-module (guix build-system cmake)
+ #:use-module (guix build-system qt)
#:use-module (guix download)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
@@ -540,28 +541,15 @@ different notification systems.")
(sha256
(base32
"02lr3xx5s2mgddac4n3lkgr7ppf1z5m6ajs90rjix0vs8a271kp5"))))
- (build-system cmake-build-system)
+ (build-system qt-build-system)
(arguments
`(#:configure-flags '("-DBUILD_TESTING=ON")
#:tests? #f ; tests fail hard in our build environment
- #:modules ((guix build cmake-build-system)
- (guix build qt-utils)
- (guix build utils))
- #:imported-modules (,@%cmake-build-system-modules
- (guix build qt-utils))
#:phases
- (modify-phases %standard-phases
+ (modify-phases (@ (guix build qt-build-system) %standard-phases)
(add-before 'check 'check-setup
(lambda _
(setenv "QT_QPA_PLATFORM" "offscreen")
- #t))
- (add-after 'install 'wrap-executable
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (wrap-qt-program out "../lib/libexec/kdeconnectd")
- (wrap-qt-program out "kdeconnect-cli")
- (wrap-qt-program out "kdeconnect-handler")
- (wrap-qt-program out "kdeconnect-indicator"))
#t)))))
(native-inputs
`(("extra-cmake-modules" ,extra-cmake-modules)
--
2.21.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#38440] [PATCH 5/5] gnu: quaternion: Use qt-build-system.
2019-11-30 22:00 ` [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system Hartmut Goebel
` (2 preceding siblings ...)
2019-11-30 22:00 ` [bug#38440] [PATCH 4/5] gnu: kdeconnect: " Hartmut Goebel
@ 2019-11-30 22:00 ` Hartmut Goebel
3 siblings, 0 replies; 9+ messages in thread
From: Hartmut Goebel @ 2019-11-30 22:00 UTC (permalink / raw)
To: 38440
* gnu/packages/display-managers.scm (quaternion): Use qt-build-sytem.
[arguments]<modules, imported-modules, phases>: Remove.
---
gnu/packages/messaging.scm | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 33e752c9a0..88a7246e32 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -97,6 +97,7 @@
#:use-module (guix build-system meson)
#:use-module (guix build-system perl)
#:use-module (guix build-system python)
+ #:use-module (guix build-system qt)
#:use-module (guix build-system trivial)
#:use-module (guix download)
#:use-module (guix git-download)
@@ -1786,7 +1787,7 @@ QMatrixClient project.")
(file-name (git-file-name name version))
(sha256
(base32 "0gpv6b3nn3lsyym8809kiqkpdszfasldqjpk5s542zyn41gdlql4"))))
- (build-system cmake-build-system)
+ (build-system qt-build-system)
(inputs
`(("libqmatrixclient" ,libqmatrixclient)
("qtbase" ,qtbase)
@@ -1797,19 +1798,7 @@ QMatrixClient project.")
("qtsvg" ,qtsvg)
("qttools" ,qttools)))
(arguments
- `(#:tests? #f ; no tests
- #:modules ((guix build cmake-build-system)
- (guix build qt-utils)
- (guix build utils))
- #:imported-modules (,@%cmake-build-system-modules
- (guix build qt-utils))
- #:phases
- (modify-phases %standard-phases
- (add-after 'install 'wrap-program
- (lambda* (#:key outputs #:allow-other-keys)
- (let ((out (assoc-ref outputs "out")))
- (wrap-qt-program out "quaternion")
- #t))))))
+ `(#:tests? #f)) ; no tests
(home-page "https://matrix.org/docs/projects/client/quaternion.html")
(synopsis "Graphical client for the Matrix instant messaging protocol")
(description "Quaternion is a Qt5 desktop client for the Matrix instant
--
2.21.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [bug#38440] [PATCH 0/5] Add the `qt` build-system.
2019-11-30 21:59 [bug#38440] [PATCH 0/5] Add the `qt` build-system Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system Hartmut Goebel
@ 2019-11-30 22:15 ` Brett Gilio
2019-12-01 19:28 ` bug#38440: " Hartmut Goebel
2019-11-30 22:17 ` [bug#38440] [PATCH v2] guix: Add the 'qt' build system Hartmut Goebel
2 siblings, 1 reply; 9+ messages in thread
From: Brett Gilio @ 2019-11-30 22:15 UTC (permalink / raw)
To: Hartmut Goebel; +Cc: 38440
Hartmut Goebel <h.goebel@crazy-compilers.com> writes:
> Works and is a good substitude for `wrap-program` from `qt-utils`. This
> `wrap-program` is still kept, since some packagins not using the
> cmake-build-syttem use it.
>
> Like `wrap-program`, this implementation has one deficit: The
> wrapper collects paths from *all* inputs, thus e.g. cmake will become a
> dependency of *every* binary packages using qt-build-system.
>
> But contraty to `wrap-program` this implementation does not use env-vars to
> build the paths, but inputs. Thus it will be easier to solve the issue by
> filtering inputs.
>
> Comments on the code are heardy welcome.
>
> Also see
> <https://lists.gnu.org/archive/html/guix-devel/2019-11/msg00386.html>
> <https://lists.gnu.org/archive/html/guix-devel/2019-11/msg00391.html>
>
> Hartmut Goebel (5):
> guix: Add the 'qt' build system.
> gnu: sddm: Use qt-build-system.
> gnu: ktouch: Use qt-build-system.
> gnu: kdeconnect: Use qt-build-system.
> gnu: quaternion: Use qt-build-system.
>
> Makefile.am | 2 +
> doc/guix.texi | 21 ++-
> gnu/packages/display-managers.scm | 18 +-
> gnu/packages/education.scm | 17 +-
> gnu/packages/kde.scm | 18 +-
> gnu/packages/messaging.scm | 17 +-
> guix/build-system/qt.scm | 295 ++++++++++++++++++++++++++++++
> guix/build/qt-build-system.scm | 109 +++++++++++
> 8 files changed, 440 insertions(+), 57 deletions(-)
> create mode 100644 guix/build-system/qt.scm
> create mode 100644 guix/build/qt-build-system.scm
Hartmut,
LGTM! Thanks for your work.
--
Brett M. Gilio
https://git.sr.ht/~brettgilio/
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bug#38440] [PATCH v2] guix: Add the 'qt' build system.
2019-11-30 21:59 [bug#38440] [PATCH 0/5] Add the `qt` build-system Hartmut Goebel
2019-11-30 22:00 ` [bug#38440] [PATCH 1/5] guix: Add the 'qt' build system Hartmut Goebel
2019-11-30 22:15 ` [bug#38440] [PATCH 0/5] Add the `qt` build-system Brett Gilio
@ 2019-11-30 22:17 ` Hartmut Goebel
2 siblings, 0 replies; 9+ messages in thread
From: Hartmut Goebel @ 2019-11-30 22:17 UTC (permalink / raw)
To: 38440
* guix/build-system/qt.scm, guix/build/qt-build-system.scm: New files.
* Makefile.am (MODULES): Add them.
* doc/guix.texi (Buiild systems): Add the new build system.
---
Makefile.am | 2 +
doc/guix.texi | 21 ++-
guix/build-system/qt.scm | 295 +++++++++++++++++++++++++++++++++
guix/build/qt-build-system.scm | 109 ++++++++++++
4 files changed, 426 insertions(+), 1 deletion(-)
create mode 100644 guix/build-system/qt.scm
create mode 100644 guix/build/qt-build-system.scm
diff --git a/Makefile.am b/Makefile.am
index b3f03d44c8..97f1ff514b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -132,6 +132,7 @@ MODULES = \
guix/build-system/perl.scm \
guix/build-system/python.scm \
guix/build-system/ocaml.scm \
+ guix/build-system/qt.scm \
guix/build-system/waf.scm \
guix/build-system/r.scm \
guix/build-system/rakudo.scm \
@@ -178,6 +179,7 @@ MODULES = \
guix/build/perl-build-system.scm \
guix/build/python-build-system.scm \
guix/build/ocaml-build-system.scm \
+ guix/build/qt-build-system.scm \
guix/build/r-build-system.scm \
guix/build/rakudo-build-system.scm \
guix/build/ruby-build-system.scm \
diff --git a/doc/guix.texi b/doc/guix.texi
index 23a30ce553..cf1d38afc9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -47,7 +47,7 @@ Copyright @copyright{} 2017 Thomas Danckaert@*
Copyright @copyright{} 2017 humanitiesNerd@*
Copyright @copyright{} 2017 Christopher Allan Webber@*
Copyright @copyright{} 2017, 2018 Marius Bakke@*
-Copyright @copyright{} 2017 Hartmut Goebel@*
+Copyright @copyright{} 2017, 2019 Hartmut Goebel@*
Copyright @copyright{} 2017, 2019 Maxim Cournoyer@*
Copyright @copyright{} 2017, 2018, 2019 Tobias Geerinckx-Rice@*
Copyright @copyright{} 2017 George Clemmer@*
@@ -6408,6 +6408,25 @@ passes flags specified by the @code{#:make-maker-flags} or
Which Perl package is used can be specified with @code{#:perl}.
@end defvr
+@defvr {Scheme Variable} qt-build-system
+This variable is exported by @code{(guix build-system qt)}. It
+is intended for use with applications using Qt or KDE.
+
+This build system adds the phase @code{qt-wrap} to the ones defined by
+@var{cmake-build-system}, after the @code{install} phase.
+
+This phase searches for Qt5 plugin paths, QML paths and some XDG in the inputs
+and output. In case some path is found, all programs in the output's
+@file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
+are wrapped in scripts defining the necessary environment variables.
+
+It is possible to exclude specific package outputs from that wrapping process
+by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
+This is useful when an output is known not to contain any Qt binaries, and
+where wrapping would gratuitously add a dependency of that output on Qt, KDE,
+or such.
+@end defvr
+
@defvr {Scheme Variable} r-build-system
This variable is exported by @code{(guix build-system r)}. It
implements the build procedure used by @uref{https://r-project.org, R}
diff --git a/guix/build-system/qt.scm b/guix/build-system/qt.scm
new file mode 100644
index 0000000000..b776845377
--- /dev/null
+++ b/guix/build-system/qt.scm
@@ -0,0 +1,295 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Cyril Roelandt <tipecaml@gmail.com>
+;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system qt)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system cmake)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (%qt-build-system-modules
+ qt-build
+ qt-build-system))
+
+;; Commentary:
+;;
+;; This build system is an extension of the 'cmake-build-system'. It
+;; accommodates the needs of Qt and KDE applications by adding a phase run
+;; after the 'install' phase:
+;;
+;; 'qt-wrap' phase:
+;;
+;; This phase looks for Qt5 plugin paths, QML paths and some XDG paths as well
+;; as the corresponding environment variables. If any of these is found in
+;; the output or if respective environment variables are set, then all
+;; programs in the output's "bin", "sbin", "libexec and "lib/libexec"
+;; directories are wrapped in scripts defining the necessary environment
+;; variables.
+;;
+;; Code:
+
+(define %qt-build-system-modules
+ ;; Build-side modules imported and used by default.
+ `((guix build qt-build-system)
+ ,@%cmake-build-system-modules))
+
+(define (default-cmake)
+ "Return the default CMake package."
+
+ ;; Do not use `@' to avoid introducing circular dependencies.
+ (let ((module (resolve-interface '(gnu packages cmake))))
+ (module-ref module 'cmake-minimal)))
+
+;; This barely is a copy from (guix build-system cmake), only adjusted to use
+;; the variables defined here.
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ (cmake (default-cmake))
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ `(#:source #:cmake #:inputs #:native-inputs #:outputs
+ ,@(if target '() '(#:target))))
+
+ (bag
+ (name name)
+ (system system)
+ (target target)
+ (build-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@`(("cmake" ,cmake))
+ ,@native-inputs
+ ,@(if target
+ ;; Use the standard cross inputs of
+ ;; 'gnu-build-system'.
+ (standard-cross-packages target 'host)
+ '())
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ ,@(standard-packages)))
+ (host-inputs inputs)
+
+ ;; The cross-libc is really a target package, but for bootstrapping
+ ;; reasons, we can't put it in 'host-inputs'. Namely, 'cross-gcc' is a
+ ;; native package, so it would end up using a "native" variant of
+ ;; 'cross-libc' (built with 'gnu-build'), whereas all the other packages
+ ;; would use a target variant (built with 'gnu-cross-build'.)
+ (target-inputs (if target
+ (standard-cross-packages target 'target)
+ '()))
+ (outputs outputs)
+ (build (if target qt-cross-build qt-build))
+ (arguments (strip-keyword-arguments private-keywords arguments))))
+
+
+(define* (qt-build store name inputs
+ #:key (guile #f)
+ (outputs '("out")) (configure-flags ''())
+ (search-paths '())
+ (make-flags ''())
+ (out-of-source? #t)
+ (build-type "RelWithDebInfo")
+ (tests? #t)
+ (test-target "test")
+ (parallel-build? #t) (parallel-tests? #f)
+ (validate-runpath? #t)
+ (patch-shebangs? #t)
+ (strip-binaries? #t)
+ (strip-flags ''("--strip-debug"))
+ (strip-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (phases '(@ (guix build qt-build-system)
+ %standard-phases))
+ (qt-wrap-excluded-outputs ''())
+ (system (%current-system))
+ (imported-modules %qt-build-system-modules)
+ (modules '((guix build cmake-build-system)
+ (guix build utils))))
+ "Build SOURCE using CMAKE, and with INPUTS. This assumes that SOURCE
+provides a 'CMakeLists.txt' file as its build system."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (cmake-build #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:outputs %outputs
+ #:inputs %build-inputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:phases ,phases
+ #:qt-wrap-excluded-outputs ,qt-wrap-excluded-outputs
+ #:configure-flags ,configure-flags
+ #:make-flags ,make-flags
+ #:out-of-source? ,out-of-source?
+ #:build-type ,build-type
+ #:tests? ,tests?
+ #:test-target ,test-target
+ #:parallel-build? ,parallel-build?
+ #:parallel-tests? ,parallel-tests?
+ #:validate-runpath? ,validate-runpath?
+ #:patch-shebangs? ,patch-shebangs?
+ #:strip-binaries? ,strip-binaries?
+ #:strip-flags ,strip-flags
+ #:strip-directories ,strip-directories)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs inputs
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+\f
+;;;
+;;; Cross-compilation.
+;;;
+
+(define* (qt-cross-build store name
+ #:key
+ target native-drvs target-drvs
+ (guile #f)
+ (outputs '("out"))
+ (configure-flags ''())
+ (search-paths '())
+ (native-search-paths '())
+ (make-flags ''())
+ (out-of-source? #t)
+ (build-type "RelWithDebInfo")
+ (tests? #f) ; nothing can be done
+ (test-target "test")
+ (parallel-build? #t) (parallel-tests? #f)
+ (validate-runpath? #t)
+ (patch-shebangs? #t)
+ (strip-binaries? #t)
+ (strip-flags ''("--strip-debug"
+ "--enable-deterministic-archives"))
+ (strip-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (phases '(@ (guix build qt-build-system)
+ %standard-phases))
+ (system (%current-system))
+ (build (nix-system->gnu-triplet system))
+ (imported-modules %qt-build-system-modules)
+ (modules '((guix build cmake-build-system)
+ (guix build utils))))
+ "Cross-build NAME using CMAKE for TARGET, where TARGET is a GNU triplet and
+with INPUTS. This assumes that SOURCE provides a 'CMakeLists.txt' file as its
+build system."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (let ()
+ (define %build-host-inputs
+ ',(map (match-lambda
+ ((name (? derivation? drv) sub ...)
+ `(,name . ,(apply derivation->output-path drv sub)))
+ ((name path)
+ `(,name . ,path)))
+ native-drvs))
+
+ (define %build-target-inputs
+ ',(map (match-lambda
+ ((name (? derivation? drv) sub ...)
+ `(,name . ,(apply derivation->output-path drv sub)))
+ ((name (? package? pkg) sub ...)
+ (let ((drv (package-cross-derivation store pkg
+ target system)))
+ `(,name . ,(apply derivation->output-path drv sub))))
+ ((name path)
+ `(,name . ,path)))
+ target-drvs))
+
+ (cmake-build #:source ,(match (assoc-ref native-drvs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:build ,build
+ #:target ,target
+ #:outputs %outputs
+ #:inputs %build-target-inputs
+ #:native-inputs %build-host-inputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:native-search-paths ',(map
+ search-path-specification->sexp
+ native-search-paths)
+ #:phases ,phases
+ #:configure-flags ,configure-flags
+ #:make-flags ,make-flags
+ #:out-of-source? ,out-of-source?
+ #:build-type ,build-type
+ #:tests? ,tests?
+ #:test-target ,test-target
+ #:parallel-build? ,parallel-build?
+ #:parallel-tests? ,parallel-tests?
+ #:validate-runpath? ,validate-runpath?
+ #:patch-shebangs? ,patch-shebangs?
+ #:strip-binaries? ,strip-binaries?
+ #:strip-flags ,strip-flags
+ #:strip-directories ,strip-directories))))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs (append native-drvs target-drvs)
+ #:outputs outputs
+ #:modules imported-modules
+ #:guile-for-build guile-for-build))
+
+(define qt-build-system
+ (build-system
+ (name 'qt)
+ (description
+ "The CMake build system augmented with definition of suitable environment
+variables for Qt and KDE in program wrappers.")
+ (lower lower)))
diff --git a/guix/build/qt-build-system.scm b/guix/build/qt-build-system.scm
new file mode 100644
index 0000000000..46fcad7848
--- /dev/null
+++ b/guix/build/qt-build-system.scm
@@ -0,0 +1,109 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2019 Hartmut Goebel <h.goebel@crazy-compilers.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build qt-build-system)
+ #:use-module ((guix build cmake-build-system) #:prefix cmake:)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
+ #:use-module (ice-9 ftw)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ qt-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard Qt build procedure.
+;;
+;; Code:
+
+(define (variables-for-wrapping base-directories)
+
+ (define (collect-sub-dirs base-directories subdirectory)
+ (filter-map
+ (lambda (dir)
+ (let ((directory (string-append dir subdirectory)))
+ (if (directory-exists? directory) directory #f)))
+ base-directories))
+
+ (filter
+ (lambda (var-to-wrap) (not (null? (last var-to-wrap))))
+ (map
+ (lambda (var-spec)
+ `(,(first var-spec) = ,(collect-sub-dirs base-directories (last var-spec))))
+ (list
+ ;; these shall match the search-path-specification for Qt and KDE
+ ;; libraries
+ '("XDG_DATA_DIRS" "/share")
+ '("XDG_CONFIG_DIRS" "/etc/xdg")
+ '("QT_PLUGIN_PATH" "/lib/qt5/plugins")
+ '("QML2_IMPORT_PATH" "/lib/qt5/qml")))))
+
+(define* (wrap-all-programs #:key inputs outputs
+ (qt-wrap-excluded-outputs '())
+ #:allow-other-keys)
+ "Implement phase \"qt-wrap\": look for GSettings schemas and
+gtk+-v.0 libraries and create wrappers with suitably set environment variables
+if found.
+
+Wrapping is not applied to outputs whose name is listed in
+QT-WRAP-EXCLUDED-OUTPUTS. This is useful when an output is known not
+to contain any Qt binaries, and where wrapping would gratuitously
+add a dependency of that output on Qt."
+ (define (find-files-to-wrap directory)
+ (append-map
+ (lambda (dir)
+ (if (directory-exists? dir) (find-files dir ".*") (list)))
+ (list (string-append directory "/bin")
+ (string-append directory "/sbin")
+ (string-append directory "/libexec")
+ (string-append directory "/lib/libexec"))))
+
+ (define input-directories
+ ;; FIXME: Filter out unwanted inputs, e.g. cmake
+ (match inputs
+ (((_ . dir) ...)
+ dir)))
+
+ (define handle-output
+ (match-lambda
+ ((output . directory)
+ (unless (member output qt-wrap-excluded-outputs)
+ (let ((bin-list (find-files-to-wrap directory))
+ (vars-to-wrap (variables-for-wrapping
+ (append (list output)
+ input-directories))))
+ (when (not (null? vars-to-wrap))
+ (for-each (cut apply wrap-program <> vars-to-wrap)
+ bin-list)))))))
+
+ (for-each handle-output outputs)
+ #t)
+
+(define %standard-phases
+ (modify-phases cmake:%standard-phases
+ (add-after 'install 'qt-wrap wrap-all-programs)))
+
+(define* (qt-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given package, applying all of PHASES in order."
+ (apply cmake:cmake-build #:inputs inputs #:phases phases args))
--
2.21.0
^ permalink raw reply related [flat|nested] 9+ messages in thread