From ae774da04323c45a8f45d1e542c54c6a2598e8a1 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Mon, 23 Jun 2025 12:22:20 +0000 Subject: [PATCH] zilch-cli-rust: improve behavior slightly Change-Id: I6a6a69641ebf9fcf1e2d453a904db252a1cfe596 --- cli/zilch-rust.scm | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/cli/zilch-rust.scm b/cli/zilch-rust.scm index 71428ac..213f1cb 100644 --- a/cli/zilch-rust.scm +++ b/cli/zilch-rust.scm @@ -16,8 +16,6 @@ and output derivations for each target given on the command line (or all executables in the crate, if unspecified) -h, --help Print this help message. - -b, --build Build the store paths, rather than show their - derivations. -j, --max-jobs COUNT The maximum amount of builds to run. Defaults to the amount of cores. -v, --verbose Increase the verbosity configured in the Nix @@ -41,7 +39,6 @@ executables in the crate, if unspecified) (define-values (options args) (getopt '((help #f #\h) - (build #f #\b) (max-jobs #t #\j) (verbose #f #\v) (print-build-logs #f #\L) @@ -108,7 +105,7 @@ executables in the crate, if unspecified) (define (append-dir dirname vfs workspace) (define-values (parsed-cargo new-workspace) (parse-cargo-toml vfs (call-with-input-file (string-append dirname "/Cargo.toml") (lambda (p) (read-string 999999 p))) workspace)) - (when (and (not workspace) new-workspace) + (when (and (not parsed-cargo) (and (not workspace) new-workspace)) (set-print-logs #t) (fprintf (current-error-port) "Replaced directory ~S contains a Cargo workspace. This is unsupported.\n" dirname) (exit 1)) @@ -135,18 +132,6 @@ executables in the crate, if unspecified) (define output (process-many-with-lockfile projects lockfile)) -(define do-build (assoc 'build options)) - -(define (build-if-wanted path) - (store-path-materialize path) - (if do-build - (begin - (store-path-build path) - (store-path-realisation path)) - (if (string=? (store-path-output path) "out") - (derivation-path (store-path-drv path)) - (string-append (derivation-path (store-path-drv path)) "!" (store-path-output path))))) - (define build-script-overrides (mapping (make-default-comparator))) (define build-script-dependency-overrides (mapping (make-default-comparator))) (define rustc-overrides (mapping (make-default-comparator))) @@ -199,9 +184,8 @@ executables in the crate, if unspecified) (for-each (lambda (pkg) - (if (equal? 'bin (cargo-target-crate-type (resolved-package-cargo-target pkg))) - (if (should-skip pkg) - (printf "~A\t~A\t~A\tskipped\n" (cargo-crate-name (resolved-package-crate pkg)) (cargo-target-name (resolved-package-cargo-target pkg)) (cargo-target-crate-type (resolved-package-cargo-target pkg))) - (let ((built (build-package pkg build-script-env-overrides rustc-env-overrides))) (printf "~A\t~A\tbin\t~A\n" (cargo-crate-name (resolved-package-crate pkg)) (cargo-target-name (resolved-package-cargo-target pkg)) (build-if-wanted built)))) - (printf "~A\t~A\t~A\tnot a binary\n" (cargo-crate-name (resolved-package-crate pkg)) (cargo-target-name (resolved-package-cargo-target pkg)) (cargo-target-crate-type (resolved-package-cargo-target pkg))))) + (unless (should-skip pkg) + (if (equal? 'bin (cargo-target-crate-type (resolved-package-cargo-target pkg))) + (let ((built (build-package pkg build-script-env-overrides rustc-env-overrides))) (printf "~A\t~A\tbin\t~A\n" (cargo-crate-name (resolved-package-crate pkg)) (cargo-target-name (resolved-package-cargo-target pkg)) (store-path-realised built))) + (printf "~A\t~A\t~A\tnot a binary\n" (cargo-crate-name (resolved-package-crate pkg)) (cargo-target-name (resolved-package-cargo-target pkg)) (cargo-target-crate-type (resolved-package-cargo-target pkg)))))) output)