mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 15:40:19 +02:00
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.
This commit is contained in:
parent
f4aa0f104b
commit
2e4c3227ce
4 changed files with 146 additions and 2 deletions
|
@ -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'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue