| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (gnu packages hare)
|
| 20 | #:use-module (gnu packages)
|
| 21 | #:use-module (gnu packages base)
|
| 22 | #:use-module (gnu packages c)
|
| 23 | #:use-module (gnu packages commencement)
|
| 24 | #:use-module (gnu packages cross-base)
|
| 25 | #:use-module (gnu packages less)
|
| 26 | #:use-module (gnu packages man)
|
| 27 | #:use-module (guix build-system gnu)
|
| 28 | #:use-module (guix build-system hare)
|
| 29 | #:use-module (guix deprecation)
|
| 30 | #:use-module (guix gexp)
|
| 31 | #:use-module (guix git-download)
|
| 32 | #:use-module ((guix licenses) #:prefix license:)
|
| 33 | #:use-module (guix packages)
|
| 34 | #:use-module (guix search-paths)
|
| 35 | #:use-module (guix utils)
|
| 36 | #:re-export (%hare-supported-systems target->hare-arch))
|
| 37 |
|
| 38 | (define-deprecated/public-alias hare-supported-systems %hare-supported-systems)
|
| 39 |
|
| 40 | (define (cross-target? target) |
| 41 | (and target (not (if (%current-target-system)
|
| 42 | (string=? (%current-target-system) target)
|
| 43 | (string-prefix? (%current-system) target)))))
|
| 44 |
|
| 45 | (define (tools-for-target target)
|
| 46 | (let* ((cross? (and=> target cross-target?))
|
| 47 | (with-target (lambda (f) (if cross? (f target) (f))))
|
| 48 | (prefix (string-upcase (with-target target->hare-arch)))
|
| 49 | (prefix-for (lambda (v) (if target (string-append prefix "_" v) v)))
|
| 50 | (toolchain (if cross? (cross-gcc-toolchain target) gcc-toolchain))
|
| 51 | (bin-for (lambda (t) (file-append toolchain "/bin/" (with-target t)))))
|
| 52 | #~((#$(prefix-for "CC") #$(bin-for cc-for-target))
|
| 53 | (#$(prefix-for "AS") #$(bin-for as-for-target))
|
| 54 | (#$(prefix-for "LD") #$(bin-for ld-for-target)))))
|
| 55 |
|
| 56 | (define hare-config |
| 57 | (computed-file "hare-config.mk"
|
| 58 | #~(begin (use-modules (ice-9 format))
|
| 59 | (call-with-output-file #$output
|
| 60 | (lambda (port)
|
| 61 | (format port "include configs/linux.mk~%~:{~a=~a~%~}"
|
| 62 | `(("ARCH" ,#$(target->hare-arch))
|
| 63 | ("DEFAULT_TARGET" "$(ARCH)")
|
| 64 | ("STDLIB" "$(PREFIX)/share/hare")
|
| 65 | ("HAREPATH" "$(PREFIX)/share/hare")
|
| 66 | #$@(tools-for-target #f)
|
| 67 | #$@(tools-for-target "aarch64-linux-gnu")
|
| 68 | #$@(tools-for-target "riscv64-linux-gnu")
|
| 69 | #$@(tools-for-target "x86_64-linux-gnu"))))))))
|
| 70 |
|
| 71 | (define-public harec
|
| 72 | (package
|
| 73 | (name "harec")
|
| 74 | (version "0.26.0")
|
| 75 | (source (origin
|
| 76 | (method git-fetch)
|
| 77 | (uri (git-reference
|
| 78 | (url "https://git.sr.ht/~sircmpwn/harec")
|
| 79 | (commit version)))
|
| 80 | (file-name (git-file-name name version))
|
| 81 | (sha256
|
| 82 | (base32
|
| 83 | "1bzmd4j2q6kdgz8zxs6qwy57fzh7wh7xwps9rcmcrhwl5zngff3b"))))
|
| 84 | (build-system gnu-build-system)
|
| 85 | (arguments
|
| 86 | (list #:modules `((ice-9 format) ,@%default-gnu-modules)
|
| 87 | #:make-flags #~(list (string-append "PREFIX=" #$output)
|
| 88 | (string-append "VERSION=" #$version))
|
| 89 | #:phases
|
| 90 | #~(modify-phases %standard-phases
|
| 91 | (replace 'configure
|
| 92 | (lambda _ (copy-file #$hare-config "config.mk"))))))
|
| 93 | (native-inputs (list qbe))
|
| 94 | (supported-systems %hare-supported-systems)
|
| 95 | (home-page "https://harelang.org")
|
| 96 | (synopsis "Harelang bootstrap compiler")
|
| 97 | (description "@code{harec} is a bootstrap compiler written in C for the Hare
|
| 98 | programming language. For general Hare programming, see the @code{hare}
|
| 99 | package.")
|
| 100 | (license license:gpl3)))
|
| 101 |
|
| 102 | (define $HAREPATH
|
| 103 | (search-path-specification
|
| 104 | (variable "HAREPATH")
|
| 105 | (files '("share/hare"))))
|
| 106 |
|
| 107 | (define $HARE_TOOLPATH
|
| 108 | (search-path-specification
|
| 109 | (variable "HARE_TOOLPATH")
|
| 110 | (files '("libexec/hare"))))
|
| 111 |
|
| 112 | (define-public hare
|
| 113 | (package
|
| 114 | (name "hare")
|
| 115 | (version "0.26.0")
|
| 116 | (source (origin
|
| 117 | (method git-fetch)
|
| 118 | (uri (git-reference
|
| 119 | (url "https://git.sr.ht/~sircmpwn/hare")
|
| 120 | (commit version)))
|
| 121 | (file-name (git-file-name name version))
|
| 122 | (patches (search-patches "hare-fallback-cache.patch"))
|
| 123 | (sha256
|
| 124 | (base32
|
| 125 | "1iay401z2bl6rihjlgd50zq1d29l7k304r5jmwr55l8in2fy3nnw"))))
|
| 126 | (build-system gnu-build-system)
|
| 127 | (arguments
|
| 128 | (list #:modules `((ice-9 format) ,@%default-gnu-modules)
|
| 129 | #:make-flags #~(list (string-append "PREFIX=" #$output)
|
| 130 | (string-append "VERSION=" #$version))
|
| 131 | #:phases
|
| 132 | #~(modify-phases %standard-phases
|
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | (replace 'configure
|
| 139 | (lambda* (#:key inputs #:allow-other-keys)
|
| 140 | (copy-file #$hare-config "config.mk")
|
| 141 | |
| 142 | (let ((file (lambda (s) (search-input-file inputs s)))
|
| 143 | (dir (lambda (s) (search-input-directory inputs s))))
|
| 144 | (substitute* "cmd/hare/build.ha"
|
| 145 | (("\"harec\"") (format #f "\"~a\"" (file "bin/harec")))
|
| 146 | (("\"qbe\"") (format #f "\"~a\"" (file "bin/qbe"))))
|
| 147 | (substitute* "cmd/haredoc/main.ha"
|
| 148 | (("\"less\"") (format #f "\"~a\"" (file "bin/less"))))
|
| 149 | (substitute* "wordexp/wordexp.ha"
|
| 150 | (("/bin/sh") (file "bin/sh")))
|
| 151 | (substitute* "time/chrono/+linux.ha"
|
| 152 | (("/usr/share/zoneinfo/leap-seconds.list")
|
| 153 | (file "share/zoneinfo/leap-seconds.list")))
|
| 154 | (substitute* "time/date/+linux.ha"
|
| 155 | (("/usr/share/zoneinfo") (dir "share/zoneinfo")))))))))
|
| 156 | (inputs
|
| 157 | (let ((tc (lambda (t) (and (cross-target? t) (cross-gcc-toolchain t)))))
|
| 158 | (filter ->bool (list gcc-toolchain less tzdata/leap-seconds harec qbe
|
| 159 | |
| 160 | |
| 161 | (tc "aarch64-linux-gnu")
|
| 162 | (tc "riscv64-linux-gnu")
|
| 163 | (tc "x86_64-linux-gnu")))))
|
| 164 | (native-inputs (list harec qbe scdoc))
|
| 165 | (supported-systems %hare-supported-systems)
|
| 166 | (native-search-paths (list $HAREPATH $HARE_TOOLPATH))
|
| 167 | (home-page "https://harelang.org")
|
| 168 | (synopsis "Harelang compiler tooling and stdlib")
|
| 169 | (description "Hare is a simple systems programming language, featuring
|
| 170 | static typing, manual memory management, and a minimal runtime.")
|
| 171 | (license (list license:gpl3 license:mpl2.0))))
|
| 172 |
|
| 173 | (define-public hare-update
|
| 174 | (package
|
| 175 | (name "hare-update")
|
| 176 | (version "0.26.0.0")
|
| 177 | (source (origin
|
| 178 | (method git-fetch)
|
| 179 | (uri (git-reference
|
| 180 | (url "https://git.sr.ht/~sircmpwn/hare-update")
|
| 181 | (commit version)))
|
| 182 | (file-name (git-file-name name version))
|
| 183 | (sha256
|
| 184 | (base32
|
| 185 | "1pqlqgryjdcvzshj95p3gd8icpjgn01hcsfss8r3hd8xqr87v8qk"))))
|
| 186 | (build-system hare-build-system)
|
| 187 | (arguments (list #:phases
|
| 188 | #~(modify-phases %standard-phases
|
| 189 | (add-before 'build 'build-rules
|
| 190 | |
| 191 | |
| 192 | (lambda _ (invoke "make" "hare-update-genrules"))))))
|
| 193 | (supported-systems %hare-supported-systems)
|
| 194 | (home-page "https://harelang.org")
|
| 195 | (synopsis "Harelang interversion updater tool")
|
| 196 | (description "@code{hare-update} updates Harelang source files to newer
|
| 197 | versions of the language and stdlib automagically.")
|
| 198 | (license license:eupl1.2)))
|