diff options
author | Hilton Chain <hako@ultrarare.space> | 2024-11-20 08:00:54 +0800 |
---|---|---|
committer | Hilton Chain <hako@ultrarare.space> | 2024-12-31 10:56:34 +0800 |
commit | bdff1941e51193437dbcefad80d019fd9d5d0aa9 (patch) | |
tree | d229690dfa81d125ac2a33ab1acfd2e6568b0e15 | |
parent | 5ce59e0413510098f92e4b824d2a24b97ad2e4c9 (diff) |
gnu: zig: Default to zig-0.13.
* guix/build-system/zig.scm (#:parallel-build?,#:parallel-tests?):
New arguments.
* guix/build/zig-build-system.scm (zig-arguments): New procedure.
(bulid): Use it and honor #:parallel-build?.
(check): Use it and honor #:parallel-tests?.
* gnu/packages/zig.scm (zig): Define as zig-0.13.
* gnu/packages/ncdu.scm (ncdu)[arguments]<#:zig>: Unset.
<#:zig-release-type>: Set to "safe".
<#:zig-build-flags>: Add "-Dpie".
* gnu/packages/zig-xyz.scm (river)[arguments]<#:zig>: Use zig-0.10.
(zig-zls)[arguments]<#:zig>: Use zig-0.10.
<#:zig-release-type>: Set to "safe".
Change-Id: I1f0087ff39ea9fecb2ad911019d0525f1e6285f6
-rw-r--r-- | gnu/packages/ncdu.scm | 6 | ||||
-rw-r--r-- | gnu/packages/zig-xyz.scm | 5 | ||||
-rw-r--r-- | gnu/packages/zig.scm | 2 | ||||
-rw-r--r-- | guix/build-system/zig.scm | 8 | ||||
-rw-r--r-- | guix/build/zig-build-system.scm | 65 |
5 files changed, 70 insertions, 16 deletions
diff --git a/gnu/packages/ncdu.scm b/gnu/packages/ncdu.scm index c49fefc077e..bbbb2fea26f 100644 --- a/gnu/packages/ncdu.scm +++ b/gnu/packages/ncdu.scm @@ -72,8 +72,10 @@ ncurses installed.") "01g5mpvsm78lkd0yin82gyancrl23npy69qcp3d60vmm72yiwirz")))) (build-system zig-build-system) (arguments - (list #:zig zig-0.12 - #:install-source? #f)) + (list #:install-source? #f + #:zig-release-type "safe" + #:zig-build-flags + #~(list "-Dpie"))) (inputs (list ncurses `(,zstd "lib"))) (native-inputs (list pkg-config)) (properties `((tunable? . #t))))) diff --git a/gnu/packages/zig-xyz.scm b/gnu/packages/zig-xyz.scm index 9c86dde5560..e504e50e237 100644 --- a/gnu/packages/zig-xyz.scm +++ b/gnu/packages/zig-xyz.scm @@ -53,6 +53,7 @@ (build-system zig-build-system) (arguments (list + #:zig zig-0.10 #:install-source? #f #:phases #~(modify-phases %standard-phases @@ -124,7 +125,9 @@ mission-critical safety and performance for financial services.") (build-system zig-build-system) (inputs (list zig-0.10 python)) (arguments - (list #:install-source? #f + (list #:zig zig-0.10 + #:install-source? #f + #:zig-release-type "safe" ;; The tests fail with memory leaks. #:tests? #f)) (synopsis "Zig language server") diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm index 2644516e696..13c8fa421ed 100644 --- a/gnu/packages/zig.scm +++ b/gnu/packages/zig.scm @@ -1639,4 +1639,4 @@ toolchain. Among other features it provides (properties `((max-silent-time . 9600) ,@(clang-compiler-cpu-architectures "18"))))) -(define-public zig zig-0.10) +(define-public zig zig-0.13) diff --git a/guix/build-system/zig.scm b/guix/build-system/zig.scm index 6d16303794c..43d6ee977c3 100644 --- a/guix/build-system/zig.scm +++ b/guix/build-system/zig.scm @@ -48,6 +48,8 @@ source (tests? #t) (test-target #f) + (parallel-build? #t) + (parallel-tests? #t) (install-source? #t) (skip-build? #f) (zig-build-flags ''()) @@ -70,6 +72,8 @@ #:source #+source #:system #$system #:test-target #$test-target + #:parallel-build? #$parallel-build? + #:parallel-tests? #$parallel-tests? #:install-source? #$install-source? #:skip-build? #$skip-build? #:zig-build-flags #$zig-build-flags @@ -102,6 +106,8 @@ (native-search-paths '()) (tests? #t) (test-target #f) + (parallel-build? #t) + (parallel-tests? #t) (install-source? #t) (skip-build? #f) (zig-build-flags ''()) @@ -140,6 +146,8 @@ #:outputs %outputs #:target #$target #:test-target #$test-target + #:parallel-build? #$parallel-build? + #:parallel-tests? #$parallel-tests? #:inputs %build-target-inputs #:native-inputs %build-host-inputs #:search-paths '#$(map search-path-specification->sexp diff --git a/guix/build/zig-build-system.scm b/guix/build/zig-build-system.scm index f6928ad2531..b202c4bce23 100644 --- a/guix/build/zig-build-system.scm +++ b/guix/build/zig-build-system.scm @@ -41,6 +41,32 @@ (zig-source-install-path (dirname (dirname (dirname (canonicalize-path input)))))) +(define (zig-arguments) + (define version-major+minor + (let* ((port (open-input-pipe "zig version")) + (str (read-line port))) + (close-pipe port) + (take (string-split str #\.) 2))) + (define (version>=? a b-major b-minor) + (let ((a-major (string->number (first a))) + (a-minor (string->number (second a)))) + (or (> a-major b-major) + (and (= a-major b-major) + (>= a-minor b-minor))))) + `(("parallel-jobs" . + ,(lambda (jobs) + (cond + ((version>=? version-major+minor 0 11) + (list (string-append "-j" (number->string jobs)))) + (else '())))) + ("release-type" . + ,(lambda (type) + (cond + ((version>=? version-major+minor 0 11) + (list (string-append "--release=" type))) + (else + (list (string-append "-Drelease-" type)))))))) + ;; Notes on Zig package manager (`build.zig.zon') ;; 1. Dependency definition (name -> URL + hash) ;; - Dependency names are not necessarily consistent across packages. @@ -114,34 +140,49 @@ zig-build-target ;; "safe", "fast" or "small", empty for a "debug" build. zig-release-type + parallel-build? skip-build? #:allow-other-keys) "Build a given Zig package." (when (not skip-build?) (setenv "DESTDIR" "out") - (let ((call `("zig" "build" - "--prefix" "" ;; Don't add /usr - "--prefix-lib-dir" "lib" - "--prefix-exe-dir" "bin" - "--prefix-include-dir" "include" - ,(string-append "-Dtarget=" (zig-target zig-build-target)) - ,@(if zig-release-type - (list (string-append "-Drelease-" zig-release-type)) - '()) - ,@zig-build-flags))) + (let* ((arguments (zig-arguments)) + (call `("zig" "build" + "--prefix" "" ;; Don't add /usr + "--prefix-lib-dir" "lib" + "--prefix-exe-dir" "bin" + "--prefix-include-dir" "include" + ,(string-append "-Dtarget=" (zig-target zig-build-target)) + ,@(if parallel-build? + ((assoc-ref arguments "parallel-jobs") + (parallel-job-count)) + ((assoc-ref arguments "parallel-jobs") + 1)) + ,@(if zig-release-type + ((assoc-ref arguments "release-type") + zig-release-type) + '()) + ,@zig-build-flags))) (format #t "running: ~s~%" call) (apply invoke call)))) (define* (check #:key tests? zig-test-flags target + parallel-tests? #:allow-other-keys) "Run all the tests" (when (and tests? (not target)) (let ((old-destdir (getenv "DESTDIR"))) (setenv "DESTDIR" "test-out") ;; Avoid colisions with the build output - (let ((call `("zig" "build" "test" - ,@zig-test-flags))) + (let* ((arguments (zig-arguments)) + (call `("zig" "build" "test" + ,@(if parallel-tests? + ((assoc-ref arguments "parallel-jobs") + (parallel-job-count)) + ((assoc-ref arguments "parallel-jobs") + 1)) + ,@zig-test-flags))) (format #t "running: ~s~%" call) (apply invoke call)) (if old-destdir |