gnu: maven-shared-utils: Fix /bin/sh invocation.
[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 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages vlang)
20 #:use-module (gnu packages c)
21 #:use-module (gnu packages gcc)
22 #:use-module (gnu packages glib)
23 #:use-module (guix build-system gnu)
24 #:use-module (guix git-download)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix packages))
27
28 (define-public v
29 (package
30 (name "v")
31 (version "0.1.27")
32 (source
33 (origin
34 (method git-fetch)
35 (uri (git-reference
36 (url "https://github.com/vlang/v")
37 (commit version)))
38 (file-name (git-file-name name version))
39 (sha256
40 (base32 "1d9qhacllvkqif42jaayixhjyhx7pzslh8p1yr5p19447q763fq1"))))
41 (build-system gnu-build-system)
42 (arguments
43 '(#:tests? #f ; tests are broken in v 0.1.27
44 #:make-flags
45 `("CC=gcc"
46 "GITCLEANPULL=true"
47 "GITFASTCLONE=mkdir -p"
48 "TCCREPO="
49 "TMPTCC=tcc"
50 ,(string-append "TMPVC=" (assoc-ref %build-inputs "vc"))
51 "VCREPO="
52 "VERBOSE=1"
53 "V_ALWAYS_CLEAN_TMP=false")
54 #:phases
55 (modify-phases %standard-phases
56 (delete 'configure)
57 (add-before 'build 'patch-makefile
58 (lambda _
59 (substitute* "Makefile"
60 (("rm -rf") "true")
61 (("v self") "v -cc gcc cmd/v"))
62 #t))
63 ;; A few tests are broken in v 0.1.27. This function should be
64 ;; enabled to run tests in the next release.
65 ;; (replace 'check
66 ;; (lambda _
67 ;; (let* ((tmpbin "tmp/bin")
68 ;; (gcc (which "gcc")))
69 ;; (mkdir-p tmpbin)
70 ;; (symlink gcc (string-append tmpbin "/cc"))
71 ;; (setenv "PATH" (string-append tmpbin ":" (getenv "PATH")))
72 ;; (invoke "./v" "test-fixed"))
73 ;; #t))
74 (replace 'install
75 (lambda _
76 (let* ((bin (string-append (assoc-ref %outputs "out") "/bin"))
77 (tools (string-append bin "/cmd/tools"))
78 (thirdparty (string-append bin "/thirdparty"))
79 (vlib (string-append bin "/vlib"))
80 (vmod (string-append bin "/v.mod")))
81 (mkdir-p bin)
82 (copy-file "./v" (string-append bin "/v"))
83 ;; v requires as of 0.1.27 that these other components are in the
84 ;; same directory. In a future release we may be able to move
85 ;; these into other output folders.
86 (copy-recursively "cmd/tools" tools)
87 (copy-recursively "thirdparty" thirdparty)
88 (copy-recursively "vlib" vlib)
89 (copy-file "v.mod" vmod))
90 #t)))))
91 (inputs
92 `(("glib" ,glib)
93 ("gcc" ,gcc)))
94 (native-inputs
95 `(("vc"
96 ,(let ((vc-version "0884d7092f4c2a4f8ca16da6f1792efa235247be"))
97 ;; v bootstraps from generated c source code from a dedicated
98 ;; repository. It's readable, as generated source goes, and not at all
99 ;; obfuscated, and it's about 15kb. The original source written in
100 ;; golang is lost to the forces of entropy; modifying the generated c
101 ;; source by hand has been a commonly used technique for iterating on
102 ;; the codebase.
103 (origin
104 (method git-fetch)
105 (uri (git-reference
106 (url "https://github.com/vlang/vc")
107 (commit vc-version)))
108 (file-name (git-file-name "vc" vc-version))
109 (sha256
110 (base32 "17bs09iwxfd0si70j48n9nd16gfgcj8imd0azypk3xzzbz4wybnz")))))))
111 (home-page "https://vlang.io/")
112 (synopsis "Compiler for the V programming language")
113 (description
114 "V is a systems programming language. It provides memory safety and thread
115 safety guarantees with minimal abstraction.")
116 (license license:expat)))