gnu: python-deepmerge: Use pyproject-build-system.
[jackhill/guix/guix.git] / gnu / packages / vlang.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2020 Ryan Prior <rprior@protonmail.com>
3 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
4 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2021 (unmatched parenthesis <paren@disroot.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages vlang)
23 #:use-module (gnu packages glib)
24 #:use-module (gnu packages node)
25 #:use-module (gnu packages sqlite)
26 #:use-module (gnu packages tls)
27 #:use-module (gnu packages version-control)
28 #:use-module (gnu packages xorg)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix git-download)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix utils)
33 #:use-module (guix packages))
34
35 (define-public vlang
36 (package
37 (name "vlang")
38 (version "0.2.4")
39 (source
40 (origin
41 (method git-fetch)
42 (uri (git-reference
43 (url "https://github.com/vlang/v")
44 (commit version)))
45 (file-name (git-file-name name version))
46 (sha256
47 (base32 "17wmjxssmg6kd4j8i6pgib452zzwvkyi3n1znd1jj3xkf2l92fw8"))))
48 (build-system gnu-build-system)
49 (arguments
50 `(#:make-flags
51 (list (string-append "CC=" ,(cc-for-target))
52 "TMPTCC=tcc"
53 (string-append "VC=" (assoc-ref %build-inputs "vc"))
54 "GITCLEANPULL=true"
55 "GITFASTCLONE=mkdir -p"
56 "TCCREPO="
57 "VCREPO="
58 (string-append "VFLAGS=-cc " ,(cc-for-target))
59 "VERBOSE=1")
60 #:phases
61 (modify-phases %standard-phases
62 (delete 'configure)
63 (add-before 'build 'change-home
64 (lambda _
65 (setenv "HOME" "/tmp")
66 #t))
67 (add-before 'build 'patch-makefile
68 (lambda _
69 (substitute* "Makefile"
70 (("--branch thirdparty-unknown-unknown") "")
71 (("rm -rf") "true"))
72 #t))
73 (add-before 'check 'delete-failing-tests
74 ;; XXX As always, these should eventually be fixed and run.
75 (lambda _
76 (for-each delete-file
77 '("vlib/os/notify/notify_test.v"
78 "vlib/v/doc/doc_private_fn_test.v"
79 "vlib/v/live/live_test.v"
80 "vlib/v/tests/repl/repl_test.v"
81 "vlib/v/tests/valgrind/valgrind_test.v"))
82 #t))
83 (replace 'check
84 (lambda* (#:key tests? #:allow-other-keys)
85 (let* ((bin "tmp/bin")
86 (gcc (which "gcc")))
87 (when tests?
88 (mkdir-p bin)
89 (symlink gcc (string-append bin "/cc"))
90 (setenv "PATH" (string-append bin ":" (getenv "PATH")))
91 (invoke "./v" "test-self")))
92 #t))
93 (replace 'install
94 (lambda* (#:key outputs #:allow-other-keys)
95 (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
96 (docs (string-append bin "/cmd/v/help"))
97 (tools (string-append bin "/cmd/tools"))
98 (thirdparty (string-append bin "/thirdparty"))
99 (vlib (string-append bin "/vlib"))
100 (vmod (string-append bin "/v.mod")))
101 (mkdir-p bin)
102 (copy-file "./v" (string-append bin "/v"))
103 ;; v requires as of 0.2.4 that these other components are in the
104 ;; same directory. In a future release we may be able to move
105 ;; these into other output folders.
106 (copy-recursively "cmd/tools" tools)
107 (copy-recursively "cmd/v/help" docs)
108 (copy-recursively "thirdparty" thirdparty)
109 (copy-recursively "vlib" vlib)
110 (copy-file "v.mod" vmod))
111 #t)))))
112 (inputs
113 (list glib))
114 (native-inputs
115 `(("vc"
116 ;; Versions are not consistently tagged, but the matching commit will
117 ;; probably have ‘v0.x.y’ in the commit message.
118 ,(let ((vc-version "5e876c1491db50b136499d3397b57b7c062040e5"))
119 ;; v bootstraps from generated c source code from a dedicated
120 ;; repository. It's readable, as generated source goes, and not at all
121 ;; obfuscated, and it's about 15kb. The original source written in
122 ;; golang is lost to the forces of entropy; modifying the generated c
123 ;; source by hand has been a commonly used technique for iterating on
124 ;; the codebase.
125 (origin
126 (method git-fetch)
127 (uri (git-reference
128 (url "https://github.com/vlang/vc")
129 (commit vc-version)))
130 (file-name (git-file-name "vc" vc-version))
131 (sha256
132 (base32 "1gxdkgc7aqw5f0fhch1n6nhzgzvgb49p77idx1zj7wcp53lpx5ng")))))
133 ("git" ,git-minimal)
134 ;; For the tests.
135 ("libx11" ,libx11)
136 ("node" ,node)
137 ("openssl" ,openssl)
138 ("sqlite" ,sqlite)))
139 (home-page "https://vlang.io/")
140 (synopsis "Compiler for the V programming language")
141 (description
142 "V is a systems programming language. It provides memory safety and thread
143 safety guarantees with minimal abstraction.")
144 (license license:expat)))