-;;; Compile --- Command-line Guile Scheme compiler
+;;; Compile --- Command-line Guile Scheme compiler -*- coding: iso-8859-1 -*-
-;; Copyright 2005,2008,2009 Free Software Foundation, Inc.
+;; Copyright 2005, 2008-2011, 2013, 2014 Free Software Foundation, Inc.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public License
(define-module (scripts compile)
#:use-module ((system base compile) #:select (compile-file))
+ #:use-module (system base target)
#:use-module (system base message)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-13)
#:use-module (ice-9 format)
#:export (compile))
+(define %summary "Compile a file.")
+
\f
(define (fail . messages)
- (format (current-error-port)
- (string-concatenate `("error: " ,@messages "~%")))
+ (format (current-error-port) "error: ~{~a~}~%" messages)
(exit 1))
(define %options
(lambda (opt name arg result)
(if (assoc-ref result 'to)
(fail "`--to' option cannot be specified more than once")
- (alist-cons 'to (string->symbol arg) result))))))
+ (alist-cons 'to (string->symbol arg) result))))
+ (option '(#\T "target") #t #f
+ (lambda (opt name arg result)
+ (if (assoc-ref result 'target)
+ (fail "`--target' option cannot be specified more than once")
+ (alist-cons 'target arg result))))))
(define (parse-args args)
"Parse argument list @var{args} and return an alist with all the relevant
(define (show-version)
(format #t "compile (GNU Guile) ~A~%" (version))
- (format #t "Copyright (C) 2009 Free Software Foundation, Inc.
+ (format #t "Copyright (C) 2009, 2011 Free Software Foundation, Inc.
License LGPLv3+: GNU LGPL version 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.~%"))
(cons #:O o)
o)))
(from (or (assoc-ref options 'from) 'scheme))
- (to (or (assoc-ref options 'to) 'objcode))
+ (to (or (assoc-ref options 'to) 'bytecode))
+ (target (or (assoc-ref options 'target) %host-type))
(input-files (assoc-ref options 'input-files))
(output-file (assoc-ref options 'output-file))
(load-path (assoc-ref options 'load-path)))
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'
+ -t, --to=LANG specify a target language other than `bytecode'
+ -T, --target=TRIPLET produce bytecode for host TRIPLET
-Note that autocompilation will be turned off.
+Note that auto-compilation will be turned off.
Report bugs to <~A>.~%"
%guile-bug-report-address)
(exit 0)))
(set! %load-path (append load-path %load-path))
- (set! %load-should-autocompile #f)
+ (set! %load-should-auto-compile #f)
(if (and output-file
(or (null? input-files)
(fail "`-o' option can only be specified "
"when compiling a single file"))
+ ;; Install a SIGINT handler. As a side effect, this gives unwind
+ ;; handlers an opportunity to run upon SIGINT; this includes that of
+ ;; 'call-with-output-file/atomic', called by 'compile-file', which
+ ;; removes the temporary output file.
+ (sigaction SIGINT
+ (lambda args
+ (fail "interrupted by the user")))
+
(for-each (lambda (file)
(format #t "wrote `~A'\n"
- (compile-file file
- #:output-file output-file
- #:from from
- #:to to
- #:opts compile-opts)))
+ (with-fluids ((*current-warning-prefix* ""))
+ (with-target target
+ (lambda ()
+ (compile-file file
+ #:output-file output-file
+ #:from from
+ #:to to
+ #:opts compile-opts))))))
input-files)))
(define main compile)
-
-;;; Local Variables:
-;;; coding: latin-1
-;;; End: