Log in New API Help About

3.2 KB of Plain text
Created 4 months ago — expires in 245 days
https://dpaste.com/AJ68WXY8X
COPY TO CLIPBOARD SOFT WRAP RAW TEXT DUPLICATE DIFF
(define-module (zig)
  #:use-module (guix packages)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix build-system cmake)
  #:use-module (guix download)
  #:use-module (gnu packages)
  #:use-module (gnu packages llvm))

(define (llvm-uri component version)
  (string-append "https://github.com/llvm/llvm-project/releases/download"
                 "/llvmorg-" version "/" component "-" version ".src.tar.xz"))

(define* (llvm-subprojects-origin components version hash
                                  #:optional (patches '()))
  (origin
    (method url-fetch)
    (uri (llvm-uri "llvm-project" version))
    (sha256 (base32 hash))
    (patches (map search-patch patches))
    (modules '((guix build utils)
               (ice-9 ftw)))
    (snippet
     `(for-each
       (lambda (file)
         (unless (member file '("." ".." ,@components))
           (delete-file-recursively file)))
       (scandir ".")))))

(define-public lld-12
  (package
    (inherit lld)
    (version "12.0.0")
    (source (llvm-subprojects-origin '("lld" "libunwind") version
                                     "0a1n88dmbwp1ww7h3ykf0s001cndk1bm3i2cj1y2sh548f4nilcy"))
    (arguments
     `(,@(package-arguments lld)
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'dissect
           (lambda _
             ;; Find libunwind in unpacked sources
             (substitute* "lld/MachO/CMakeLists.txt"
               (("\\$\\{LLVM_MAIN_SRC_DIR\\}/\\.\\./libunwind")
                (string-append (getcwd) "/libunwind")))
             ;; chdir to actual source folder
             (chdir "lld"))))))
    (inputs
     `(("llvm" ,llvm-12)))))

(define-public zig
  (package
    (name "zig")
    (version "0.8.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/ziglang/zig.git")
             (commit version)))
       (file-name (git-file-name name version))
       (sha256
        (base32 "1a6rcxzlmmqiza4n9aphhs9ckf3g27v65laikxvgk37wlmqf70kc"))))
    (build-system cmake-build-system)
    (inputs
     `(("clang" ,clang-12)
       ("lld" ,lld-12)
       ("llvm" ,llvm-12)))
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'save-unpack-dir
           (lambda _
             ;; HACK: Passing unpacked source directory to 'check phase.
             (setenv "ZIG_UNPACK_DIR" (getcwd))
             #t))
         (add-after 'configure 'set-home
           (lambda _
             (setenv "HOME" (getcwd))    ; zig writes to $HOME/.cache
             #t))
         (delete 'check))))
    (synopsis "General purpose programming language and toolchain")
    (description "Zig is a general-purpose programming language and
toolchain.  Among other features it provides
@itemize
@item an Optional type instead of null pointers,
@item manual memory management,
@item generic data structures and functions,
@item compile-time reflection and compile-time code execution,
@item integration with C using zig as a C compiler, and
@item concurrency via async functions.
@end itemize")
    (home-page "https://github.com/ziglang/zig")
    (license license:expat)))

Share: