From c411f67a2cd2afef1ff81f2fb0824c1ec473517a Mon Sep 17 00:00:00 2001 From: jottbee Date: Tue, 15 Feb 2005 18:54:47 +0000 Subject: [PATCH] make-is-out-of-date? is more readable now; small improvement target-mtime doesn't need to be checked for each prereq. --- templates.scm | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/templates.scm b/templates.scm index da15584..75e615e 100644 --- a/templates.scm +++ b/templates.scm @@ -6,7 +6,7 @@ (let ((cooked-state (last args)) (prereqs-results (cdr (reverse (cdr args))))) (cons (begin - (display ";;; rule : ") + (display ";;; file : ") (display target) (newline) (bind-fluids-gnu target prereqs prereqs-results thunk)) @@ -61,18 +61,22 @@ (cons (file-not-exists? target) init-state)))) (define (make-is-out-of-date? target . prereqs) - (lambda args + (lambda args ; (breakpoint "make-is-out-of-date?") (let ((init-state (last args))) - (cons (or (file-not-exists? target) - (and (not (null? prereqs)) - (let for-each-prereq ((prereq (car prereqs)) - (todo (cdr prereqs))) - (cond - ((file-not-exists? prereq) #t) - ((> (file-last-mod prereq) (file-last-mod target)) #t) - ((null? todo) #f) - (else (for-each-prereq (car todo) (cdr todo))))))) + (cons (if (file-not-exists? target) + #t + (if (null? prereqs) + #f + (let ((target-mtime (file-last-mod target))) + (let for-each-prereq ((prereq (car prereqs)) + (todo (cdr prereqs))) + (cond + ((file-not-exists? prereq) + (error "nonexistent prerequisite" prereq)) + ((> (file-last-mod prereq) target-mtime) #t) + ((null? todo) #f) + (else (for-each-prereq (car todo) (cdr todo)))))))) init-state)))) (define (make-md5-sum-changed? target . prereqs) @@ -86,13 +90,13 @@ (let* ((bname (string-append basename extension)) (file (expand-file-name bname (cwd)))) (if (file-exists? file) - (let* ((outport (open-input-file file)) - (strls (port->string-list outport))) - ;; (display ";;; using : ") (display bname) (newline) - (if (null? strls) - #f - (string->number (car strls)))) - #f))) + (let* ((outport (open-input-file file)) + (strls (port->string-list outport))) + ;; (display ";;; using : ") (display bname) (newline) + (if (null? strls) + #f + (string->number (car strls)))) + #f))) (define (checksum-into-file basename extension checksum) (let* ((bname (string-append basename extension))