cuirass: add "--load-path" option

* bin/cuirass.in (%options): Add "--load-path" and "-L" command line options.
(show-help): Adapt.
* src/cuirass/base.scm (%load-package-path): New variable.
(preprend-to-package-module-path): New method.
(evaluate)[arguments]: Pass %load-package-path.
* bin/evaluate.in (main): Read new "load-package-path" argument and
add it to load lists with "preprend-to-package-module-path".
pull/3/head
Mathieu Othacehe 2017-01-25 09:54:54 +01:00
parent d0a5801e39
commit f44922c046
3 changed files with 20 additions and 1 deletions

View File

@ -34,6 +34,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@"
--one-shot Evaluate and build jobs only once
--cache-directory=DIR Use DIR for storing repository data
-L --load-path=DIR Prepend DIR to the package module search path.
-S --specifications=SPECFILE
Add specifications from SPECFILE to database.
-D --database=DB Use DB to store build results.
@ -48,6 +49,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@"
(define %options
'((one-shot (value #f))
(cache-directory (value #t))
(load-path (single-char #\L) (value #t))
(specifications (single-char #\S) (value #t))
(database (single-char #\D) (value #t))
(port (single-char #\p) (value #t))
@ -68,6 +70,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@"
(%package-database (option-ref opts 'database (%package-database)))
(%package-cachedir
(option-ref opts 'cache-directory (%package-cachedir)))
(%load-package-path (option-ref opts 'load-path (%load-package-path)))
(%use-substitutes? (option-ref opts 'use-substitutes #f)))
(cond
((option-ref opts 'help #f)

View File

@ -32,7 +32,7 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@"
(define* (main #:optional (args (command-line)))
(match args
((command load-path cachedir specstr database)
((command load-path load-package-path cachedir specstr database)
;; Load FILE, a Scheme file that defines Hydra jobs.
(let ((%user-module (make-fresh-user-module))
(spec (with-input-from-string specstr read))
@ -58,6 +58,8 @@ exec ${GUILE:-@GUILE@} --no-auto-compile -e main -s "$0" "$@"
(exit 1)))
(parameterize ((%package-database database)
(%use-substitutes? (assoc-ref spec #:use-substitutes?)))
(if load-package-path
(prepend-to-package-module-path load-package-path))
;; Call the entry point of FILE and print the resulting job sexp.
(let* ((proc-name (assq-ref spec #:proc))
(proc (module-ref %user-module proc-name))

View File

@ -22,6 +22,7 @@
#:use-module (cuirass utils)
#:use-module (guix derivations)
#:use-module (guix store)
#:use-module (gnu packages)
#:use-module (ice-9 format)
#:use-module (ice-9 popen)
#:use-module (ice-9 rdelim)
@ -33,14 +34,20 @@
evaluate
build-packages
process-specs
prepend-to-package-module-path
;; Parameters.
%package-cachedir
%load-package-path
%use-substitutes?))
(define %use-substitutes?
;; Define whether to use substitutes
(make-parameter #f))
(define %load-package-path
;; Extension of package module search path.
(make-parameter #f))
(define %package-cachedir
;; Define to location of cache directory of this package.
(make-parameter (or (getenv "CUIRASS_CACHEDIR")
@ -52,6 +59,12 @@
(scm-error 'wrong-type-arg
"%package-cachedir" "Not a string: ~S" (list #f) #f)))))
(define (prepend-to-package-module-path load-path)
(%package-module-path (cons load-path (%package-module-path)))
(%patch-path (cons load-path (%patch-path)))
(set! %load-path (cons load-path %load-path))
(set! %load-compiled-path (cons load-path %load-compiled-path)))
(define (call-with-time thunk kont)
"Call THUNK and pass KONT the elapsed time followed by THUNK's return
values."
@ -114,6 +127,7 @@ if required."
(string-append (%package-cachedir) "/"
(assq-ref spec #:name) "/"
(assq-ref spec #:load-path))
(%load-package-path)
(%package-cachedir)
(object->string spec)
(%package-database)))