From 48e8cd9455e21efc2d99b48126a58f5b153841a8 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Mon, 24 Nov 2025 18:37:10 +0000 Subject: [PATCH] (zilch lang ninja nixpkgs): don't choke on non-UTF-8 files Change-Id: I7d3472c0492104574cc4b7264ab1ceaf6a6a6964 --- lang/ninja/src/nixpkgs.sld | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/ninja/src/nixpkgs.sld b/lang/ninja/src/nixpkgs.sld index 1c2510f..7c8fe92 100644 --- a/lang/ninja/src/nixpkgs.sld +++ b/lang/ninja/src/nixpkgs.sld @@ -377,6 +377,8 @@ rewrites)) (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. ;; This is used to determine the dataflow, to make cross-project incremental ;; builds work. @@ -469,8 +471,8 @@ (define (get-file-marker fptr) (call-with-port (store-path-open fptr) (lambda (p) - (define header (read-string 20 p)) - (and (string=? header "ZILCH MARKER FILE ->") + (define header (read-bytevector 20 p)) + (and (equal? header marker-header) (let ((str (read-string 99999 p))) (string-copy str 0 (- (string-length str) 1))))))) (define output (mapping (make-default-comparator))) @@ -489,5 +491,3 @@ (vfs-contents vfs))) (for-each process-output patched-drv) 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?