Merge branch 'staging' into core-updates
[jackhill/guix/guix.git] / guix / build / meson-build-system.scm
index 7efd433..f6b8b49 100644 (file)
@@ -1,5 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
+;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
          (prefix (assoc-ref outputs "out"))
          (args `(,(string-append "--prefix=" prefix)
                  ,(string-append "--buildtype=" build-type)
+                 ,(string-append "-Dc_link_args=-Wl,-rpath="
+                                 (assoc-ref outputs "out") "/lib")
+                 ,(string-append "-Dcpp_link_args=-Wl,-rpath="
+                                 (assoc-ref outputs "out") "/lib")
                  ,@configure-flags
                  ,source-dir)))
 
-    ;; Meson lacks good facilities for dealing with RUNPATH, so we
-    ;; add the output "lib" directory here to avoid doing that in
-    ;; many users.  Related issues:
-    ;; * <https://github.com/mesonbuild/meson/issues/314>
-    ;; * <https://github.com/mesonbuild/meson/issues/3038>
-    ;; * <https://github.com/NixOS/nixpkgs/issues/31222>
-    (unless (getenv "LDFLAGS")
-      (setenv "LDFLAGS" (string-append "-Wl,-rpath=" out "/lib")))
-
     (mkdir build-dir)
     (chdir build-dir)
-    (zero? (apply system* "meson" args))))
+    (apply invoke "meson" args)))
 
 (define* (build #:key parallel-build?
                 #:allow-other-keys)
   "Build a given meson package."
-  (zero? (apply system* "ninja"
-                (if parallel-build?
-                    `("-j" ,(number->string (parallel-job-count)))
-                    '("-j" "1")))))
+  (invoke "ninja" "-j" (if parallel-build?
+                           (number->string (parallel-job-count))
+                           "1")))
 
 (define* (check #:key test-target parallel-tests? tests?
                 #:allow-other-keys)
               (number->string (parallel-job-count))
               "1"))
   (if tests?
-      (zero? (system* "ninja" test-target))
-      (begin
-        (format #t "test suite not run~%")
-        #t)))
+      (invoke "ninja" test-target)
+      (format #t "test suite not run~%"))
+  #t)
 
 (define* (install #:rest args)
-  (zero? (system* "ninja" "install")))
+  (invoke "ninja" "install"))
 
 (define* (fix-runpath #:key (elf-directories '("lib" "lib64" "libexec"
                                                "bin" "sbin"))
@@ -149,8 +144,13 @@ for example libraries only needed for the tests."
     (replace 'configure configure)
     (replace 'build build)
     (replace 'check check)
-    (replace 'install install)
-    (add-after 'strip 'fix-runpath fix-runpath)))
+    ;; XXX: We used to have 'fix-runpath' here, but it appears no longer
+    ;; necessary with newer Meson.  However on 'core-updates' there is a
+    ;; useful 'strip-runpath' procedure to ensure no bogus directories in
+    ;; RUNPATH (remember that we tell Meson to not touch RUNPATH in
+    ;; (@ (gnu packages build-tools) meson-for-build)), so it should be
+    ;; re-added there sans the augment-rpath calls (which are not needed).
+    (replace 'install install)))
 
 (define* (meson-build #:key inputs phases
                       #:allow-other-keys #:rest args)