zilch-cli-ninja: make source' and diff' operate on rewrites
Change-Id: I6a6a69644e8984ec8400e13928c8ac0e14526ad1
This commit is contained in:
parent
cdee2291fb
commit
5485b0f4ce
2 changed files with 58 additions and 29 deletions
|
|
@ -54,7 +54,7 @@
|
|||
(define source (and (assoc 'source options) (cdr (assoc 'source options))))
|
||||
|
||||
(define config-path (if (assoc 'config-file options) (cdr (assoc 'config-file options)) "zilch.scm"))
|
||||
(define config (parse-ninja-config config-path `(override-source: ,(and source (vfs-from-directory source)) ,@(call-with-input-file config-path read))))
|
||||
(define config (parse-ninja-config config-path (string=? (car args) "build")`(override-source: ,(and source (vfs-from-directory source)) ,@(call-with-input-file config-path read))))
|
||||
|
||||
(when (and (ninja-build-config-depfile-path config) (file-exists? (ninja-build-config-depfile-path config)))
|
||||
(set-ninja-build-config-depfile! config (alist->mapping (make-default-comparator) (call-with-input-file (ninja-build-config-depfile-path config) read))))
|
||||
|
|
@ -75,14 +75,43 @@
|
|||
(else (loop (cdr rewrites)))))))
|
||||
options)
|
||||
|
||||
(define (do-diff config source-override is-root)
|
||||
(define-values (_ configured-drv _ _ _ _ _) (setup-ninja-environment config '()))
|
||||
(define path (or source-override (ninja-build-config-override-source-path config) (and is-root "src")))
|
||||
(define exit-status 0)
|
||||
(when path
|
||||
(let*-values
|
||||
(((pid) (process-run "git"
|
||||
(list "diff" "--no-index" "--"
|
||||
(string-append (store-path-realised configured-drv) "/src")
|
||||
path)))
|
||||
((pid normal-exit new-exit-status) (process-wait pid)))
|
||||
(unless normal-exit (exit #f))
|
||||
(set! exit-status (max exit-status new-exit-status))))
|
||||
(for-each
|
||||
(lambda (v)
|
||||
(set! exit-status
|
||||
(max exit-status
|
||||
(do-diff (cdr v) #f #f))))
|
||||
(ninja-build-config-rewrites config))
|
||||
exit-status)
|
||||
|
||||
(define (do-source config source-override is-root)
|
||||
(define-values (_ configured-drv _ _ _ _ _) (setup-ninja-environment config '()))
|
||||
(define path (or source-override (ninja-build-config-override-source-path config) (and is-root "src")))
|
||||
(when path
|
||||
(system* (string-append "cp -rf --no-preserve=ownership -T " (store-path-realised configured-drv) "/src " (qs path)))
|
||||
(system* (string-append "chmod -R u+rw " (qs path))))
|
||||
(for-each
|
||||
(lambda (v)
|
||||
(do-source (cdr v) #f #f))
|
||||
(ninja-build-config-rewrites config)))
|
||||
|
||||
(cond
|
||||
((string=? (car args) "source")
|
||||
(let*-values
|
||||
(((_ configured-drv _ _ _ _ _) (setup-ninja-environment config '()))
|
||||
((realised) (store-path-realised configured-drv))
|
||||
((path) (if (null? (cdr args)) "src" (cadr args))))
|
||||
(system* (string-append "cp -rf --no-preserve=ownership " realised "/src " (qs path)))
|
||||
(system* (string-append "chmod -R u+rw " (qs path)))))
|
||||
(do-source config (and (pair? (cdr args)) (cadr args)) #t))
|
||||
((string=? (car args) "diff")
|
||||
(exit (= (do-diff config source #t) 0)))
|
||||
((string=? (car args) "build")
|
||||
(if (null? (cdr args))
|
||||
(let ((output (build-nixpkgs-drv-reproducibly config)))
|
||||
|
|
@ -98,11 +127,5 @@
|
|||
(define built-target (edge-ref target))
|
||||
(printf "~A\t-> ~S\n" target (store-path-realised (force (built-edge-out-drv (cdr built-target))))))
|
||||
(cdr args)))))
|
||||
((string=? (car args) "diff")
|
||||
(let*-values
|
||||
(((_ configured-drv _ _ _ _ _) (setup-ninja-environment config '()))
|
||||
((realised) (store-path-realised configured-drv))
|
||||
((path) (or source "src")))
|
||||
(process-execute "git" (list "diff" "--no-index" "--" (string-append realised "/src") path))))
|
||||
(else
|
||||
(print-help (string-append "Unknown subcommand " (car args)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue