(zilch lang ninja build): support phony rules
This commit is contained in:
parent
355af66489
commit
7cdf45ef96
1 changed files with 20 additions and 8 deletions
|
|
@ -49,12 +49,19 @@
|
||||||
(define (append-file path)
|
(define (append-file path)
|
||||||
(define input-file (mapping-ref edges path (lambda () (mapping-ref/default edges (normalize-path path) #f))))
|
(define input-file (mapping-ref edges path (lambda () (mapping-ref/default edges (normalize-path path) #f))))
|
||||||
|
|
||||||
|
(cond
|
||||||
; if input-file is 'base, this is part of the base vfs; we don't filter that right now.
|
; if input-file is 'base, this is part of the base vfs; we don't filter that right now.
|
||||||
(unless (eq? input-file 'base)
|
((eq? input-file 'base) #f)
|
||||||
(if input-file
|
|
||||||
|
; Phony rule; pass through the inputs literally.
|
||||||
|
((and (pair? input-file) (eq? (car input-file) 'phony)) (for-each append-file (cdr input-file)))
|
||||||
|
|
||||||
; This file is produced by another build edge. Add it to our input vfs.
|
; This file is produced by another build edge. Add it to our input vfs.
|
||||||
|
(input-file
|
||||||
(let ((prev-copy-input-files copy-input-files))
|
(let ((prev-copy-input-files copy-input-files))
|
||||||
(set! copy-input-files #~,(string-append #$prev-copy-input-files "\n" "$COREUTILS/mkdir -p bdir/" relative-to-root "/$($COREUTILS/dirname " path "); $COREUTILS/cp -rf " #$(force input-file) " bdir/" relative-to-root "/" path))); (set! vfs (vfs-append-file vfs (normalize-path path) (force input-file)))
|
(set! copy-input-files #~,(string-append #$prev-copy-input-files "\n" "$COREUTILS/mkdir -p bdir/" relative-to-root "/$($COREUTILS/dirname " path "); $COREUTILS/cp -rf " #$(force input-file) " bdir/" relative-to-root "/" path))))
|
||||||
|
|
||||||
|
(else
|
||||||
(unless (string-prefix? "/nix/store" path)
|
(unless (string-prefix? "/nix/store" path)
|
||||||
(error "Path doesn't exist as build edge" path))))
|
(error "Path doesn't exist as build edge" path))))
|
||||||
|
|
||||||
|
|
@ -138,8 +145,13 @@
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (edge)
|
(lambda (edge)
|
||||||
(define processed (delay (derivation-for-edge environment vfs-store-path relative-to edges edge)))
|
(define processed (delay (derivation-for-edge environment vfs-store-path relative-to edges edge)))
|
||||||
|
(if (build-edge-resolved edge)
|
||||||
(for-each (lambda (v) (set! edges (mapping-set! edges v (delay #~,(string-append #$(force processed) "/" v)))))
|
(for-each (lambda (v) (set! edges (mapping-set! edges v (delay #~,(string-append #$(force processed) "/" v)))))
|
||||||
(append (build-edge-outputs edge) (build-edge-implicit-outputs edge))))
|
(append (build-edge-outputs edge) (build-edge-implicit-outputs edge)))
|
||||||
|
|
||||||
|
; This edge is phony; mark the edge as having its outputs.
|
||||||
|
(for-each (lambda (v) (set! edges (mapping-set! edges v (cons 'phony (build-edge-inputs edge)))))
|
||||||
|
(append (build-edge-outputs edge) (build-edge-implicit-outputs edge)))))
|
||||||
(build-file-build-edges file))
|
(build-file-build-edges file))
|
||||||
|
|
||||||
(define edge-ref (lambda (path) (force (mapping-ref/default edges path #f))))
|
(define edge-ref (lambda (path) (force (mapping-ref/default edges path #f))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue