summaryrefslogtreecommitdiff
path: root/guix/build
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-04-25 15:53:41 +0200
committerMarius Bakke <mbakke@fastmail.com>2018-04-25 15:53:41 +0200
commita9fe3882b9400d6a49ca95e136e78477b3e81a07 (patch)
treeb724ec1ed54d4a2c1b617a63eb05b98721f5d48a /guix/build
parent68c4759baa4c1bb87e1c7c5568d5cdf4e1434fb1 (diff)
parent0afeda65218ed0c82ab18762111c52a9fedd2582 (diff)
Merge branch 'master' into staging
Diffstat (limited to 'guix/build')
-rw-r--r--guix/build/emacs-build-system.scm93
-rw-r--r--guix/build/emacs-utils.scm14
2 files changed, 58 insertions, 49 deletions
diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm
index b779847424..094b04750a 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -74,12 +74,37 @@ archive, a directory, or an Emacs Lisp file."
#t)
(gnu:unpack #:source source)))
-(define* (set-emacs-load-path #:key inputs #:allow-other-keys)
+(define* (set-emacs-load-path #:key source inputs #:allow-other-keys)
+ (define (inputs->directories inputs)
+ "Extract the directory part from INPUTS."
+ (match inputs
+ (((names . directories) ...) directories)))
+
+ (define (input-directory->el-directory input-directory)
+ "Return the correct Emacs Lisp directory in INPUT-DIRECTORY or #f, if there
+is no Emacs Lisp directory."
+ (let ((legacy-elisp-directory (string-append input-directory %legacy-install-suffix))
+ (guix-elisp-directory
+ (string-append
+ input-directory %install-suffix "/"
+ (store-directory->elpa-name-version input-directory))))
+ (cond
+ ((file-exists? guix-elisp-directory) guix-elisp-directory)
+ ((file-exists? legacy-elisp-directory) legacy-elisp-directory)
+ (else #f))))
+
+ (define (input-directories->el-directories input-directories)
+ "Return the list of Emacs Lisp directories in INPUT-DIRECTORIES."
+ (filter-map input-directory->el-directory input-directories))
+
"Set the EMACSLOADPATH environment variable so that dependencies are found."
- (let* ((input-elisp-dirs (emacs-inputs-el-directories
- (emacs-inputs-directories inputs)))
- (emacs-load-path-value (string-join
- input-elisp-dirs ":" 'suffix)))
+ (let* ((source-directory (getcwd))
+ (input-elisp-directories (input-directories->el-directories
+ (inputs->directories inputs)))
+ (emacs-load-path-value
+ (string-join
+ (append input-elisp-directories (list source-directory))
+ ":" 'suffix)))
(setenv "EMACSLOADPATH" emacs-load-path-value)
(format #t "environment variable `EMACSLOADPATH' set to ~a\n"
emacs-load-path-value)))
@@ -133,6 +158,24 @@ store in '.el' files."
(substitute-program-names))))
#t))
+(define* (check #:key tests? (test-command '("make" "check"))
+ (parallel-tests? #t) #:allow-other-keys)
+ "Run the tests by invoking TEST-COMMAND.
+
+When TEST-COMMAND uses make and PARALLEL-TESTS is #t, the tests are run in
+parallel. PARALLEL-TESTS? is ignored when using a non-make TEST-COMMAND."
+ (match-let (((test-program . args) test-command))
+ (let ((using-make? (string=? test-program "make")))
+ (if tests?
+ (apply invoke test-program
+ `(,@args
+ ,@(if (and using-make? parallel-tests?)
+ `("-j" ,(number->string (parallel-job-count)))
+ '())))
+ (begin
+ (format #t "test suite not run~%")
+ #t)))))
+
(define* (install #:key outputs
(include %default-include)
(exclude %default-exclude)
@@ -203,47 +246,12 @@ store in '.el' files."
(elpa-name (package-name->name+version elpa-name-ver))
(el-dir (string-append out %install-suffix "/" elpa-name-ver)))
(parameterize ((%emacs emacs))
- (emacs-generate-autoloads elpa-name el-dir))
- #t))
+ (emacs-generate-autoloads elpa-name el-dir))))
(define (emacs-package? name)
"Check if NAME correspond to the name of an Emacs package."
(string-prefix? "emacs-" name))
-(define (emacs-inputs inputs)
- "Retrieve the list of Emacs packages from INPUTS."
- (filter (match-lambda
- ((label . directory)
- (emacs-package? ((compose package-name->name+version
- strip-store-file-name)
- directory)))
- (_ #f))
- inputs))
-
-(define (emacs-inputs-directories inputs)
- "Extract the list of Emacs package directories from INPUTS."
- (let ((inputs (emacs-inputs inputs)))
- (match inputs
- (((names . directories) ...) directories))))
-
-(define (emacs-input->el-directory emacs-input)
- "Return the correct Elisp directory location of EMACS-INPUT or #f if none."
- (let ((legacy-elisp-dir (string-append emacs-input %legacy-install-suffix))
- (guix-elisp-dir (string-append
- emacs-input %install-suffix "/"
- (store-directory->elpa-name-version emacs-input))))
- (cond
- ((file-exists? guix-elisp-dir) guix-elisp-dir)
- ((file-exists? legacy-elisp-dir) legacy-elisp-dir)
- (else (format #t "warning: could not locate elisp directory under `~a'\n"
- emacs-input)
- #f))))
-
-(define (emacs-inputs-el-directories dirs)
- "Build the list of Emacs Lisp directories from the Emacs package directory
-DIRS."
- (filter-map emacs-input->el-directory dirs))
-
(define (package-name-version->elpa-name-version name-ver)
"Convert the Guix package NAME-VER to the corresponding ELPA name-version
format. Essentially drop the prefix used in Guix."
@@ -260,12 +268,13 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages."
(define %standard-phases
(modify-phases gnu:%standard-phases
- (add-after 'set-paths 'set-emacs-load-path set-emacs-load-path)
(replace 'unpack unpack)
+ (add-after 'unpack 'set-emacs-load-path set-emacs-load-path)
(delete 'configure)
;; Move the build phase after install: the .el files are byte compiled
;; directly in the store.
(delete 'build)
+ (replace 'check check)
(replace 'install install)
(add-after 'install 'build build)
(add-after 'install 'make-autoloads make-autoloads)
diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8389ca582f..2bd4e39854 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2018 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -18,6 +19,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix build emacs-utils)
+ #:use-module (guix build utils)
#:export (%emacs
emacs-batch-eval
emacs-batch-edit-file
@@ -39,16 +41,14 @@
(define (emacs-batch-eval expr)
"Run Emacs in batch mode, and execute the elisp code EXPR."
- (unless (zero? (system* (%emacs) "--quick" "--batch"
- (format #f "--eval=~S" expr)))
- (error "emacs-batch-eval failed!" expr)))
+ (invoke (%emacs) "--quick" "--batch"
+ (format #f "--eval=~S" expr)))
(define (emacs-batch-edit-file file expr)
"Load FILE in Emacs using batch mode, and execute the elisp code EXPR."
- (unless (zero? (system* (%emacs) "--quick" "--batch"
- (string-append "--visit=" file)
- (format #f "--eval=~S" expr)))
- (error "emacs-batch-edit-file failed!" file expr)))
+ (invoke (%emacs) "--quick" "--batch"
+ (string-append "--visit=" file)
+ (format #f "--eval=~S" expr)))
(define (emacs-generate-autoloads name directory)
"Generate autoloads for Emacs package NAME placed in DIRECTORY."