hako pushed a commit to branch wip-zig-bootstrap
in repository guix.
commit 69f25668fd515ef15d147c93cd9c22928bc41a3f
Author: Hilton Chain <[email protected]>
AuthorDate: Mon Dec 30 22:10:22 2024 +0800
squash! build-system: zig: Support Zig package manager.
Change-Id: I771fc79f6eda795799049e4d506932605ce7dba1
---
guix/build/zig-build-system.scm | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/guix/build/zig-build-system.scm b/guix/build/zig-build-system.scm
index e33911da42..60e0935282 100644
--- a/guix/build/zig-build-system.scm
+++ b/guix/build/zig-build-system.scm
@@ -76,16 +76,17 @@
;; 3. Recursive dependency is possible
;; `build.zig.zon' -> dependency (`build.zig.zon' -> next dependency).
;;
-;; With our naming convention and different expectation package sources, we'll
-;; need to change dependency names and hashes for nearly every Zig package.
+;; With our naming convention and different expectation on package sources,
+;; we'll need to change dependency names and hashes for nearly every Zig
+;; package.
;; - `rename-zig-dependencies' in `(gnu packages zig)' takes care of names.
;; - `unpack-dependencies' below is for hashes. Ideally we can parse
;; `build.zig.zon' and only `zig fetch' required dependencies for current
;; package, this way recursive dependencies are resolved by fetching store
paths
-;; in their URLs. However Zig package manager currently doesn't support file
-;; URLs[0] so we are fetching all dependencies needed for the build process and
-;; they are added to all involved `build.zig.zon' as a side effect.
-;;
+;; defined in dependency URLs. However Zig package manager currently doesn't
+;; support file URLs[0] so we are instead fetching all dependencies needed for
+;; the build process and all of them are added to involved `build.zig.zon' as a
+;; side effect.
;; [0]: https://github.com/ziglang/zig/pull/21931
(define (unpack-dependencies . _)
"Unpack Zig dependencies from GUIX_ZIG_PACKAGE_PATH."
@@ -111,18 +112,20 @@
(drop-right name+version (if guix-revision? 2 1))
"-")))
(for-each
- (lambda (build.zig)
- (with-directory-excursion (dirname build.zig)
- (for-each
- (match-lambda
- ((input-name . input-path)
- (let ((call `("zig" "fetch"
- ,(zig-input-install-path input-path)
- ,(string-append "--save=" (strip-version
input-name)))))
- (format #t "running: ~s~%" call)
- (apply invoke call))))
- (reverse zig-inputs))))
- (find-files "." "^build\\.zig$")))
+ (lambda (build.zig.zon)
+ (format #t "unpacking dependencies for ~s...~%" build.zig.zon)
+ (with-directory-excursion (dirname build.zig.zon)
+ (false-if-exception
+ (for-each
+ (match-lambda
+ ((input-name . input-path)
+ (let ((call `("zig" "fetch"
+ ,(zig-input-install-path input-path)
+ ,(string-append "--save=" (strip-version
input-name)))))
+ (format #t "running: ~s~%" call)
+ (apply invoke call))))
+ (reverse zig-inputs)))))
+ (find-files "." "^build\\.zig\\.zon$")))
(define* (build #:key
zig-build-flags