vlang.scm 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. (define-module (gnu packages vlang)
  22. #:use-module (gnu packages glib)
  23. #:use-module (gnu packages node)
  24. #:use-module (gnu packages sqlite)
  25. #:use-module (gnu packages tls)
  26. #:use-module (gnu packages version-control)
  27. #:use-module (gnu packages xorg)
  28. #:use-module (guix build-system gnu)
  29. #:use-module (guix git-download)
  30. #:use-module ((guix licenses) #:prefix license:)
  31. #:use-module (guix utils)
  32. #:use-module (guix packages))
  33. (define-public vlang
  34. (package
  35. (name "vlang")
  36. (version "0.2.4")
  37. (source
  38. (origin
  39. (method git-fetch)
  40. (uri (git-reference
  41. (url "https://github.com/vlang/v")
  42. (commit version)))
  43. (file-name (git-file-name name version))
  44. (sha256
  45. (base32 "17wmjxssmg6kd4j8i6pgib452zzwvkyi3n1znd1jj3xkf2l92fw8"))))
  46. (build-system gnu-build-system)
  47. (arguments
  48. `(#:make-flags
  49. (list (string-append "CC=" ,(cc-for-target))
  50. "TMPTCC=tcc"
  51. (string-append "VC=" (assoc-ref %build-inputs "vc"))
  52. "GITCLEANPULL=true"
  53. "GITFASTCLONE=mkdir -p"
  54. "TCCREPO="
  55. "VCREPO="
  56. (string-append "VFLAGS=-cc " ,(cc-for-target))
  57. "VERBOSE=1")
  58. #:phases
  59. (modify-phases %standard-phases
  60. (delete 'configure)
  61. (add-before 'build 'change-home
  62. (lambda _
  63. (setenv "HOME" "/tmp")
  64. #t))
  65. (add-before 'build 'patch-makefile
  66. (lambda _
  67. (substitute* "Makefile"
  68. (("--branch thirdparty-unknown-unknown") "")
  69. (("rm -rf") "true"))
  70. #t))
  71. (add-before 'check 'delete-failing-tests
  72. ;; XXX As always, these should eventually be fixed and run.
  73. (lambda _
  74. (for-each delete-file
  75. '("vlib/os/notify/notify_test.v"
  76. "vlib/v/doc/doc_private_fn_test.v"
  77. "vlib/v/live/live_test.v"
  78. "vlib/v/tests/repl/repl_test.v"
  79. "vlib/v/tests/valgrind/valgrind_test.v"))
  80. #t))
  81. (replace 'check
  82. (lambda* (#:key tests? #:allow-other-keys)
  83. (let* ((bin "tmp/bin")
  84. (gcc (which "gcc")))
  85. (when tests?
  86. (mkdir-p bin)
  87. (symlink gcc (string-append bin "/cc"))
  88. (setenv "PATH" (string-append bin ":" (getenv "PATH")))
  89. (invoke "./v" "test-self")))
  90. #t))
  91. (replace 'install
  92. (lambda* (#:key outputs #:allow-other-keys)
  93. (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
  94. (docs (string-append bin "/cmd/v/help"))
  95. (tools (string-append bin "/cmd/tools"))
  96. (thirdparty (string-append bin "/thirdparty"))
  97. (vlib (string-append bin "/vlib"))
  98. (vmod (string-append bin "/v.mod")))
  99. (mkdir-p bin)
  100. (copy-file "./v" (string-append bin "/v"))
  101. ;; v requires as of 0.2.4 that these other components are in the
  102. ;; same directory. In a future release we may be able to move
  103. ;; these into other output folders.
  104. (copy-recursively "cmd/tools" tools)
  105. (copy-recursively "cmd/v/help" docs)
  106. (copy-recursively "thirdparty" thirdparty)
  107. (copy-recursively "vlib" vlib)
  108. (copy-file "v.mod" vmod))
  109. #t)))))
  110. (inputs
  111. (list glib))
  112. (native-inputs
  113. `(("vc"
  114. ;; Versions are not consistently tagged, but the matching commit will
  115. ;; probably have ‘v0.x.y’ in the commit message.
  116. ,(let ((vc-version "5e876c1491db50b136499d3397b57b7c062040e5"))
  117. ;; v bootstraps from generated c source code from a dedicated
  118. ;; repository. It's readable, as generated source goes, and not at all
  119. ;; obfuscated, and it's about 15kb. The original source written in
  120. ;; golang is lost to the forces of entropy; modifying the generated c
  121. ;; source by hand has been a commonly used technique for iterating on
  122. ;; the codebase.
  123. (origin
  124. (method git-fetch)
  125. (uri (git-reference
  126. (url "https://github.com/vlang/vc")
  127. (commit vc-version)))
  128. (file-name (git-file-name "vc" vc-version))
  129. (sha256
  130. (base32 "1gxdkgc7aqw5f0fhch1n6nhzgzvgb49p77idx1zj7wcp53lpx5ng")))))
  131. ("git" ,git-minimal)
  132. ;; For the tests.
  133. ("libx11" ,libx11)
  134. ("node" ,node)
  135. ("openssl" ,openssl)
  136. ("sqlite" ,sqlite)))
  137. (home-page "https://vlang.io/")
  138. (synopsis "Compiler for the V programming language")
  139. (description
  140. "V is a systems programming language. It provides memory safety and thread
  141. safety guarantees with minimal abstraction.")
  142. (license license:expat)))