(zilch lang ninja nixpkgs): don't choke on non-UTF-8 files

Change-Id: I7d3472c0492104574cc4b7264ab1ceaf6a6a6964
This commit is contained in:
puck 2025-11-24 18:37:10 +00:00
parent 99bb57a4ed
commit 48e8cd9455

View file

@ -377,6 +377,8 @@
rewrites)) rewrites))
(make-finalized-drv store-paths export-depfile secondary-roots conf)) (make-finalized-drv store-paths export-depfile secondary-roots conf))
(define marker-header (string->utf8 "ZILCH MARKER FILE ->"))
;; Build the derivation, but with stubbed out header and .so files. ;; Build the derivation, but with stubbed out header and .so files.
;; This is used to determine the dataflow, to make cross-project incremental ;; This is used to determine the dataflow, to make cross-project incremental
;; builds work. ;; builds work.
@ -469,8 +471,8 @@
(define (get-file-marker fptr) (define (get-file-marker fptr)
(call-with-port (store-path-open fptr) (call-with-port (store-path-open fptr)
(lambda (p) (lambda (p)
(define header (read-string 20 p)) (define header (read-bytevector 20 p))
(and (string=? header "ZILCH MARKER FILE ->") (and (equal? header marker-header)
(let ((str (read-string 99999 p))) (let ((str (read-string 99999 p)))
(string-copy str 0 (- (string-length str) 1))))))) (string-copy str 0 (- (string-length str) 1)))))))
(define output (mapping (make-default-comparator))) (define output (mapping (make-default-comparator)))
@ -489,5 +491,3 @@
(vfs-contents vfs))) (vfs-contents vfs)))
(for-each process-output patched-drv) (for-each process-output patched-drv)
output))) output)))
; TODO(puck): for each output, do the necessary dance of figuring out where it came from. read first N bytes, compare, then do the thing. output a big alist and do the dataflow dance?