diff options
author | Hilton Chain <hako@ultrarare.space> | 2024-11-20 07:41:06 +0800 |
---|---|---|
committer | Hilton Chain <hako@ultrarare.space> | 2024-12-31 10:56:34 +0800 |
commit | 5ce59e0413510098f92e4b824d2a24b97ad2e4c9 (patch) | |
tree | c8b24010320c7a5ccb4c03c759f148b009e456c3 /gnu/packages/zig.scm | |
parent | 3ef8c9307ce10ca59af9bcf84161a88fd08310e7 (diff) |
build-system: zig: Support Zig package manager.
* guix/build-system/zig.scm (zig-build,zig-cross-build)
[#:install-source?,#:skip-build?]: New arguments.
[#:tests?]: Honor #:skip-build?.
* guix/build/zig-build-system.scm (zig-source-install-path)
(zig-input-install-path,unpack-dependencies): New procedures.
(%standard-phases): Add 'unpack-dependencies.
(build,install): Honor #:skip-build?.
* doc/guix.texi (Build Systems)[zig-build-system]: Update documentation.
* gnu/packages/zig.scm (zig-0.9)[native-search-paths]: Add
GUIX_ZIG_PACKAGE_PATH.
Use search paths defined in (guix search-paths).
(add-build.zig.zon,rename-zig-dependencies): New procedures.
* gnu/packages/ncdu.scm (ncdu)[arguments]: Don't install source.
* gnu/packages/zig-xyz.scm (river,tigerbeetle,zig-zls)[arguments]: Likewise.
Diffstat (limited to 'gnu/packages/zig.scm')
-rw-r--r-- | gnu/packages/zig.scm | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm index 99335c54048..2644516e696 100644 --- a/gnu/packages/zig.scm +++ b/gnu/packages/zig.scm @@ -24,6 +24,7 @@ #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix platform) + #:use-module (guix search-paths) #:use-module (guix utils) #:use-module (guix download) #:use-module (guix git-download) @@ -33,7 +34,51 @@ #:use-module (gnu packages compression) #:use-module (gnu packages llvm) #:use-module (gnu packages llvm-meta) - #:use-module (gnu packages web)) + #:use-module (gnu packages web) + #:export (add-build.zig.zon + rename-zig-dependencies)) + +(define* (add-build.zig.zon name version dependencies #:optional (paths '(""))) + "Snippet to generate build.zig.zon of DEPENDENCIES for package NAME@VERSION." + `(let ((port (open-file "build.zig.zon" "w" #:encoding "utf8"))) + (format port "\ +.{ + .name = \"~a\", + .version = \"~a\", + .paths = .{ +~{\ + \"~a\", +~}\ + }, + .dependencies = .{ +~{\ + .@\"~a\" = .{ + .url = \"\", + }, +~}\ + }, +}~%" ,name ,version (quote ,paths) (quote ,dependencies)) + (close-port port))) + +(define* (rename-zig-dependencies mapping #:optional (directories '("."))) + "Snippet to rename Zig dependencies in build.zig and build.zig.zon." + `(begin + (use-modules (ice-9 match) + (guix build utils)) + (for-each + (lambda (directory) + (for-each + (match-lambda + ((old-name . new-name) + (with-directory-excursion directory + (substitute* "build.zig" + (((string-append "([Dd]ependency.\")" old-name) _ prefix) + (string-append prefix new-name))) + (substitute* "build.zig.zon" + (((format #f "\\.(@\")?~a\"?" old-name)) + (format #f ".@\"~a\"" new-name)))))) + (quote ,mapping))) + (quote ,directories)))) (define (zig-source version commit hash) (origin @@ -169,16 +214,12 @@ (list llvm-13 zig-0.9-glibc-abi-tool)) (native-search-paths - (list - (search-path-specification - (variable "C_INCLUDE_PATH") - (files '("include"))) - (search-path-specification - (variable "CPLUS_INCLUDE_PATH") - (files '("include/c++" "include"))) - (search-path-specification - (variable "LIBRARY_PATH") - (files '("lib" "lib64"))))) + (list $C_INCLUDE_PATH + $CPLUS_INCLUDE_PATH + $LIBRARY_PATH + (search-path-specification + (variable "GUIX_ZIG_PACKAGE_PATH") + (files '("src/zig"))))) (synopsis "General purpose programming language and toolchain") (description "Zig is a general-purpose programming language and toolchain. Among other features it provides |