From 7b6b7cdcc5d50cb25c140145b30028c5569c62af Mon Sep 17 00:00:00 2001 From: Andy Patterson Date: Thu, 30 Aug 2018 01:36:28 -0400 Subject: build-system/asdf: Handle all asdf dependency specifications. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for dependencies of the form (:version ), (:feature ) and (:require ), as defined by . * guix/build/lisp-utils.scm (normalize-dependency): New variable. (make-asd-file)[dependencies]: Use it to generate dependencies with normalized names. [dependency-name]: New variable. [registry]: Use it to flatten the normalized dependencies. Signed-off-by: Ludovic Courtès --- guix/build/lisp-utils.scm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'guix/build') diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm index 21cb620d59..3a7afab43d 100644 --- a/guix/build/lisp-utils.scm +++ b/guix/build/lisp-utils.scm @@ -81,6 +81,20 @@ "Replace invalid characters in STR with a hyphen." (string-join (string-tokenize str valid-char-set) "-")) +(define (normalize-dependency dependency) + "Normalize the name of DEPENDENCY. Handles dependency definitions of the +dependency-def form described by +." + (match dependency + ((':version name rest ...) + `(:version ,(normalize-string name) ,@rest)) + ((':feature feature-specification dependency-specification) + `(:feature + ,feature-specification + ,(normalize-dependency dependency-specification))) + ((? string? name) (normalize-string name)) + (require-specification require-specification))) + (define (inputs->asd-file-map inputs) "Produce a hash table of the form (system . asd-file), where system is the name of an ASD system, and asd-file is the full path to its definition." @@ -273,16 +287,24 @@ system to find its dependencies, as described by GENERATE-DEPENDENCY-LINKS." (system-dependencies system system-asd-file))) (if (eq? 'NIL deps) '() - (map normalize-string deps)))) + (map normalize-dependency deps)))) (define lisp-input-map (inputs->asd-file-map inputs)) + (define dependency-name + (match-lambda + ((':version name _ ...) name) + ((':feature _ dependency-specification) + (dependency-name dependency-specification)) + ((? string? name) name) + (_ #f))) + (define registry (filter-map hash-get-handle (make-list (length dependencies) lisp-input-map) - dependencies)) + (map dependency-name dependencies))) (call-with-output-file asd-file (lambda (port) -- cgit v1.2.3 From 29a3ffb44623701c2c24b8e921e23d03dde02a4a Mon Sep 17 00:00:00 2001 From: Andy Patterson Date: Thu, 30 Aug 2018 01:36:29 -0400 Subject: build-system/asdf: Log lisp system invocations. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build/lisp-system.scm: (lisp-eval-program): Log the arguments to system*. Signed-off-by: Ludovic Courtès --- guix/build/lisp-utils.scm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'guix/build') diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm index 3a7afab43d..9cf479dac5 100644 --- a/guix/build/lisp-utils.scm +++ b/guix/build/lisp-utils.scm @@ -119,9 +119,10 @@ name of an ASD system, and asd-file is the full path to its definition." (define (lisp-eval-program program) "Evaluate PROGRAM with a given LISP implementation." - (unless (zero? (apply system* - (lisp-invocation program))) - (error "lisp-eval-program failed!" (%lisp) program))) + (define invocation (lisp-invocation program)) + (format #t "Invoking ~a: ~{~s ~}~%" (%lisp-type) invocation) + (unless (zero? (apply system* invocation)) + (error "lisp-eval-program failed!" invocation))) (define (spread-statements program argument-name) "Return a list with the statements from PROGRAM spread between -- cgit v1.2.3 From e831a1668b0556068343dce8cecacef2014a96e9 Mon Sep 17 00:00:00 2001 From: Andy Patterson Date: Thu, 30 Aug 2018 01:36:30 -0400 Subject: build-system/asdf: Use invoke. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build/lisp-utils.scm (lisp-eval-program): Replace system* and error handling with invoke. Signed-off-by: Ludovic Courtès --- guix/build/lisp-utils.scm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'guix/build') diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm index 9cf479dac5..7c0a68ca97 100644 --- a/guix/build/lisp-utils.scm +++ b/guix/build/lisp-utils.scm @@ -121,8 +121,7 @@ name of an ASD system, and asd-file is the full path to its definition." "Evaluate PROGRAM with a given LISP implementation." (define invocation (lisp-invocation program)) (format #t "Invoking ~a: ~{~s ~}~%" (%lisp-type) invocation) - (unless (zero? (apply system* invocation)) - (error "lisp-eval-program failed!" invocation))) + (apply invoke invocation)) (define (spread-statements program argument-name) "Return a list with the statements from PROGRAM spread between -- cgit v1.2.3 From 5f6908d664c3af6bd1805a769640ba5240602230 Mon Sep 17 00:00:00 2001 From: Andy Patterson Date: Thu, 30 Aug 2018 01:36:31 -0400 Subject: build-system/asdf: Adopt asdf conventions. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The asdf documentation specifies that asdf:load-asd should be preferred to calling load on a system definition file. * guix/build/lisp-utils.scm (compile-system): Replace load with asdf:load-asd. (system-dependencies): Likewise. (test-system): Likewise. Signed-off-by: Ludovic Courtès --- guix/build/lisp-utils.scm | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'guix/build') diff --git a/guix/build/lisp-utils.scm b/guix/build/lisp-utils.scm index 7c0a68ca97..6470cfec97 100644 --- a/guix/build/lisp-utils.scm +++ b/guix/build/lisp-utils.scm @@ -152,8 +152,7 @@ with PROGRAM." first." (lisp-eval-program `((require :asdf) - (let ((*package* (find-package :asdf))) - (load ,asd-file)) + (asdf:load-asd (truename ,asd-file) :name ,(normalize-string system)) (asdf:operate 'asdf:compile-bundle-op ,system)))) (define (system-dependencies system asd-file) @@ -162,8 +161,7 @@ asdf:system-depends-on. First load the system's ASD-FILE." (define deps-file ".deps.sexp") (define program `((require :asdf) - (let ((*package* (find-package :asdf))) - (load ,asd-file)) + (asdf:load-asd (truename ,asd-file) :name ,(normalize-string system)) (with-open-file (stream ,deps-file :direction :output) (format stream @@ -203,19 +201,18 @@ asdf:system-depends-on. First load the system's ASD-FILE." Also load TEST-ASD-FILE if necessary." (lisp-eval-program `((require :asdf) - (let ((*package* (find-package :asdf))) - (load ,asd-file) - ,@(if test-asd-file - `((load ,test-asd-file)) - ;; Try some likely files. - (map (lambda (file) - `(when (uiop:file-exists-p ,file) - (load ,file))) - (list - (string-append system "-tests.asd") - (string-append system "-test.asd") - "tests.asd" - "test.asd")))) + (asdf:load-asd (truename ,asd-file) :name ,(normalize-string system)) + ,@(if test-asd-file + `((asdf:load-asd (truename ,test-asd-file))) + ;; Try some likely files. + (map (lambda (file) + `(when (uiop:file-exists-p ,file) + (asdf:load-asd (truename ,file)))) + (list + (string-append system "-tests.asd") + (string-append system "-test.asd") + "tests.asd" + "test.asd"))) (asdf:test-system ,system)))) (define (string->lisp-keyword . strings) -- cgit v1.2.3