summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-02-20 16:19:12 +0100
committerLudovic Courtès <ludo@gnu.org>2009-02-20 16:19:12 +0100
commit6d77c6efa00e61355bdbab12f3d2ded53341b786 (patch)
treec4caa1e4bda4c330fef6337d1031049c70146c6e
parent2308dce1beb1d7338a2edbbc6c3458399a9f15df (diff)
downloadguile-6d77c6efa00e61355bdbab12f3d2ded53341b786.tar.gz
Add `-L'/`--load-path' option to "guile-tools compile".
* scripts/compile (%options): Add `-L'/`--load-path'. (parse-args): Have `load-path' default to '(). (compile): Handle `--load-path' option.
-rwxr-xr-xscripts/compile17
1 files changed, 15 insertions, 2 deletions
diff --git a/scripts/compile b/scripts/compile
index 344cb3752..15160cdcd 100755
--- a/scripts/compile
+++ b/scripts/compile
@@ -47,6 +47,11 @@ exec ${GUILE-guile} -e '(@ (scripts compile) compile)' -s $0 "$@"
(lambda (opt name arg result)
(alist-cons 'help? #t result)))
+ (option '(#\L "load-path") #t #f
+ (lambda (opt name arg result)
+ (let ((load-path (assoc-ref result 'load-path)))
+ (alist-cons 'load-path (cons arg load-path)
+ result))))
(option '(#\O "optimize") #f #f
(lambda (opt name arg result)
(alist-cons 'optimize? #t result)))
@@ -71,7 +76,10 @@ options."
(let ((input-files (assoc-ref result 'input-files)))
(alist-cons 'input-files (cons file input-files)
result)))
- '((input-files))))
+
+ ;; default option values
+ '((input-files)
+ (load-path))))
(define (compile args)
@@ -81,13 +89,16 @@ options."
(expand-only? (assoc-ref options 'expand-only?))
(translate-only? (assoc-ref options 'translate-only?))
(compile-only? (assoc-ref options 'compile-only?))
- (input-files (assoc-ref options 'input-files)))
+ (input-files (assoc-ref options 'input-files))
+ (load-path (assoc-ref options 'load-path)))
(if (or help? (null? input-files))
(begin
(format #t "Usage: compile [OPTION] FILE...
Compile each Guile Scheme source file FILE into a Guile object.
-h, --help print this help message
+
+ -L, --load-path=DIR add DIR to the front of the module load path
-O, --optimize turn on optimizations
-e, --expand-only only go through the code expansion stage
-t, --translate-only stop after the translation to GHIL
@@ -96,6 +107,8 @@ Compile each Guile Scheme source file FILE into a Guile object.
Report bugs to <guile-user@gnu.org>.~%")
(exit 0)))
+ (set! %load-path (append load-path %load-path))
+
(let ((compile-opts (append (if optimize? '(#:O) '())
(if expand-only? '(#:e) '())
(if translate-only? '(#:t) '())