home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / compiler / etc / xcbfdir.scm < prev   
Text File  |  1999-01-02  |  3KB  |  76 lines

  1. #| -*-Scheme-*-
  2.  
  3. $Id: xcbfdir.scm,v 1.9 1999/01/02 06:06:43 cph Exp $
  4.  
  5. Copyright (c) 1989-1999 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. |#
  21.  
  22. ;;;; Distributed directory recompilation.
  23.  
  24. (declare (usual-integrations))
  25.  
  26. (define (process-directory directory processor extension)
  27.   (for-each
  28.    (lambda (pathname)
  29.      (let ((one (pathname-new-type pathname extension))
  30.        (two (pathname-new-type pathname "tch")))
  31.        (call-with-current-continuation
  32.     (lambda (here)
  33.       (bind-condition-handler (list condition-type:error)
  34.           (lambda (condition)
  35.         (let ((port (current-output-port)))
  36.           (newline port)
  37.           (write-string ";; *** Aborting " port)
  38.           (display pathname port)
  39.           (write-string " ***" port)
  40.           (newline port)
  41.           (write-condition-report condition port)
  42.           (newline port))
  43.         (here 'next))
  44.         (lambda ()
  45.           (let ((touch-created-file? false))
  46.         (dynamic-wind
  47.          (lambda ()
  48.            ;; file-touch returns #T if the file did not exist,
  49.            ;; #F if it did.
  50.            (set! touch-created-file? (file-touch two))
  51.            unspecific)
  52.          (lambda ()
  53.            (if (and touch-created-file?
  54.                 (let ((one-time (file-modification-time one)))
  55.                   (or (not one-time)
  56.                   (< one-time
  57.                      (file-modification-time pathname)))))
  58.                (processor pathname
  59.                   (pathname-new-type pathname extension))))
  60.          (lambda ()
  61.            (if touch-created-file?
  62.                (delete-file two)))))))))))
  63.    (directory-read
  64.     (merge-pathnames (pathname-as-directory (->pathname directory))
  65.              (->pathname "*.bin")))))
  66.  
  67. (define (recompile-directory dir)
  68.   (let ((extn
  69.      (if (access compiler:cross-compiling?
  70.              (->environment '(compiler)))
  71.          "moc"
  72.          "com")))
  73.     (process-directory dir compile-bin-file extn)))
  74.  
  75. (define (cross-compile-directory dir)
  76.   (process-directory dir cross-compile-bin-file "moc"))