summaryrefslogtreecommitdiff
path: root/module/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-07-31 00:06:59 +0200
committerLudovic Courtès <ludo@gnu.org>2009-07-31 00:49:22 +0200
commit2e4c3227ce1374dd53abd3c7c5797cc64329de91 (patch)
tree2feba0d7095f83b390bf0da5370b1260d0f391fb /module/scripts
parentf4aa0f104b3347c21093b837046022fb7bb6a2ff (diff)
downloadguile-2e4c3227ce1374dd53abd3c7c5797cc64329de91.tar.gz
Add `(system base message)', a simple warning framework.
* module/Makefile.am (SOURCES): Add `system/base/message.scm'. * module/scripts/compile.scm (%options): Add `--warn'. (parse-args): Update default value for `warnings'. (show-warning-help): New procedure. (compile)[compile-opts]: Add `#:warnings'. Update help message. * module/system/base/compile.scm (compile): Sanity-check the requested warnings. * module/system/base/message.scm: New file.
Diffstat (limited to 'module/scripts')
-rw-r--r--module/scripts/compile.scm34
1 files changed, 32 insertions, 2 deletions
diff --git a/module/scripts/compile.scm b/module/scripts/compile.scm
index 311e35bad..89d35bcb5 100644
--- a/module/scripts/compile.scm
+++ b/module/scripts/compile.scm
@@ -30,9 +30,11 @@
(define-module (scripts compile)
#:use-module ((system base compile) #:select (compile-file))
+ #:use-module (system base message)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-13)
#:use-module (srfi srfi-37)
+ #:use-module (ice-9 format)
#:export (compile))
@@ -58,6 +60,17 @@
(fail "`-o' option cannot be specified more than once")
(alist-cons 'output-file arg result))))
+ (option '(#\W "warn") #t #f
+ (lambda (opt name arg result)
+ (if (string=? arg "help")
+ (begin
+ (show-warning-help)
+ (exit 0))
+ (let ((warnings (assoc-ref result 'warnings)))
+ (alist-cons 'warnings
+ (cons (string->symbol arg) warnings)
+ (alist-delete 'warnings result))))))
+
(option '(#\O "optimize") #f #f
(lambda (opt name arg result)
(alist-cons 'optimize? #t result)))
@@ -86,13 +99,27 @@ options."
;; default option values
'((input-files)
- (load-path))))
+ (load-path)
+ (warnings unsupported-warning))))
+
+(define (show-warning-help)
+ (format #t "The available warning types are:~%~%")
+ (for-each (lambda (wt)
+ (format #t " ~22A ~A~%"
+ (format #f "`~A'" (warning-type-name wt))
+ (warning-type-description wt)))
+ %warning-types)
+ (format #t "~%"))
(define (compile . args)
(let* ((options (parse-args args))
(help? (assoc-ref options 'help?))
- (compile-opts (if (assoc-ref options 'optimize?) '(#:O) '()))
+ (compile-opts (let ((o `(#:warnings
+ ,(assoc-ref options 'warnings))))
+ (if (assoc-ref options 'optimize?)
+ (cons #:O o)
+ o)))
(from (or (assoc-ref options 'from) 'scheme))
(to (or (assoc-ref options 'to) 'objcode))
(input-files (assoc-ref options 'input-files))
@@ -108,6 +135,9 @@ Compile each Guile source file FILE into a Guile object.
-L, --load-path=DIR add DIR to the front of the module load path
-o, --output=OFILE write output to OFILE
+ -W, --warn=WARNING emit warnings of type WARNING; use `--warn=help'
+ for a list of available warnings
+
-f, --from=LANG specify a source language other than `scheme'
-t, --to=LANG specify a target language other than `objcode'