chiark / gitweb /
lib/keyword.c (kw_parseempty): Use correct variable scanning `kwval' list.
[sod] / src / frontend.lisp
index 1d0938250cc9f4726f3aa155ef11b7c44302be05..a00a8bbbb35dc4c34e3a14561406a0f9acfe9a17 100644 (file)
 ;;; along with SOD; if not, write to the Free Software Foundation,
 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 ;;; along with SOD; if not, write to the Free Software Foundation,
 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-(cl:defpackage #:sod-frontend
-  (:use #:common-lisp #:sod-utilities #:optparse #:sod #:sod-parser)
-  (:shadowing-import-from #:optparse #:int))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (handler-bind ((warning #'muffle-warning))
+    (cl:defpackage #:sod-frontend
+      (:use #:common-lisp #:sod-utilities #:optparse #:sod #:sod-parser))))
 
 (cl:in-package #:sod-frontend)
 
 
 (cl:in-package #:sod-frontend)
 
-;;;--------------------------------------------------------------------------
-;;; Preparation for dumping.
-
-(clear-the-decks)
-(exercise)
-
 ;;;--------------------------------------------------------------------------
 ;;; The main program.
 
 ;;;--------------------------------------------------------------------------
 ;;; The main program.
 
@@ -98,6 +93,7 @@ (defun main ()
        (backtracep nil)
        (builtinsp nil)
        (stdoutp nil)
        (backtracep nil)
        (builtinsp nil)
        (stdoutp nil)
+       (track-deps-p nil)
        (args nil))
 
     ;; Option definitions.
        (args nil))
 
     ;; Option definitions.
@@ -123,8 +119,12 @@     (define-program
                     ("Evaluate raw Lisp code.")
                     (lambda (lisp)
                       (handler-case
                     ("Evaluate raw Lisp code.")
                     (lambda (lisp)
                       (handler-case
-                          (let ((*package* (find-package "SOD-USER")))
-                            (eval (read-from-string lisp)))
+                          (let ((*package* (find-package "SOD-USER"))
+                                (token (cons 'token nil)))
+                            (with-input-from-string (in lisp)
+                              (loop (let ((form (read in nil token)))
+                                      (when (eq form token) (return))
+                                      (eval form)))))
                         (error (error)
                           (option-parse-error "~A" error)))))
                (#\l "load" (:arg "FILE")
                         (error (error)
                           (option-parse-error "~A" error)))))
                (#\l "load" (:arg "FILE")
@@ -145,6 +145,9 @@     (define-program
                                                  :print nil))))
                           (error (error)
                             (option-parse-error "~A" error))))))
                                                  :print nil))))
                           (error (error)
                             (option-parse-error "~A" error))))))
+               (#\M "track-dependencies"
+                    "Write make(1) fragments recording dependencies."
+                    (set track-deps-p))
                (#\p "stdout"
                     ("Write output files to standard output.")
                     (set stdoutp))
                (#\p "stdout"
                     ("Write output files to standard output.")
                     (set stdoutp))
@@ -190,7 +193,11 @@     (define-program
                             :direction :output
                             :if-exists :supersede
                             :if-does-not-exist :create)
                             :direction :output
                             :if-exists :supersede
                             :if-does-not-exist :create)
-                         (output-module module reason stream))))
+                         (output-module module reason stream))
+
+                       (when track-deps-p
+                         (write-dependency-file module reason
+                                                output-path))))
 
                   ;; Error recovery.
                   (continue ()
 
                   ;; Error recovery.
                   (continue ()
@@ -229,6 +236,6 @@     (define-program
                                      ~[~:; ~:*~D error~:P~[~:; and~]~:*~]~
                                      ~[~:; ~:*~D warning~:P~]~%"
                      *program-name* nerror nwarn))
                                      ~[~:; ~:*~D error~:P~[~:; and~]~:*~]~
                                      ~[~:; ~:*~D warning~:P~]~%"
                      *program-name* nerror nwarn))
-           (exit (if (plusp nerror) 2 0)))))))
+           (uiop:quit (if (plusp nerror) 2 0)))))))
 
 ;;;----- That's all, folks --------------------------------------------------
 
 ;;;----- That's all, folks --------------------------------------------------