added automatic variables in (currently only) gnu style.

added switch between make-rule-cml (file make-rule) and make-rule-no-cml
This commit is contained in:
jottbee 2005-02-15 18:59:37 +00:00
parent c411f67a2c
commit 62be1f7142
2 changed files with 222 additions and 19 deletions

160
autovars.scm Normal file
View File

@ -0,0 +1,160 @@
(define fluid-$@ (make-preserved-thread-fluid (list)))
(define fluid-$< (make-preserved-thread-fluid (list)))
(define fluid-$? (make-preserved-thread-fluid (list)))
(define fluid-$^ (make-preserved-thread-fluid (list)))
(define fluid-$+ (make-preserved-thread-fluid (list)))
(define fluid-$* (make-preserved-thread-fluid (list)))
(define fluid-$@/ (make-preserved-thread-fluid (list)))
(define fluid-/$@ (make-preserved-thread-fluid (list)))
(define fluid-$*/ (make-preserved-thread-fluid (list)))
(define fluid-/$* (make-preserved-thread-fluid (list)))
(define fluid-$</ (make-preserved-thread-fluid (list)))
(define fluid-/$< (make-preserved-thread-fluid (list)))
(define fluid-$^/ (make-preserved-thread-fluid (list)))
(define fluid-/$^ (make-preserved-thread-fluid (list)))
(define fluid-$+/ (make-preserved-thread-fluid (list)))
(define fluid-/$+ (make-preserved-thread-fluid (list)))
(define fluid-$?/ (make-preserved-thread-fluid (list)))
(define fluid-/$? (make-preserved-thread-fluid (list)))
(define (bind-fluids-gnu target prereqs prereqs-results thunk)
(let (($@ target)
($< (cond
((and (list? prereqs) (not (null? prereqs))) (car prereqs))
((and (list? prereqs) (null? prereqs)) "")
(else prereqs)))
($? (cond
((not (list? prereqs))
(let ((newer-prereq (list)))
(if (car (rule-result-wants-build?
(car prereqs-results)))
(cons newer-prereq newer-prereq)
newer-prereq)))
((and (list? prereqs) (null? prereqs)) prereqs)
((list? prereqs)
(let for-prereqs ((newer-prereqs (list))
(current-prereq (car prereqs))
(todo-prereqs (cdr prereqs))
(current-result (car prereqs-results))
(todo-results (cdr prereqs-results)))
(let ((build? (if (is-rule-result? current-result)
(car (rule-result-wants-build?
current-result))
#f)))
(if build?
(if (not (null? todo-prereqs))
(for-prereqs (cons current-prereq
newer-prereqs)
(car todo-prereqs)
(cdr todo-prereqs)
(car todo-results)
(cdr todo-results))
newer-prereqs)
(if (not (null? todo-prereqs))
(for-prereqs newer-prereqs
(car todo-prereqs)
(cdr todo-prereqs)
(car todo-results)
(cdr todo-results))
newer-prereqs)))))
(else (error "no match in bind-fluids-gnu fluid-$?"))))
($^ (delete-duplicates! prereqs))
($+ prereqs)
($* ""))
(let-thread-fluids fluid-$@ $@ ;; $@ : file name of the target
;; $% : target member name, when target is an archive member.
;; fluid-$% target
;; $< : name of the first prerequisite
fluid-$< $<
;; $? : names of all prerequisites that are newer than target
fluid-$? $?
;; $^ : names of all the prerequisites without duplicates
;; $+ : names of all the prerequisites
fluid-$^ $^
fluid-$+ $+
;; $* : The stem with which an implicit rule matches.
fluid-$* $*
;; we have no parens so we will use the following *scheme*:
;; e.g. for $@: $@/ denotes directory part of $@
;; while /$@ denotes file within directory of $@
;;
;; $(@D), $(@F) : directory part and file-within-directory
fluid-$@/ (file-name-directory $@)
fluid-/$@ (file-name-nondirectory $@)
;; $(*D), $(*F) : directory part and file-within-directory
fluid-$*/ (file-name-directory $*)
fluid-/$* (file-name-nondirectory $*)
;; $(%D), $(%F) : directory part and file-within-directory
; $%/ (file-name-directory fluid-$%)
; /$% (file-name-nondirectory fluid-$%)
;; $(<D), $(<F) : directory part and file-within-directory
fluid-$</ (file-name-directory $<)
fluid-/$< (file-name-nondirectory $<)
;; $(^D), $(^F) : directory part and file-within-directory
fluid-$^/ (map (lambda (d)
(file-name-directory d))
$^)
fluid-/$^ (map (lambda (f)
(file-name-nondirectory f))
$^)
;; $(+D), $(+F) : directory part and file-within-directory
fluid-$+/ (map (lambda (d)
(file-name-directory d))
$+)
fluid-/$+ (map (lambda (f)
(file-name-nondirectory f))
$+)
;; $(?D), $(?F) : directory part and the
;; file-within-directory part of $?.
fluid-$?/ (map (lambda (d)
(file-name-directory d))
$?)
fluid-/$? (map (lambda (f)
(file-name-nondirectory f))
$?)
thunk)))
(define ($@) (thread-fluid fluid-$@))
(define ($<) (thread-fluid fluid-$<))
(define ($?) (thread-fluid fluid-$?))
(define ($^) (thread-fluid fluid-$^))
(define ($+) (thread-fluid fluid-$+))
(define ($*) (thread-fluid fluid-$*))
(define ($@/) (thread-fluid fluid-$@/))
(define (/$@) (thread-fluid fluid-/$@))
(define ($*/) (thread-fluid fluid-$*/))
(define (/$*) (thread-fluid fluid-/$*))
(define ($</) (thread-fluid fluid-$</))
(define (/$<) (thread-fluid fluid-/$<))
(define ($^/) (thread-fluid fluid-$^/))
(define (/$^) (thread-fluid fluid-/$^))
(define ($+/) (thread-fluid fluid-$+/))
(define (/$+) (thread-fluid fluid-/$+))
(define ($?/) (thread-fluid fluid-$?/))
(define (/$?) (thread-fluid fluid-/$?))
(define (bind-fluids-human target prereqs prereqs-results thunk)
(display "not yet implemented."))
;;; (define (bind-fluids-human target prereqs prereqs-results thunk)
;;; (lambda ()
;;; (bind-fluids-gnu target prereqs prereqs-results
;;; (lambda ()
;;; (let ((target-fname (make-preserved-thread-fluid $@))
;;; (prereqs-first (make-preserved-thread-fluid $<))
;;; (prereqs-to-build (make-preserved-thread-fluid $?))
;;; (prereqs-unique (make-preserved-thread-fluid $^))
;;; (prereqs (make-preserved-thread-fluid $+)))
;;; (thunk))))))

View File

@ -140,7 +140,7 @@
rule-result-build-func
rule-make))
(define-structure make-rule make-rule-interface
(define-structure make-rule-cml make-rule-interface
(open scheme-with-scsh
locks
with-lock
@ -149,23 +149,12 @@
srfi-9
finite-types
collect-channels
dfs
(with-prefix rendezvous cml-rv/)
(with-prefix rendezvous-channels cml-sync-ch/))
(files make-rule))
(define-interface make-rule-no-cml-interface
(export make-rule
is-rule?
make-empty-rule-set
rule-set-add
is-rule-set?
make-rule-result
is-rule-result?
rule-result-wants-build?
rule-result-build-func
rule-make))
(define-structure make-rule-no-cml make-rule-no-cml-interface
(define-structure make-rule-no-cml make-rule-interface
(open scheme-with-scsh
locks
with-lock
@ -175,22 +164,23 @@
(define-interface macros-interface
(export (makefile :syntax)
(rule :syntax)
(file :syntax)
(makefile-rule :syntax)
(is-out-of-date? :syntax)
(md5 :syntax)
(rule-md5 :syntax)
(file-md5 :syntax)
(phony :syntax)
(always :syntax)
(is-out-of-date! :syntax)
(once :syntax)
(rule-once :syntax)))
(file-once :syntax)))
(define-structure macros macros-interface
(open scheme-with-scsh
srfi-1
to-rule-set
dfs
autovars
templates
make-rule)
(files macros))
@ -215,8 +205,9 @@
(define-interface dfs-interface
(export make-dfs
dfs->list
dfs
dfs-dag-show
dfs))
sort))
(define-structure dfs dfs-interface
(open scheme-with-scsh
@ -238,7 +229,7 @@
(files misc))
(define-interface templates-interface
(export make-rule-build-func
(export make-file-build-func
make-md5-build-func
make-always-build-func
make-once-build-func
@ -249,10 +240,60 @@
(define-structure templates templates-interface
(open scheme-with-scsh
autovars
srfi-1
big-util
srfi-13)
(files templates))
(define-interface autovars-interface
(export bind-fluids-gnu
fluid-$@
fluid-$<
fluid-$?
fluid-$^
fluid-$+
fluid-$*
fluid-$@/
fluid-/$@
fluid-$*/
fluid-/$*
fluid-$</
fluid-/$<
fluid-$^/
fluid-/$^
fluid-$+/
fluid-/$+
fluid-$?/
fluid-/$?
$@
$<
$?
$^
$+
$*
$@/
/$@
$*/
/$*
$</
/$<
$^/
/$^
$+/
/$+
$?/
/$?
bind-fluids-human))
(define-structure autovars autovars-interface
(open scheme-with-scsh
make-rule
thread-fluids
srfi-1
srfi-13)
(files autovars))
(define-structure make (export make)
(open scheme-with-scsh
srfi-1
@ -261,3 +302,5 @@
to-rule-set
make-rule)
(files make))
(define make-rule make-rule-cml)