diff options
Diffstat (limited to 'gnu/packages/graal.scm')
| -rw-r--r-- | gnu/packages/graal.scm | 1815 |
1 files changed, 1815 insertions, 0 deletions
diff --git a/gnu/packages/graal.scm b/gnu/packages/graal.scm new file mode 100644 index 00000000000..6714155b50a --- /dev/null +++ b/gnu/packages/graal.scm | |||
| @@ -0,0 +1,1815 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2025 Danny Milosavljevic <dannym@friendly-machines.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 graal) | ||
| 20 | #:use-module ((guix licenses) #:prefix license:) | ||
| 21 | #:use-module (guix packages) | ||
| 22 | #:use-module (guix download) | ||
| 23 | #:use-module (guix git-download) | ||
| 24 | #:use-module (guix gexp) | ||
| 25 | #:use-module (guix utils) | ||
| 26 | #:use-module (guix build-system gnu) | ||
| 27 | #:use-module (guix build-system copy) | ||
| 28 | #:use-module (guix build-system ant) | ||
| 29 | #:use-module (guix build-system maven) | ||
| 30 | #:use-module (gnu packages) | ||
| 31 | #:use-module (gnu packages maven) | ||
| 32 | #:use-module (gnu packages maven-parent-pom) | ||
| 33 | #:use-module (gnu packages bash) | ||
| 34 | #:use-module (gnu packages java) | ||
| 35 | #:use-module (gnu packages python) | ||
| 36 | #:use-module (gnu packages compression) | ||
| 37 | #:use-module (gnu packages icu4c) | ||
| 38 | #:use-module (gnu packages java-compression) | ||
| 39 | #:use-module (gnu packages libffi) | ||
| 40 | #:use-module (gnu packages ninja) | ||
| 41 | #:use-module (gnu packages cmake) | ||
| 42 | #:use-module (gnu packages version-control)) | ||
| 43 | |||
| 44 | ;;; | ||
| 45 | ;;; GraalVM build tool and components | ||
| 46 | ;;; | ||
| 47 | |||
| 48 | ;; The Universal Permissive License (UPL) 1.0 is an FSF-approved, | ||
| 49 | ;; GPL-compatible, permissive free software license. | ||
| 50 | ;; See: <https://www.fsf.org/blogs/licensing/universal-permissive-license-added-to-license-list> | ||
| 51 | (define upl1.0 | ||
| 52 | (license:non-copyleft "https://opensource.org/licenses/UPL" | ||
| 53 | "Universal Permissive License 1.0")) | ||
| 54 | |||
| 55 | ;;; Shared version and source definitions | ||
| 56 | |||
| 57 | (define %graalvm-version "25.0.1") | ||
| 58 | |||
| 59 | ;; Main graal repository source (used by sdk, truffle) | ||
| 60 | (define %graal-source | ||
| 61 | (origin | ||
| 62 | (method git-fetch) | ||
| 63 | (uri (git-reference | ||
| 64 | (url "https://github.com/oracle/graal") | ||
| 65 | (commit (string-append "vm-" %graalvm-version)))) | ||
| 66 | (file-name (git-file-name "graal" %graalvm-version)) | ||
| 67 | (sha256 | ||
| 68 | (base32 "06m8nbjrjawn5falr7fzgsqqav23zapzhc5f774320cdjbj90zvx")) | ||
| 69 | (modules '((guix build utils))) | ||
| 70 | (snippet | ||
| 71 | #~(begin | ||
| 72 | (use-modules (guix build utils)) | ||
| 73 | ;; Use GCC toolchain instead of clang | ||
| 74 | (substitute* '("sdk/mx.sdk/mx_sdk_vm_impl.py" | ||
| 75 | "sdk/mx.sdk/mx_sdk_vm_ng.py") | ||
| 76 | (("sdk:LLVM_NINJA_TOOLCHAIN") "mx:DEFAULT_NINJA_TOOLCHAIN")) | ||
| 77 | (substitute* '("sdk/mx.sdk/suite.py" | ||
| 78 | "truffle/mx.truffle/suite.py") | ||
| 79 | (("\"toolchain\"\\s*:\\s*\"sdk:LLVM_NINJA_TOOLCHAIN\"") | ||
| 80 | "\"toolchain\": \"mx:DEFAULT_NINJA_TOOLCHAIN\"")) | ||
| 81 | ;; Remove clang-specific flags that GCC doesn't understand. | ||
| 82 | (substitute* '("sdk/mx.sdk/suite.py" | ||
| 83 | "sdk/mx.sdk/mx_sdk_vm_impl.py" | ||
| 84 | "sdk/mx.sdk/mx_sdk_vm_ng.py") | ||
| 85 | (("-stdlib=libc\\+\\+") "") | ||
| 86 | (("-static-libstdc\\+\\+") "") | ||
| 87 | (("-l:libc\\+\\+abi\\.a") "")) | ||
| 88 | ;; Fix missing #include <memory> for GCC. | ||
| 89 | (substitute* "sdk/src/org.graalvm.launcher.native/src/launcher.cc" | ||
| 90 | (("#include <sys/stat.h>") | ||
| 91 | "#include <sys/stat.h> | ||
| 92 | #include <memory>")) | ||
| 93 | ;; Patch the libffi bootstrap Makefile patch to use bash explicitly. | ||
| 94 | (substitute* "truffle/src/libffi/patches/others/0001-Add-mx-bootstrap-Makefile.patch" | ||
| 95 | (("\\.\\./(\\$\\(SOURCES\\))/configure" all sources) | ||
| 96 | (string-append "$(SHELL) ../" sources "/configure"))))))) | ||
| 97 | |||
| 98 | ;;; | ||
| 99 | ;;; MX URL Rewrite Helpers | ||
| 100 | ;;; | ||
| 101 | ;;; The mx build tool downloads dependencies from Maven and other URLs. | ||
| 102 | ;;; MX_URLREWRITES redirects these to Guix-built JARs with computed SHA512 digests. | ||
| 103 | |||
| 104 | ;; Build MX_URLREWRITES JSON from a list of rewrite specifications. | ||
| 105 | ;; Each spec is: (maven-url path-pattern) | ||
| 106 | ;; maven-url: the URL mx tries to fetch | ||
| 107 | ;; path-pattern: pattern for search-input-file, or input key for assoc-ref if no "/" | ||
| 108 | (define (make-mx-urlrewrites-phase specs) | ||
| 109 | #~(lambda* (#:key inputs #:allow-other-keys) | ||
| 110 | (use-modules (ice-9 popen) (ice-9 rdelim)) | ||
| 111 | (define (file-sha512 path) | ||
| 112 | (let* ((port (open-pipe* OPEN_READ "sha512sum" "--" path)) | ||
| 113 | (line (read-line port))) | ||
| 114 | (close-pipe port) | ||
| 115 | (car (string-split line #\space)))) | ||
| 116 | (define (resolve-path path-pattern) | ||
| 117 | (if (string-index path-pattern #\/) | ||
| 118 | (search-input-file inputs path-pattern) | ||
| 119 | (assoc-ref inputs path-pattern))) | ||
| 120 | (define (make-rewrite spec) | ||
| 121 | (let* ((maven-url (car spec)) | ||
| 122 | (path-pattern (cadr spec)) | ||
| 123 | (local-path (resolve-path path-pattern)) | ||
| 124 | (sha512 (file-sha512 local-path))) | ||
| 125 | (format #f "{\"~a\":{\"replacement\":\"file://~a\",\"digest\":\"sha512:~a\"}}" | ||
| 126 | maven-url local-path sha512))) | ||
| 127 | (let ((rewrites (string-append "[" (string-join (map make-rewrite '#$specs) ",") "]"))) | ||
| 128 | (format #t "Setting MX_URLREWRITES:~%~a~%" rewrites) | ||
| 129 | (setenv "MX_URLREWRITES" rewrites)))) | ||
| 130 | |||
| 131 | ;; Build install phase that uses `mx paths` to find distribution JARs. | ||
| 132 | ;; dists: list of distribution names (e.g., '("GRAAL_SDK" "WORD")) | ||
| 133 | ;; subdir: output subdirectory under lib/ (default "graal") | ||
| 134 | (define* (make-mx-install-phase dists #:optional (subdir "graal")) | ||
| 135 | #~(lambda* (#:key outputs #:allow-other-keys) | ||
| 136 | (use-modules (ice-9 popen) (ice-9 rdelim)) | ||
| 137 | (define (mx-paths dist) | ||
| 138 | (let* ((port (open-pipe* OPEN_READ "mx" "--user-home" (getcwd) "paths" dist)) | ||
| 139 | (path (read-line port))) | ||
| 140 | (close-pipe port) | ||
| 141 | path)) | ||
| 142 | (let* ((out (assoc-ref outputs "out")) | ||
| 143 | (lib (string-append out "/lib/" #$subdir))) | ||
| 144 | (mkdir-p lib) | ||
| 145 | (for-each (lambda (dist) | ||
| 146 | (let ((jar (mx-paths dist))) | ||
| 147 | (format #t "Installing ~a -> ~a~%" dist jar) | ||
| 148 | (install-file jar lib))) | ||
| 149 | '#$dists)))) | ||
| 150 | |||
| 151 | ;; Install mx distributions as Maven artifacts in /lib/m2 format. | ||
| 152 | ;; mapping: list of (mx-dist-name group-id artifact-id [dependencies]) entries | ||
| 153 | ;; where dependencies is an optional list of (dep-group-id dep-artifact-id) | ||
| 154 | ;; version: the version string for Maven coordinates | ||
| 155 | (define* (make-mx-install-m2-phase mapping version) | ||
| 156 | #~(lambda* (#:key outputs #:allow-other-keys) | ||
| 157 | (use-modules (ice-9 popen) (ice-9 rdelim) | ||
| 158 | (sxml simple)) | ||
| 159 | (define (mx-paths dist) | ||
| 160 | (let* ((port (open-pipe* OPEN_READ "mx" "--user-home" (getcwd) "paths" dist)) | ||
| 161 | (path (read-line port))) | ||
| 162 | (close-pipe port) | ||
| 163 | path)) | ||
| 164 | (define (install-maven-artifact mx-dist group-id artifact-id deps) | ||
| 165 | (let* ((out (assoc-ref outputs "out")) | ||
| 166 | (jar (mx-paths mx-dist)) | ||
| 167 | (m2-dir (string-append out "/lib/m2/" | ||
| 168 | (string-join (string-split group-id #\.) "/") "/" | ||
| 169 | artifact-id "/" #$version)) | ||
| 170 | (jar-name (string-append artifact-id "-" #$version ".jar")) | ||
| 171 | (pom-name (string-append artifact-id "-" #$version ".pom")) | ||
| 172 | (dep-sxml (map (lambda (dep) | ||
| 173 | `(dependency | ||
| 174 | (groupId ,(car dep)) | ||
| 175 | (artifactId ,(cadr dep)) | ||
| 176 | (version ,#$version))) | ||
| 177 | deps))) | ||
| 178 | (format #t "Installing ~a -> ~a/~a~%" mx-dist m2-dir jar-name) | ||
| 179 | (mkdir-p m2-dir) | ||
| 180 | (copy-file jar (string-append m2-dir "/" jar-name)) | ||
| 181 | ;; Create POM with dependencies for Maven resolution | ||
| 182 | (call-with-output-file (string-append m2-dir "/" pom-name) | ||
| 183 | (lambda (port) | ||
| 184 | (sxml->xml | ||
| 185 | `(*TOP* | ||
| 186 | (*PI* xml "version=\"1.0\"") | ||
| 187 | (project | ||
| 188 | (modelVersion "4.0.0") | ||
| 189 | (groupId ,group-id) | ||
| 190 | (artifactId ,artifact-id) | ||
| 191 | (version ,#$version) | ||
| 192 | ,@(if (null? dep-sxml) | ||
| 193 | '() | ||
| 194 | `((dependencies ,@dep-sxml))))) | ||
| 195 | port))))) | ||
| 196 | (for-each (lambda (entry) | ||
| 197 | (install-maven-artifact (list-ref entry 0) | ||
| 198 | (list-ref entry 1) | ||
| 199 | (list-ref entry 2) | ||
| 200 | (if (> (length entry) 3) | ||
| 201 | (list-ref entry 3) | ||
| 202 | '()))) | ||
| 203 | '#$mapping))) | ||
| 204 | |||
| 205 | ;; ASM bytecode manipulation library (version 9.7.1) | ||
| 206 | (define %mx-rewrites-asm | ||
| 207 | '(("https://repo1.maven.org/maven2/org/ow2/asm/asm/9.7.1/asm-9.7.1.jar" | ||
| 208 | "share/java/asm9.jar") | ||
| 209 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm/9.7.1/asm-9.7.1-sources.jar" | ||
| 210 | "share/java/asm9-sources.jar") | ||
| 211 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.7.1/asm-tree-9.7.1.jar" | ||
| 212 | "share/java/asm-tree.jar") | ||
| 213 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.7.1/asm-tree-9.7.1-sources.jar" | ||
| 214 | "share/java/asm-tree-sources.jar") | ||
| 215 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/9.7.1/asm-analysis-9.7.1.jar" | ||
| 216 | "share/java/asm-analysis.jar") | ||
| 217 | ;; asm-analysis sources -> binary (no sources JAR available) | ||
| 218 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/9.7.1/asm-analysis-9.7.1-sources.jar" | ||
| 219 | "share/java/asm-analysis.jar") | ||
| 220 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-util/9.7.1/asm-util-9.7.1.jar" | ||
| 221 | "share/java/asm-util8.jar") | ||
| 222 | ;; asm-util sources -> binary | ||
| 223 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-util/9.7.1/asm-util-9.7.1-sources.jar" | ||
| 224 | "share/java/asm-util8.jar") | ||
| 225 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.7.1/asm-commons-9.7.1.jar" | ||
| 226 | "share/java/asm-commons8.jar") | ||
| 227 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.7.1/asm-commons-9.7.1-sources.jar" | ||
| 228 | "share/java/asm-commons-sources.jar"))) | ||
| 229 | |||
| 230 | ;; ANTLR4 parser runtime (version 4.13.2) | ||
| 231 | (define %mx-rewrites-antlr | ||
| 232 | '(("https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.13.2/antlr4-runtime-4.13.2.jar" | ||
| 233 | "share/java/java-antlr4-runtime.jar") | ||
| 234 | ;; sources -> binary | ||
| 235 | ("https://repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.13.2/antlr4-runtime-4.13.2-sources.jar" | ||
| 236 | "share/java/java-antlr4-runtime.jar"))) | ||
| 237 | |||
| 238 | ;; ICU4J unicode library (mx wants 76.1, we provide 73.2) | ||
| 239 | (define %mx-rewrites-icu | ||
| 240 | '(("https://repo1.maven.org/maven2/com/ibm/icu/icu4j/76.1/icu4j-76.1.jar" | ||
| 241 | "share/java/icu4j.jar") | ||
| 242 | ("https://search.maven.org/remotecontent?filepath=com/ibm/icu/icu4j/76.1/icu4j-76.1.jar" | ||
| 243 | "share/java/icu4j.jar") | ||
| 244 | ("https://repo1.maven.org/maven2/com/ibm/icu/icu4j/76.1/icu4j-76.1-sources.jar" | ||
| 245 | "share/java/icu4j-sources.jar") | ||
| 246 | ("https://repo1.maven.org/maven2/com/ibm/icu/icu4j-charset/76.1/icu4j-charset-76.1.jar" | ||
| 247 | "share/java/icu4j-charset.jar") | ||
| 248 | ("https://search.maven.org/remotecontent?filepath=com/ibm/icu/icu4j-charset/76.1/icu4j-charset-76.1.jar" | ||
| 249 | "share/java/icu4j-charset.jar") | ||
| 250 | ("https://repo1.maven.org/maven2/com/ibm/icu/icu4j-charset/76.1/icu4j-charset-76.1-sources.jar" | ||
| 251 | "share/java/icu4j-charset-sources.jar"))) | ||
| 252 | |||
| 253 | ;; XZ compression library (version 1.10) | ||
| 254 | (define %mx-rewrites-xz | ||
| 255 | '(("https://repo1.maven.org/maven2/org/tukaani/xz/1.10/xz-1.10.jar" | ||
| 256 | "share/java/xz.jar") | ||
| 257 | ("https://search.maven.org/remotecontent?filepath=org/tukaani/xz/1.10/xz-1.10.jar" | ||
| 258 | "share/java/xz.jar") | ||
| 259 | ("https://repo1.maven.org/maven2/org/tukaani/xz/1.10/xz-1.10-sources.jar" | ||
| 260 | "share/java/xz-sources.jar"))) | ||
| 261 | |||
| 262 | ;; Ninja build tool | ||
| 263 | (define %mx-rewrites-ninja | ||
| 264 | '(("https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/ninja-1.10.2-linux-amd64.zip" | ||
| 265 | "share/ninja/ninja.zip"))) | ||
| 266 | |||
| 267 | ;; Hamcrest test matchers | ||
| 268 | (define %mx-rewrites-hamcrest | ||
| 269 | '(("https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" | ||
| 270 | "lib/m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar") | ||
| 271 | ("https://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" | ||
| 272 | "lib/m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar") | ||
| 273 | ;; sources -> binary | ||
| 274 | ("https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar" | ||
| 275 | "lib/m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar") | ||
| 276 | ("https://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar" | ||
| 277 | "lib/m2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"))) | ||
| 278 | |||
| 279 | ;; libffi source tarball | ||
| 280 | (define %mx-rewrites-libffi | ||
| 281 | '(("https://github.com/libffi/libffi/releases/download/v3.4.8/libffi-3.4.8.tar.gz" | ||
| 282 | "libffi-3.4.8.tar.gz") | ||
| 283 | ("https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/libffi-3.4.8.tar.gz" | ||
| 284 | "libffi-3.4.8.tar.gz"))) | ||
| 285 | |||
| 286 | ;; JLine terminal library (version 3.28.0) | ||
| 287 | (define %mx-rewrites-jline | ||
| 288 | '(("https://repo1.maven.org/maven2/org/jline/jline-terminal/3.28.0/jline-terminal-3.28.0.jar" | ||
| 289 | "share/java/jline-terminal.jar") | ||
| 290 | ("https://repo1.maven.org/maven2/org/jline/jline-terminal/3.28.0/jline-terminal-3.28.0-sources.jar" | ||
| 291 | "share/java/jline-terminal-sources.jar") | ||
| 292 | ("https://repo1.maven.org/maven2/org/jline/jline-reader/3.28.0/jline-reader-3.28.0.jar" | ||
| 293 | "share/java/jline-reader.jar") | ||
| 294 | ("https://repo1.maven.org/maven2/org/jline/jline-reader/3.28.0/jline-reader-3.28.0-sources.jar" | ||
| 295 | "share/java/jline-reader-sources.jar") | ||
| 296 | ("https://repo1.maven.org/maven2/org/jline/jline-builtins/3.28.0/jline-builtins-3.28.0.jar" | ||
| 297 | "share/java/jline-builtins.jar") | ||
| 298 | ("https://repo1.maven.org/maven2/org/jline/jline-builtins/3.28.0/jline-builtins-3.28.0-sources.jar" | ||
| 299 | "share/java/jline-builtins-sources.jar") | ||
| 300 | ("https://repo1.maven.org/maven2/org/jline/jline-terminal-ffm/3.28.0/jline-terminal-ffm-3.28.0.jar" | ||
| 301 | "share/java/jline-terminal-ffm.jar") | ||
| 302 | ("https://repo1.maven.org/maven2/org/jline/jline-terminal-ffm/3.28.0/jline-terminal-ffm-3.28.0-sources.jar" | ||
| 303 | "share/java/jline-terminal-ffm-sources.jar"))) | ||
| 304 | |||
| 305 | ;; JSON library (version 20250517) | ||
| 306 | (define %mx-rewrites-json | ||
| 307 | '(("https://repo1.maven.org/maven2/org/json/json/20250517/json-20250517.jar" | ||
| 308 | "share/java/json.jar") | ||
| 309 | ("https://repo1.maven.org/maven2/org/json/json/20250517/json-20250517-sources.jar" | ||
| 310 | "share/java/json-sources.jar"))) | ||
| 311 | |||
| 312 | ;; BouncyCastle crypto library (version 1.78.1) | ||
| 313 | (define %mx-rewrites-bouncycastle | ||
| 314 | '(("https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk18on/1.78.1/bcprov-jdk18on-1.78.1.jar" | ||
| 315 | "share/java/bcprov-jdk18on.jar") | ||
| 316 | ("https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk18on/1.78.1/bcprov-jdk18on-1.78.1-sources.jar" | ||
| 317 | "share/java/bcprov-jdk18on-sources.jar") | ||
| 318 | ("https://repo1.maven.org/maven2/org/bouncycastle/bcutil-jdk18on/1.78.1/bcutil-jdk18on-1.78.1.jar" | ||
| 319 | "share/java/bcutil-jdk18on.jar") | ||
| 320 | ("https://repo1.maven.org/maven2/org/bouncycastle/bcutil-jdk18on/1.78.1/bcutil-jdk18on-1.78.1-sources.jar" | ||
| 321 | "share/java/bcutil-jdk18on-sources.jar") | ||
| 322 | ("https://repo1.maven.org/maven2/org/bouncycastle/bcpkix-jdk18on/1.78.1/bcpkix-jdk18on-1.78.1.jar" | ||
| 323 | "share/java/bcpkix-jdk18on.jar") | ||
| 324 | ("https://repo1.maven.org/maven2/org/bouncycastle/bcpkix-jdk18on/1.78.1/bcpkix-jdk18on-1.78.1-sources.jar" | ||
| 325 | "share/java/bcpkix-jdk18on-sources.jar"))) | ||
| 326 | |||
| 327 | ;; Cap'n Proto runtime (version 0.1.16) | ||
| 328 | (define %mx-rewrites-capnproto | ||
| 329 | '(("https://repo1.maven.org/maven2/org/capnproto/runtime/0.1.16/runtime-0.1.16.jar" | ||
| 330 | "share/java/capnproto-runtime.jar") | ||
| 331 | ("https://repo1.maven.org/maven2/org/capnproto/runtime/0.1.16/runtime-0.1.16-sources.jar" | ||
| 332 | "share/java/capnproto-runtime-sources.jar"))) | ||
| 333 | |||
| 334 | ;; TruffleJWS WebSocket library | ||
| 335 | (define %mx-rewrites-trufflejws | ||
| 336 | '(("https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/trufflejws-1.5.7.jar" | ||
| 337 | "share/java/trufflejws.jar") | ||
| 338 | ("https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/trufflejws-1.5.7-src.jar" | ||
| 339 | "share/java/trufflejws-sources.jar"))) | ||
| 340 | |||
| 341 | ;; Native source tarballs for graalpy | ||
| 342 | (define %mx-rewrites-native-sources | ||
| 343 | '(("https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/graalpython/bzip2-1.0.8.tar.gz" | ||
| 344 | "bzip2-1.0.8.tar.gz") | ||
| 345 | ("https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/xz-5.6.2.tar.gz" | ||
| 346 | "xz-5.6.2.tar.gz"))) | ||
| 347 | |||
| 348 | ;; JCodings character encoding library (version 1.0.63) | ||
| 349 | (define %mx-rewrites-jcodings | ||
| 350 | '(("https://repo1.maven.org/maven2/org/jruby/jcodings/jcodings/1.0.63/jcodings-1.0.63.jar" | ||
| 351 | "share/java/jcodings.jar") | ||
| 352 | ("https://repo1.maven.org/maven2/org/jruby/jcodings/jcodings/1.0.63/jcodings-1.0.63-sources.jar" | ||
| 353 | "share/java/jcodings-sources.jar"))) | ||
| 354 | |||
| 355 | ;; VisualVM JFluid Heap library (version 2.1.4) | ||
| 356 | (define %mx-rewrites-visualvm | ||
| 357 | '(("https://repo1.maven.org/maven2/org/graalvm/visualvm/modules/org-graalvm-visualvm-lib-jfluid-heap/2.1.4/org-graalvm-visualvm-lib-jfluid-heap-2.1.4.jar" | ||
| 358 | "share/java/visualvm-lib-jfluid-heap.jar") | ||
| 359 | ("https://repo1.maven.org/maven2/org/graalvm/visualvm/modules/org-graalvm-visualvm-lib-jfluid-heap/2.1.4/org-graalvm-visualvm-lib-jfluid-heap-2.1.4-sources.jar" | ||
| 360 | "share/java/visualvm-lib-jfluid-heap-sources.jar"))) | ||
| 361 | |||
| 362 | ;; Guava core libraries (version 31.0.1-jre) | ||
| 363 | ;; Uses m2 layout from ant-build-system with install-jars | ||
| 364 | (define %mx-rewrites-guava | ||
| 365 | '(("https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar" | ||
| 366 | "lib/m2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar") | ||
| 367 | ;; sources -> binary (no sources jar produced) | ||
| 368 | ("https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre-sources.jar" | ||
| 369 | "lib/m2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar"))) | ||
| 370 | |||
| 371 | ;; JIMFS in-memory file system (version 1.2) | ||
| 372 | (define %mx-rewrites-jimfs | ||
| 373 | '(("https://repo1.maven.org/maven2/com/google/jimfs/jimfs/1.2/jimfs-1.2.jar" | ||
| 374 | "share/java/jimfs.jar") | ||
| 375 | ("https://repo1.maven.org/maven2/com/google/jimfs/jimfs/1.2/jimfs-1.2-sources.jar" | ||
| 376 | "share/java/jimfs-sources.jar"))) | ||
| 377 | |||
| 378 | ;; Java Allocation Instrumenter (version 3.1.0) | ||
| 379 | (define %mx-rewrites-alloc-instrumenter | ||
| 380 | '(("https://repo1.maven.org/maven2/com/google/code/java-allocation-instrumenter/java-allocation-instrumenter/3.1.0/java-allocation-instrumenter-3.1.0.jar" | ||
| 381 | "share/java/java-allocation-instrumenter.jar") | ||
| 382 | ("https://repo1.maven.org/maven2/com/google/code/java-allocation-instrumenter/java-allocation-instrumenter/3.1.0/java-allocation-instrumenter-3.1.0-sources.jar" | ||
| 383 | "share/java/java-allocation-instrumenter-sources.jar"))) | ||
| 384 | |||
| 385 | ;; JUnit test framework (version 4.13.2 required by mx) | ||
| 386 | (define %mx-rewrites-junit | ||
| 387 | '(("https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar" | ||
| 388 | "share/java/junit.jar") | ||
| 389 | ("https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2-sources.jar" | ||
| 390 | "share/java/junit-sources.jar"))) | ||
| 391 | |||
| 392 | ;; Composed rewrite lists for each package tier | ||
| 393 | (define %mx-rewrites-regex | ||
| 394 | (append %mx-rewrites-asm | ||
| 395 | %mx-rewrites-antlr | ||
| 396 | %mx-rewrites-icu | ||
| 397 | %mx-rewrites-xz | ||
| 398 | %mx-rewrites-ninja)) | ||
| 399 | |||
| 400 | (define %mx-rewrites-truffle | ||
| 401 | (append %mx-rewrites-regex | ||
| 402 | %mx-rewrites-hamcrest | ||
| 403 | %mx-rewrites-libffi | ||
| 404 | %mx-rewrites-jline)) | ||
| 405 | |||
| 406 | (define %mx-rewrites-tools | ||
| 407 | (append %mx-rewrites-truffle | ||
| 408 | %mx-rewrites-json | ||
| 409 | %mx-rewrites-trufflejws)) | ||
| 410 | |||
| 411 | (define %mx-rewrites-substratevm | ||
| 412 | (append %mx-rewrites-truffle | ||
| 413 | %mx-rewrites-capnproto)) | ||
| 414 | |||
| 415 | (define %mx-rewrites-graalpy | ||
| 416 | (append %mx-rewrites-truffle | ||
| 417 | %mx-rewrites-json | ||
| 418 | %mx-rewrites-bouncycastle | ||
| 419 | %mx-rewrites-capnproto | ||
| 420 | %mx-rewrites-trufflejws | ||
| 421 | %mx-rewrites-native-sources)) | ||
| 422 | |||
| 423 | ;; ASM 9.8 - required by mx's internal jacoco code coverage | ||
| 424 | (define %mx-rewrites-asm-mx | ||
| 425 | '(("https://repo1.maven.org/maven2/org/ow2/asm/asm/9.8/asm-9.8.jar" | ||
| 426 | "share/java/asm9.jar") | ||
| 427 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm/9.8/asm-9.8-sources.jar" | ||
| 428 | "share/java/asm9-sources.jar") | ||
| 429 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.8/asm-tree-9.8.jar" | ||
| 430 | "share/java/asm-tree.jar") | ||
| 431 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/9.8/asm-tree-9.8-sources.jar" | ||
| 432 | "share/java/asm-tree-sources.jar") | ||
| 433 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/9.8/asm-analysis-9.8.jar" | ||
| 434 | "share/java/asm-analysis.jar") | ||
| 435 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/9.8/asm-analysis-9.8-sources.jar" | ||
| 436 | "share/java/asm-analysis.jar") | ||
| 437 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.8/asm-commons-9.8.jar" | ||
| 438 | "share/java/asm-commons.jar") | ||
| 439 | ("https://repo1.maven.org/maven2/org/ow2/asm/asm-commons/9.8/asm-commons-9.8-sources.jar" | ||
| 440 | "share/java/asm-commons-sources.jar"))) | ||
| 441 | |||
| 442 | ;; JMH 1.21 and dependencies - required by mx for compiler benchmarks | ||
| 443 | (define %mx-rewrites-jmh-mx | ||
| 444 | '(("https://repo1.maven.org/maven2/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar" | ||
| 445 | "lib/m2/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar") | ||
| 446 | ("https://repo1.maven.org/maven2/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6-sources.jar" | ||
| 447 | "lib/m2/net/sf/jopt-simple/jopt-simple/4.6/jopt-simple-4.6.jar") | ||
| 448 | ("https://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar" | ||
| 449 | "lib/m2/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar") | ||
| 450 | ("https://repo1.maven.org/maven2/org/apache/commons/commons-math3/3.2/commons-math3-3.2-sources.jar" | ||
| 451 | "lib/m2/org/apache/commons/commons-math3/3.2/commons-math3-3.2.jar") | ||
| 452 | ("https://repo1.maven.org/maven2/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar" | ||
| 453 | "lib/m2/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar") | ||
| 454 | ("https://repo1.maven.org/maven2/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21-sources.jar" | ||
| 455 | "lib/m2/org/openjdk/jmh/jmh-core/1.21/jmh-core-1.21.jar") | ||
| 456 | ("https://repo1.maven.org/maven2/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar" | ||
| 457 | "lib/m2/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar") | ||
| 458 | ("https://repo1.maven.org/maven2/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21-sources.jar" | ||
| 459 | "lib/m2/org/openjdk/jmh/jmh-generator-annprocess/1.21/jmh-generator-annprocess-1.21.jar"))) | ||
| 460 | |||
| 461 | ;; Comprehensive rewrites for building complete GraalVM CE | ||
| 462 | (define %mx-rewrites-vm-ce | ||
| 463 | (append %mx-rewrites-substratevm ; truffle + capnproto | ||
| 464 | %mx-rewrites-tools ; truffle + json + trufflejws | ||
| 465 | %mx-rewrites-jcodings | ||
| 466 | %mx-rewrites-visualvm | ||
| 467 | %mx-rewrites-guava | ||
| 468 | %mx-rewrites-jimfs | ||
| 469 | %mx-rewrites-alloc-instrumenter | ||
| 470 | %mx-rewrites-junit | ||
| 471 | %mx-rewrites-asm-mx ; mx's ASM 9.8 for jacoco | ||
| 472 | %mx-rewrites-jmh-mx)) | ||
| 473 | |||
| 474 | ;;; | ||
| 475 | ;;; Packages | ||
| 476 | ;;; | ||
| 477 | |||
| 478 | ;; The mx build tool is used to build all GraalVM projects. | ||
| 479 | ;; It has no external Python dependencies (stdlib only). | ||
| 480 | (define-public graalvm-mx | ||
| 481 | (package | ||
| 482 | (name "graalvm-mx") | ||
| 483 | (version "7.68.2") | ||
| 484 | (source (origin | ||
| 485 | (method git-fetch) | ||
| 486 | (uri (git-reference | ||
| 487 | (url "https://github.com/graalvm/mx") | ||
| 488 | (commit version))) | ||
| 489 | (file-name (git-file-name name version)) | ||
| 490 | (sha256 | ||
| 491 | (base32 | ||
| 492 | "0y7qqc8374vq6sg9icfm0jlfx8fb447p9blpm18ji95qrm9ywzx0")) | ||
| 493 | (patches (search-patches "graalvm-mx-check-failed-after-join.patch")))) | ||
| 494 | (build-system copy-build-system) | ||
| 495 | (arguments | ||
| 496 | (list | ||
| 497 | #:install-plan | ||
| 498 | #~'(("." "lib/mx/")) | ||
| 499 | #:phases | ||
| 500 | #~(modify-phases %standard-phases | ||
| 501 | (add-after 'install 'create-missing-directories | ||
| 502 | ;; mx's suite.py defines native projects that expect certain | ||
| 503 | ;; directories to exist. Create them so mx doesn't fail when | ||
| 504 | ;; initializing. | ||
| 505 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 506 | (let ((lib (string-append (assoc-ref outputs "out") "/lib/mx"))) | ||
| 507 | (mkdir-p (string-append lib "/java/com.oracle.jvmtiasmagent/include"))))) | ||
| 508 | (add-after 'create-missing-directories 'install-ninja-syntax | ||
| 509 | ;; mx needs ninja_syntax Python module for native projects. | ||
| 510 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 511 | (let ((ninja-syntax (search-input-file inputs "misc/ninja_syntax.py")) | ||
| 512 | (lib (string-append (assoc-ref outputs "out") "/lib/mx"))) | ||
| 513 | (copy-file ninja-syntax (string-append lib "/ninja_syntax.py"))))) | ||
| 514 | (add-after 'install-ninja-syntax 'create-wrapper | ||
| 515 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 516 | (let* ((out (assoc-ref outputs "out")) | ||
| 517 | (bin (string-append out "/bin")) | ||
| 518 | (lib (string-append out "/lib/mx")) | ||
| 519 | (python (search-input-file inputs "/bin/python3"))) | ||
| 520 | (mkdir-p bin) | ||
| 521 | (call-with-output-file (string-append bin "/mx") | ||
| 522 | (lambda (port) | ||
| 523 | (format port "#!~a~%exec ~a ~a/mx.py \"$@\"~%" | ||
| 524 | (search-input-file inputs "/bin/bash") | ||
| 525 | python | ||
| 526 | lib))) | ||
| 527 | (chmod (string-append bin "/mx") | ||
| 528 | #o755))))))) | ||
| 529 | (native-inputs (list (package-source ninja))) | ||
| 530 | (inputs (list bash-minimal python-3)) | ||
| 531 | (home-page "https://github.com/graalvm/mx") | ||
| 532 | (synopsis "Build tool for GraalVM projects") | ||
| 533 | (description "mx is a command-line tool used for the development of | ||
| 534 | GraalVM projects. It provides commands for building, testing, and packaging | ||
| 535 | polyglot language implementations built on the Truffle framework.") | ||
| 536 | (license license:gpl2))) | ||
| 537 | |||
| 538 | ;; TruffleJWS - WebSocket implementation used by GraalVM tools (chromeinspector) | ||
| 539 | ;; Built from source jar distributed by Oracle at lafo.ssw.uni-linz.ac.at | ||
| 540 | (define-public java-trufflejws-for-graal | ||
| 541 | (package | ||
| 542 | (name "java-trufflejws-for-graal") | ||
| 543 | (version "1.5.7") | ||
| 544 | (source (origin | ||
| 545 | (method url-fetch) | ||
| 546 | (uri "https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/trufflejws-1.5.7-src.jar") | ||
| 547 | (sha256 | ||
| 548 | (base32 "0c6ccyl9s07mimdnscc4g56zkhc31qd6qvhy16vidrj12h8cxgfn")))) | ||
| 549 | (build-system ant-build-system) | ||
| 550 | (arguments | ||
| 551 | (list | ||
| 552 | #:jar-name "trufflejws.jar" | ||
| 553 | #:source-dir "." | ||
| 554 | #:tests? #f ; no tests in source jar | ||
| 555 | #:phases | ||
| 556 | #~(modify-phases %standard-phases | ||
| 557 | (replace 'unpack | ||
| 558 | (lambda* (#:key source #:allow-other-keys) | ||
| 559 | ;; Source is a jar file containing .java files. | ||
| 560 | (invoke "unzip" "-q" source))) | ||
| 561 | (add-after 'install 'install-sources | ||
| 562 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 563 | (let* ((out (assoc-ref outputs "out")) | ||
| 564 | (share (string-append out "/share/java"))) | ||
| 565 | ;; Copy source jar as sources jar for mx. | ||
| 566 | (copy-file #$source | ||
| 567 | (string-append share "/trufflejws-sources.jar")))))))) | ||
| 568 | (native-inputs (list unzip)) | ||
| 569 | (home-page "https://www.graalvm.org") | ||
| 570 | (synopsis "WebSocket implementation for GraalVM tools") | ||
| 571 | (description "TruffleJWS is a WebSocket library used by GraalVM's | ||
| 572 | Chrome Inspector and other debugging tools. It provides WebSocket client | ||
| 573 | and server implementations for the Truffle framework.") | ||
| 574 | (license upl1.0))) | ||
| 575 | |||
| 576 | ;; GraalVM SDK - standalone foundation with no suite imports. | ||
| 577 | ;; Provides: POLYGLOT, COLLECTIONS, NATIVEIMAGE, WORD, LAUNCHER_COMMON. | ||
| 578 | (define-public graal-sdk | ||
| 579 | (package | ||
| 580 | (name "graal-sdk") | ||
| 581 | (version %graalvm-version) | ||
| 582 | (source %graal-source) | ||
| 583 | (build-system gnu-build-system) | ||
| 584 | (arguments | ||
| 585 | (list | ||
| 586 | #:tests? #f | ||
| 587 | #:phases | ||
| 588 | #~(modify-phases %standard-phases | ||
| 589 | (delete 'configure) | ||
| 590 | (add-after 'unpack 'chdir-to-sdk | ||
| 591 | (lambda _ (chdir "sdk"))) | ||
| 592 | (add-before 'build 'setup-mx-urlrewrites | ||
| 593 | #$(make-mx-urlrewrites-phase %mx-rewrites-jline)) | ||
| 594 | (replace 'build | ||
| 595 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 596 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 597 | (setenv "MX_PYTHON" (which "python3")) | ||
| 598 | ;; Redirect mx's build output and cache to writable locations. | ||
| 599 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 600 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 601 | ;; Build the core SDK distributions including LAUNCHER_COMMON for language launchers. | ||
| 602 | (invoke "mx" "--user-home" (getcwd) | ||
| 603 | "build" "--dependencies" | ||
| 604 | "GRAAL_SDK,WORD,COLLECTIONS,NATIVEIMAGE,POLYGLOT,JLINE3,JNIUTILS,LAUNCHER_COMMON,MAVEN_DOWNLOADER"))) | ||
| 605 | (replace 'install | ||
| 606 | #$(make-mx-install-m2-phase | ||
| 607 | ;; Transitive dependencies match upstream Maven Central poms. | ||
| 608 | '(("GRAAL_SDK" "org.graalvm.sdk" "graal-sdk") | ||
| 609 | ("POLYGLOT" "org.graalvm.polyglot" "polyglot" | ||
| 610 | (("org.graalvm.sdk" "collections") | ||
| 611 | ("org.graalvm.sdk" "nativeimage"))) | ||
| 612 | ("WORD" "org.graalvm.sdk" "word") | ||
| 613 | ("COLLECTIONS" "org.graalvm.sdk" "collections") | ||
| 614 | ("NATIVEIMAGE" "org.graalvm.sdk" "nativeimage" | ||
| 615 | (("org.graalvm.sdk" "word"))) | ||
| 616 | ("JNIUTILS" "org.graalvm.sdk" "jniutils") | ||
| 617 | ("LAUNCHER_COMMON" "org.graalvm.sdk" "launcher-common") | ||
| 618 | ("MAVEN_DOWNLOADER" "org.graalvm.sdk" "maven-downloader")) | ||
| 619 | %graalvm-version))))) | ||
| 620 | (native-inputs | ||
| 621 | (list graalvm-mx | ||
| 622 | (list openjdk "jdk") | ||
| 623 | java-jline-terminal-for-graal-truffle | ||
| 624 | java-jline-reader-for-graal-truffle | ||
| 625 | java-jline-builtins-for-graal-truffle | ||
| 626 | java-jline-terminal-ffm-for-graal-truffle)) | ||
| 627 | (inputs (list python-3)) | ||
| 628 | (home-page "https://www.graalvm.org/") | ||
| 629 | (synopsis "GraalVM SDK and Polyglot API") | ||
| 630 | (description "Foundation libraries for GraalVM including the Polyglot API | ||
| 631 | for language interoperability. To embed guest languages in Java applications, | ||
| 632 | add these JARs to the classpath and use @code{Context.create()} to create a | ||
| 633 | polyglot context, then @code{context.eval(\"language-id\", \"code\")} to execute | ||
| 634 | guest language code. The returned @code{Value} objects provide access to | ||
| 635 | results via methods like @code{asInt()}, @code{getMember()}, and @code{execute()}.") | ||
| 636 | (license upl1.0))) | ||
| 637 | |||
| 638 | ;; Truffle - Language implementation framework | ||
| 639 | ;; Imports: sdk (as subdir) | ||
| 640 | ;; Provides: TRUFFLE_API, TRUFFLE_NFI, TRUFFLE_DSL_PROCESSOR | ||
| 641 | (define-public graal-truffle | ||
| 642 | (package | ||
| 643 | (name "graal-truffle") | ||
| 644 | (version %graalvm-version) | ||
| 645 | (source %graal-source) | ||
| 646 | (build-system gnu-build-system) | ||
| 647 | (arguments | ||
| 648 | (list | ||
| 649 | #:tests? #f | ||
| 650 | #:phases | ||
| 651 | #~(modify-phases %standard-phases | ||
| 652 | (delete 'configure) | ||
| 653 | (add-after 'unpack 'chdir-to-truffle | ||
| 654 | (lambda _ | ||
| 655 | (chdir "truffle"))) | ||
| 656 | (add-before 'build 'setup-mx-urlrewrites | ||
| 657 | #$(make-mx-urlrewrites-phase %mx-rewrites-truffle)) | ||
| 658 | (replace 'build | ||
| 659 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 660 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 661 | (setenv "MX_PYTHON" (which "python3")) | ||
| 662 | ;; Redirect mx's build output and cache to writable locations. | ||
| 663 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 664 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 665 | ;; Fix /bin/sh references in libffi's configure. | ||
| 666 | (setenv "CONFIG_SHELL" (which "bash")) | ||
| 667 | (setenv "SHELL" (which "bash")) | ||
| 668 | ;; Build the Truffle distributions including NFI with libffi. | ||
| 669 | ;; Excluded (need LLVM toolchain): | ||
| 670 | ;; TRUFFLE_NFI_NATIVE_GRAALVM_SUPPORT - needs sdk:LLVM_NINJA_TOOLCHAIN | ||
| 671 | ;; TRUFFLE_ATTACH_GRAALVM_SUPPORT - may need JLINE for launcher | ||
| 672 | (invoke "mx" "--user-home" (getcwd) "build" | ||
| 673 | "--dependencies" (string-join | ||
| 674 | '("TRUFFLE_API" | ||
| 675 | "TRUFFLE_COMPILER" | ||
| 676 | "TRUFFLE_DSL_PROCESSOR" | ||
| 677 | "TRUFFLE_ICU4J" | ||
| 678 | "TRUFFLE_NFI" | ||
| 679 | "TRUFFLE_NFI_LIBFFI" | ||
| 680 | "TRUFFLE_NFI_PANAMA" | ||
| 681 | "TRUFFLE_RUNTIME" | ||
| 682 | "TRUFFLE_XZ") | ||
| 683 | ",")))) | ||
| 684 | (replace 'install | ||
| 685 | #$(make-mx-install-m2-phase | ||
| 686 | '(("TRUFFLE_API" "org.graalvm.truffle" "truffle-api") | ||
| 687 | ("TRUFFLE_COMPILER" "org.graalvm.truffle" "truffle-compiler") | ||
| 688 | ("TRUFFLE_DSL_PROCESSOR" "org.graalvm.truffle" "truffle-dsl-processor") | ||
| 689 | ("TRUFFLE_ICU4J" "org.graalvm.shadowed" "icu4j") | ||
| 690 | ("TRUFFLE_NFI" "org.graalvm.truffle" "truffle-nfi") | ||
| 691 | ("TRUFFLE_NFI_LIBFFI" "org.graalvm.truffle" "truffle-nfi-libffi") | ||
| 692 | ("TRUFFLE_NFI_PANAMA" "org.graalvm.truffle" "truffle-nfi-panama") | ||
| 693 | ("TRUFFLE_RUNTIME" "org.graalvm.truffle" "truffle-runtime") | ||
| 694 | ("TRUFFLE_XZ" "org.graalvm.shadowed" "xz")) | ||
| 695 | %graalvm-version))))) | ||
| 696 | (native-inputs | ||
| 697 | (list (list "mx" graalvm-mx) | ||
| 698 | (list "openjdk" openjdk "jdk") | ||
| 699 | (list "git" git-minimal) | ||
| 700 | (list "bash" bash) | ||
| 701 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 702 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 703 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 704 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 705 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 706 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 707 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 708 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 709 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 710 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 711 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 712 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 713 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 714 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 715 | (list "ninja" ninja-for-graal-truffle) | ||
| 716 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)))) | ||
| 717 | (inputs (list python-3)) | ||
| 718 | (home-page "https://www.graalvm.org/") | ||
| 719 | (synopsis "Truffle language implementation framework") | ||
| 720 | (description "Truffle is a framework for implementing programming languages | ||
| 721 | as self-modifying Abstract Syntax Tree (AST) interpreters. Language implementers | ||
| 722 | extend @code{Node} classes and use the @code{@@Specialization} annotation from | ||
| 723 | the Truffle DSL. Add these JARs to the classpath along with @code{graal-sdk} | ||
| 724 | to build new language implementations. Languages built on Truffle achieve high | ||
| 725 | performance through the Graal JIT compiler when run with @code{-XX:+EnableJVMCI}.") | ||
| 726 | (license upl1.0))) | ||
| 727 | |||
| 728 | ;; Graal Tools - debugging and profiling utilities. | ||
| 729 | ;; This builds the tools suite which imports truffle, so it needs the same | ||
| 730 | ;; URL rewrites and dependencies as graal-truffle. | ||
| 731 | (define-public graal-tools | ||
| 732 | (package | ||
| 733 | (name "graal-tools") | ||
| 734 | (version %graalvm-version) | ||
| 735 | (source %graal-source) | ||
| 736 | (build-system gnu-build-system) | ||
| 737 | (arguments | ||
| 738 | (list | ||
| 739 | #:tests? #f | ||
| 740 | #:phases | ||
| 741 | #~(modify-phases %standard-phases | ||
| 742 | (delete 'configure) | ||
| 743 | (add-after 'unpack 'chdir-to-tools | ||
| 744 | (lambda _ (chdir "tools"))) | ||
| 745 | (add-before 'build 'setup-mx-urlrewrites | ||
| 746 | #$(make-mx-urlrewrites-phase %mx-rewrites-tools)) | ||
| 747 | (replace 'build | ||
| 748 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 749 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 750 | (setenv "MX_PYTHON" (which "python3")) | ||
| 751 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 752 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 753 | ;; Build all tools distributions: | ||
| 754 | ;; - TRUFFLE_PROFILER: CPU sampler and tracer | ||
| 755 | ;; - TRUFFLE_COVERAGE: Code coverage tool | ||
| 756 | ;; - INSIGHT: GraalVM Insight for dynamic instrumentation | ||
| 757 | ;; - DAP: Debug Adapter Protocol support | ||
| 758 | ;; - LSP: Language Server Protocol support | ||
| 759 | ;; - CHROMEINSPECTOR: Chrome DevTools Protocol support | ||
| 760 | (invoke "mx" "--user-home" (getcwd) "build" | ||
| 761 | "--dependencies" | ||
| 762 | "TRUFFLE_PROFILER,TRUFFLE_COVERAGE,INSIGHT,DAP,LSP,CHROMEINSPECTOR"))) | ||
| 763 | (replace 'install | ||
| 764 | #$(make-mx-install-m2-phase | ||
| 765 | '(("TRUFFLE_PROFILER" "org.graalvm.tools" "profiler-tool") | ||
| 766 | ("TRUFFLE_COVERAGE" "org.graalvm.tools" "coverage-tool") | ||
| 767 | ("INSIGHT" "org.graalvm.tools" "insight-tool") | ||
| 768 | ("DAP" "org.graalvm.tools" "dap-tool") | ||
| 769 | ("LSP" "org.graalvm.tools" "lsp-tool") | ||
| 770 | ("CHROMEINSPECTOR" "org.graalvm.tools" "chromeinspector-tool")) | ||
| 771 | %graalvm-version))))) | ||
| 772 | (native-inputs | ||
| 773 | (list (list "mx" graalvm-mx) | ||
| 774 | (list "openjdk" openjdk "jdk") | ||
| 775 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 776 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 777 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 778 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 779 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 780 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 781 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 782 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 783 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 784 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 785 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 786 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 787 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 788 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 789 | (list "java-json" java-json-for-graal-truffle) | ||
| 790 | (list "java-trufflejws" java-trufflejws-for-graal) | ||
| 791 | (list "ninja" ninja-for-graal-truffle) | ||
| 792 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)))) | ||
| 793 | (inputs (list python-3)) | ||
| 794 | (home-page "https://www.graalvm.org/") | ||
| 795 | (synopsis "GraalVM debugging and profiling tools") | ||
| 796 | (description "Development tools for GraalVM Truffle languages: | ||
| 797 | @itemize | ||
| 798 | @item CPU Sampler (@code{--cpusampler}): Profile guest language code | ||
| 799 | @item Code Coverage (@code{--coverage}): Track code coverage | ||
| 800 | @item GraalVM Insight: Dynamic instrumentation and tracing | ||
| 801 | @item Debug Adapter Protocol (DAP): IDE debugging integration | ||
| 802 | @item Language Server Protocol (LSP): IDE language features | ||
| 803 | @item Chrome DevTools (@code{--inspect}): Browser-based debugging | ||
| 804 | @end itemize | ||
| 805 | Use these flags with language launchers like @code{graalpy} or @code{js}.") | ||
| 806 | (license upl1.0))) | ||
| 807 | |||
| 808 | ;; Graal Regex - TRegex regular expression engine | ||
| 809 | ;; This builds the regex suite which imports truffle, so it needs the same | ||
| 810 | ;; URL rewrites and dependencies as graal-truffle. | ||
| 811 | (define-public graal-regex | ||
| 812 | (package | ||
| 813 | (name "graal-regex") | ||
| 814 | (version %graalvm-version) | ||
| 815 | (source %graal-source) | ||
| 816 | (build-system gnu-build-system) | ||
| 817 | (arguments | ||
| 818 | (list | ||
| 819 | #:tests? #f | ||
| 820 | #:phases | ||
| 821 | #~(modify-phases %standard-phases | ||
| 822 | (delete 'configure) | ||
| 823 | (add-after 'unpack 'chdir-to-regex | ||
| 824 | (lambda _ (chdir "regex"))) | ||
| 825 | (add-before 'build 'setup-mx-urlrewrites | ||
| 826 | #$(make-mx-urlrewrites-phase %mx-rewrites-regex)) | ||
| 827 | (replace 'build | ||
| 828 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 829 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 830 | (setenv "MX_PYTHON" (which "python3")) | ||
| 831 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 832 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 833 | (invoke "mx" "--user-home" (getcwd) "build" | ||
| 834 | "--dependencies" "TREGEX"))) | ||
| 835 | (replace 'install | ||
| 836 | #$(make-mx-install-m2-phase | ||
| 837 | '(("TREGEX" "org.graalvm.regex" "regex")) | ||
| 838 | %graalvm-version))))) | ||
| 839 | (native-inputs (list graalvm-mx | ||
| 840 | (list openjdk "jdk") | ||
| 841 | ninja-for-graal-truffle | ||
| 842 | java-asm-for-graal-truffle | ||
| 843 | java-asm-tree-for-graal-truffle | ||
| 844 | java-asm-analysis-for-graal-truffle | ||
| 845 | java-asm-util-for-graal-truffle | ||
| 846 | java-asm-commons-for-graal-truffle | ||
| 847 | java-antlr4-runtime-for-graal-truffle | ||
| 848 | java-icu4j-for-graal-truffle | ||
| 849 | java-icu4j-charset-for-graal-truffle | ||
| 850 | java-xz-for-graal-truffle)) | ||
| 851 | (inputs (list python-3)) | ||
| 852 | (home-page "https://www.graalvm.org/") | ||
| 853 | (synopsis "TRegex regular expression engine for GraalVM") | ||
| 854 | (description "TRegex is a high-performance regular expression engine | ||
| 855 | used internally by GraalVM languages like GraalJS and GraalPy for pattern | ||
| 856 | matching. Language implementers can use @code{TruffleRegexCompiler} to compile | ||
| 857 | regex patterns, or access it via the Truffle interop protocol. End users | ||
| 858 | typically do not use this package directly.") | ||
| 859 | (license upl1.0))) | ||
| 860 | |||
| 861 | ;; Graal Compiler - the JIT compiler for GraalVM | ||
| 862 | ;; This builds the compiler suite which imports truffle, regex, and sdk. | ||
| 863 | (define-public graal-compiler | ||
| 864 | (package | ||
| 865 | (name "graal-compiler") | ||
| 866 | (version %graalvm-version) | ||
| 867 | (source %graal-source) | ||
| 868 | (build-system gnu-build-system) | ||
| 869 | (arguments | ||
| 870 | (list | ||
| 871 | #:tests? #f | ||
| 872 | #:phases | ||
| 873 | #~(modify-phases %standard-phases | ||
| 874 | (delete 'configure) | ||
| 875 | (add-after 'unpack 'chdir-to-compiler | ||
| 876 | (lambda _ (chdir "compiler"))) | ||
| 877 | (add-before 'build 'setup-mx-urlrewrites | ||
| 878 | #$(make-mx-urlrewrites-phase %mx-rewrites-truffle)) | ||
| 879 | (replace 'build | ||
| 880 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 881 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 882 | (setenv "MX_PYTHON" (which "python3")) | ||
| 883 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 884 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 885 | ;; Build the core compiler distributions. | ||
| 886 | ;; GRAAL is the main compiler JAR for use with --upgrade-module-path. | ||
| 887 | ;; GRAAL_MANAGEMENT provides JMX management beans. | ||
| 888 | (invoke "mx" "--user-home" (getcwd) "build" | ||
| 889 | "--dependencies" "GRAAL,GRAAL_MANAGEMENT"))) | ||
| 890 | (replace 'install | ||
| 891 | #$(make-mx-install-m2-phase | ||
| 892 | '(("GRAAL" "org.graalvm.compiler" "compiler") | ||
| 893 | ("GRAAL_MANAGEMENT" "org.graalvm.compiler" "compiler-management")) | ||
| 894 | %graalvm-version))))) | ||
| 895 | (native-inputs | ||
| 896 | (list (list "mx" graalvm-mx) | ||
| 897 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 898 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 899 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 900 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 901 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 902 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 903 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 904 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 905 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 906 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 907 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 908 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 909 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 910 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 911 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 912 | (list "ninja" ninja-for-graal-truffle) | ||
| 913 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)))) | ||
| 914 | (inputs (list python-3)) | ||
| 915 | (propagated-inputs | ||
| 916 | (list graal-sdk graal-truffle (list openjdk "graal-builder-jdk"))) | ||
| 917 | (home-page "https://www.graalvm.org/") | ||
| 918 | (synopsis "Graal JIT compiler for the JVM") | ||
| 919 | (description "The Graal compiler is a high-performance JIT compiler for | ||
| 920 | the JVM that can be used as a replacement for the C2 compiler. It provides | ||
| 921 | optimizations specifically tuned for dynamic languages. Requires | ||
| 922 | @code{openjdk} with the @code{graal-builder-jdk} output which has JVMCI exports | ||
| 923 | configured for Graal. | ||
| 924 | Example usage: | ||
| 925 | @example | ||
| 926 | java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI \\ | ||
| 927 | --upgrade-module-path=$GUIX_ENVIRONMENT/lib/m2/org/graalvm/compiler/compiler/25.0.1/compiler-25.0.1.jar \\ | ||
| 928 | -XX:+UseJVMCICompiler YourApp | ||
| 929 | @end example") | ||
| 930 | (license (list license:gpl2+ ; with Classpath exception | ||
| 931 | upl1.0)))) | ||
| 932 | |||
| 933 | ;; SubstrateVM - Ahead-of-time compilation for Java (native-image) | ||
| 934 | ;; This builds the substratevm suite which imports compiler and espresso-shared. | ||
| 935 | (define-public graal-substratevm | ||
| 936 | (package | ||
| 937 | (name "graal-substratevm") | ||
| 938 | (version %graalvm-version) | ||
| 939 | (source %graal-source) | ||
| 940 | (build-system gnu-build-system) | ||
| 941 | (arguments | ||
| 942 | (list | ||
| 943 | #:tests? #f | ||
| 944 | #:phases | ||
| 945 | #~(modify-phases %standard-phases | ||
| 946 | (delete 'configure) | ||
| 947 | (add-after 'unpack 'chdir-to-substratevm | ||
| 948 | (lambda _ (chdir "substratevm"))) | ||
| 949 | (add-before 'build 'setup-mx-urlrewrites | ||
| 950 | #$(make-mx-urlrewrites-phase %mx-rewrites-substratevm)) | ||
| 951 | (replace 'build | ||
| 952 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 953 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 954 | (setenv "MX_PYTHON" (which "python3")) | ||
| 955 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 956 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 957 | ;; Build the native-image driver and its dependencies. | ||
| 958 | ;; SVM_DRIVER is the native-image building tool. | ||
| 959 | ;; SVM is the main SubstrateVM image builder. | ||
| 960 | (invoke "mx" "--user-home" (getcwd) "build" | ||
| 961 | "--dependencies" "SVM_DRIVER,SVM"))) | ||
| 962 | (replace 'install | ||
| 963 | #$(make-mx-install-phase '("SVM_DRIVER" "SVM") "svm"))))) | ||
| 964 | (native-inputs | ||
| 965 | (list (list "mx" graalvm-mx) | ||
| 966 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 967 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 968 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 969 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 970 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 971 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 972 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 973 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 974 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 975 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 976 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 977 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 978 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 979 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 980 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 981 | (list "ninja" ninja-for-graal-truffle) | ||
| 982 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)) | ||
| 983 | (list "java-capnproto-runtime" java-capnproto-runtime-for-graal-truffle))) | ||
| 984 | (inputs (list python-3)) | ||
| 985 | (home-page "https://www.graalvm.org/") | ||
| 986 | (synopsis "Ahead-of-time compilation for Java applications") | ||
| 987 | (description "SubstrateVM provides the core libraries for ahead-of-time (AOT) | ||
| 988 | compilation of Java applications. These JARs are used by the @command{native-image} | ||
| 989 | tool to compile Java bytecode into standalone native executables. Note: this | ||
| 990 | package provides the SVM libraries; the full @command{native-image} tool requires | ||
| 991 | additional GraalVM components. The resulting native binaries start instantly | ||
| 992 | and use less memory than traditional JVM-based applications.") | ||
| 993 | (license (list license:gpl2+ ; with Classpath exception | ||
| 994 | upl1.0)))) | ||
| 995 | |||
| 996 | (define-public graal-wasm | ||
| 997 | (package | ||
| 998 | (name "graal-wasm") | ||
| 999 | (version %graalvm-version) | ||
| 1000 | (source %graal-source) | ||
| 1001 | (build-system gnu-build-system) | ||
| 1002 | (arguments | ||
| 1003 | (list | ||
| 1004 | #:tests? #f | ||
| 1005 | #:phases | ||
| 1006 | #~(modify-phases %standard-phases | ||
| 1007 | (delete 'configure) | ||
| 1008 | (add-after 'unpack 'chdir-to-wasm | ||
| 1009 | (lambda _ | ||
| 1010 | (chdir "wasm"))) | ||
| 1011 | (add-before 'build 'setup-mx-urlrewrites | ||
| 1012 | #$(make-mx-urlrewrites-phase %mx-rewrites-truffle)) | ||
| 1013 | (replace 'build | ||
| 1014 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1015 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 1016 | (setenv "MX_PYTHON" (which "python3")) | ||
| 1017 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 1018 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 1019 | ;; Build the WebAssembly runtime and launcher. | ||
| 1020 | (invoke "mx" "--user-home" (getcwd) "build" | ||
| 1021 | "--dependencies" "WASM,WASM_LAUNCHER"))) | ||
| 1022 | (replace 'install | ||
| 1023 | #$(make-mx-install-phase '("WASM" "WASM_LAUNCHER") "wasm"))))) | ||
| 1024 | (native-inputs | ||
| 1025 | (list (list "mx" graalvm-mx) | ||
| 1026 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 1027 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 1028 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 1029 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 1030 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 1031 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 1032 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 1033 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 1034 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 1035 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 1036 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 1037 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 1038 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 1039 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 1040 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 1041 | (list "ninja" ninja-for-graal-truffle) | ||
| 1042 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)))) | ||
| 1043 | (inputs (list python-3)) | ||
| 1044 | (home-page "https://www.graalvm.org/webassembly/") | ||
| 1045 | (synopsis "High-performance WebAssembly runtime for Java") | ||
| 1046 | (description "GraalWasm is a high-performance embeddable WebAssembly runtime | ||
| 1047 | for Java. Add these JARs along with @code{graal-sdk} and @code{graal-truffle} | ||
| 1048 | to the classpath, then use @code{Context.newBuilder(\"wasm\").build()} to create | ||
| 1049 | a context and @code{context.eval(Source.newBuilder(\"wasm\", wasmFile).build())} | ||
| 1050 | to load modules. Access exported functions via @code{getMember(\"exports\")}. | ||
| 1051 | Supports WebAssembly MVP and various post-MVP proposals.") | ||
| 1052 | (license upl1.0))) | ||
| 1053 | |||
| 1054 | ;; Imports: truffle, sdk | ||
| 1055 | ;; Provides: ESPRESSO_SHARED | ||
| 1056 | (define-public graal-espresso-shared | ||
| 1057 | (package | ||
| 1058 | (name "graal-espresso-shared") | ||
| 1059 | (version %graalvm-version) | ||
| 1060 | (source %graal-source) | ||
| 1061 | (build-system gnu-build-system) | ||
| 1062 | (arguments | ||
| 1063 | (list | ||
| 1064 | #:tests? #f | ||
| 1065 | #:phases | ||
| 1066 | #~(modify-phases %standard-phases | ||
| 1067 | (delete 'configure) | ||
| 1068 | (add-after 'unpack 'chdir-to-espresso-shared | ||
| 1069 | (lambda _ | ||
| 1070 | (chdir "espresso-shared"))) | ||
| 1071 | (add-before 'build 'setup-mx-urlrewrites | ||
| 1072 | #$(make-mx-urlrewrites-phase %mx-rewrites-truffle)) | ||
| 1073 | (replace 'build | ||
| 1074 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1075 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 1076 | (setenv "MX_PYTHON" (which "python3")) | ||
| 1077 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) | ||
| 1078 | "/mxbuild-output")) | ||
| 1079 | (setenv "MX_CACHE_DIR" (string-append (getcwd) | ||
| 1080 | "/mx-cache")) | ||
| 1081 | (invoke "mx" "--user-home" (getcwd) | ||
| 1082 | "build" | ||
| 1083 | "--dependencies" "ESPRESSO_SHARED"))) | ||
| 1084 | (replace 'install | ||
| 1085 | #$(make-mx-install-phase '("ESPRESSO_SHARED") | ||
| 1086 | "espresso-shared"))))) | ||
| 1087 | (native-inputs | ||
| 1088 | (list (list "mx" graalvm-mx) | ||
| 1089 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 1090 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 1091 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 1092 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 1093 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 1094 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 1095 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 1096 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 1097 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 1098 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 1099 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 1100 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 1101 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 1102 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 1103 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 1104 | (list "ninja" ninja-for-graal-truffle) | ||
| 1105 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)))) | ||
| 1106 | (inputs (list python-3)) | ||
| 1107 | (home-page "https://www.graalvm.org/jdk21/reference-manual/java-on-truffle/") | ||
| 1108 | (synopsis "Espresso shared code for runtime class loading") | ||
| 1109 | (description "Shared code used by Espresso (Java on Truffle) for runtime | ||
| 1110 | class loading. This package provides the @code{org.graalvm.espresso.shared} | ||
| 1111 | module required by the main Espresso runtime.") | ||
| 1112 | (license license:gpl2))) ;gpl2 only, with classpath exception | ||
| 1113 | |||
| 1114 | ;; Espresso - Java on Truffle (Java bytecode interpreter) | ||
| 1115 | ;; This builds the espresso suite which imports truffle, tools, sulong, sdk, espresso-shared. | ||
| 1116 | (define-public graal-espresso | ||
| 1117 | (package | ||
| 1118 | (name "graal-espresso") | ||
| 1119 | (version %graalvm-version) | ||
| 1120 | (source %graal-source) | ||
| 1121 | (build-system gnu-build-system) | ||
| 1122 | (arguments | ||
| 1123 | (list | ||
| 1124 | #:tests? #f | ||
| 1125 | #:modules '((guix build gnu-build-system) | ||
| 1126 | (guix build utils) | ||
| 1127 | (ice-9 match)) | ||
| 1128 | #:phases | ||
| 1129 | #~(modify-phases %standard-phases | ||
| 1130 | (delete 'configure) | ||
| 1131 | (add-after 'unpack 'chdir-to-espresso | ||
| 1132 | (lambda _ | ||
| 1133 | (chdir "espresso"))) | ||
| 1134 | (add-before 'build 'setup-mx-urlrewrites | ||
| 1135 | #$(make-mx-urlrewrites-phase %mx-rewrites-truffle)) | ||
| 1136 | (replace 'build | ||
| 1137 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1138 | (setenv "JAVA_HOME" (assoc-ref inputs "openjdk")) | ||
| 1139 | (setenv "MX_PYTHON" (which "python3")) | ||
| 1140 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) | ||
| 1141 | "/mxbuild-output")) | ||
| 1142 | (setenv "MX_CACHE_DIR" (string-append (getcwd) | ||
| 1143 | "/mx-cache")) | ||
| 1144 | ;; Build the Espresso runtime and launcher. | ||
| 1145 | (invoke "mx" "--user-home" (getcwd) | ||
| 1146 | "build" | ||
| 1147 | "--dependencies" "ESPRESSO,ESPRESSO_LAUNCHER"))) | ||
| 1148 | (replace 'install | ||
| 1149 | #$(make-mx-install-phase '("ESPRESSO" "ESPRESSO_LAUNCHER") | ||
| 1150 | "espresso")) | ||
| 1151 | (add-after 'install 'create-launcher | ||
| 1152 | (lambda* (#:key inputs outputs #:allow-other-keys) | ||
| 1153 | (let* ((out (assoc-ref outputs "out")) | ||
| 1154 | (bin (string-append out "/bin")) | ||
| 1155 | (lib (string-append out "/lib/espresso")) | ||
| 1156 | (sdk-base (assoc-ref inputs "graal-sdk")) | ||
| 1157 | (version #$%graalvm-version) | ||
| 1158 | (sdk-jars | ||
| 1159 | (map (match-lambda | ||
| 1160 | ((group-path artifact) | ||
| 1161 | (string-append sdk-base "/lib/m2/" group-path "/" | ||
| 1162 | artifact "/" version "/" | ||
| 1163 | artifact "-" version ".jar"))) | ||
| 1164 | '(("org/graalvm/sdk" "graal-sdk") | ||
| 1165 | ("org/graalvm/polyglot" "polyglot") | ||
| 1166 | ("org/graalvm/sdk" "word") | ||
| 1167 | ("org/graalvm/sdk" "collections") | ||
| 1168 | ("org/graalvm/sdk" "nativeimage") | ||
| 1169 | ("org/graalvm/sdk" "jniutils") | ||
| 1170 | ("org/graalvm/sdk" "launcher-common")))) | ||
| 1171 | (truffle-base (assoc-ref inputs "graal-truffle")) | ||
| 1172 | (truffle-jars | ||
| 1173 | (map (match-lambda | ||
| 1174 | ((group-path artifact) | ||
| 1175 | (string-append truffle-base "/lib/m2/" group-path "/" | ||
| 1176 | artifact "/" version "/" | ||
| 1177 | artifact "-" version ".jar"))) | ||
| 1178 | '(("org/graalvm/truffle" "truffle-api") | ||
| 1179 | ("org/graalvm/truffle" "truffle-compiler") | ||
| 1180 | ("org/graalvm/truffle" "truffle-nfi") | ||
| 1181 | ("org/graalvm/truffle" "truffle-nfi-libffi") | ||
| 1182 | ("org/graalvm/truffle" "truffle-nfi-panama") | ||
| 1183 | ("org/graalvm/truffle" "truffle-runtime")))) | ||
| 1184 | (shared-lib (string-append (assoc-ref inputs "graal-espresso-shared") | ||
| 1185 | "/lib/espresso-shared")) | ||
| 1186 | (jdk (assoc-ref inputs "openjdk")) | ||
| 1187 | (module-path (string-join (append (list lib) | ||
| 1188 | sdk-jars | ||
| 1189 | truffle-jars | ||
| 1190 | (list shared-lib)) | ||
| 1191 | ":"))) | ||
| 1192 | (mkdir-p bin) | ||
| 1193 | (call-with-output-file (string-append bin "/espresso") | ||
| 1194 | (lambda (port) | ||
| 1195 | (format port "#!~a | ||
| 1196 | exec ~a/bin/java \\ | ||
| 1197 | --module-path ~a \\ | ||
| 1198 | -m org.graalvm.espresso.launcher/com.oracle.truffle.espresso.launcher.EspressoLauncher \\ | ||
| 1199 | \"$@\" | ||
| 1200 | " | ||
| 1201 | (which "bash") | ||
| 1202 | jdk module-path))) | ||
| 1203 | (chmod (string-append bin "/espresso") | ||
| 1204 | #o755))))))) | ||
| 1205 | (native-inputs | ||
| 1206 | (list (list "mx" graalvm-mx) | ||
| 1207 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 1208 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 1209 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 1210 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 1211 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 1212 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 1213 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 1214 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 1215 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 1216 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 1217 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 1218 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 1219 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 1220 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 1221 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 1222 | (list "ninja" ninja-for-graal-truffle) | ||
| 1223 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)))) | ||
| 1224 | (inputs | ||
| 1225 | (list (list "python" python-3) | ||
| 1226 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 1227 | (list "bash" bash-minimal) | ||
| 1228 | (list "graal-sdk" graal-sdk) | ||
| 1229 | (list "graal-truffle" graal-truffle) | ||
| 1230 | (list "graal-espresso-shared" graal-espresso-shared))) | ||
| 1231 | (home-page "https://www.graalvm.org/jdk21/reference-manual/java-on-truffle/") | ||
| 1232 | (synopsis "Java bytecode interpreter on Truffle") | ||
| 1233 | (description "Espresso is a Java bytecode interpreter (Java on Truffle) that | ||
| 1234 | runs Java applications on GraalVM's Truffle framework. Run the @command{espresso} | ||
| 1235 | launcher to execute Java applications, or embed via the Polyglot API with | ||
| 1236 | @code{Context.newBuilder(\"java\").build()}. Espresso provides full Java | ||
| 1237 | compatibility while enabling polyglot interoperability with other Truffle | ||
| 1238 | languages. Supports debugging, HotSwap, and GraalVM tooling integration.") | ||
| 1239 | (license license:gpl2))) | ||
| 1240 | |||
| 1241 | ;; GraalPy - Python 3.12 implementation on GraalVM | ||
| 1242 | (define-public graalpy-community | ||
| 1243 | (package | ||
| 1244 | (name "graalpy-community") | ||
| 1245 | (version %graalvm-version) | ||
| 1246 | (source (origin | ||
| 1247 | (method git-fetch) | ||
| 1248 | (uri (git-reference | ||
| 1249 | (url "https://github.com/oracle/graalpython") | ||
| 1250 | (commit (string-append "graal-" version)))) | ||
| 1251 | (file-name (git-file-name name version)) | ||
| 1252 | (sha256 | ||
| 1253 | (base32 "19w22gw1ixkgy2c79m9xfhw9xvxl5vc68vddal7vq6dbsyh3g2lh")))) | ||
| 1254 | (build-system gnu-build-system) | ||
| 1255 | (arguments | ||
| 1256 | (list | ||
| 1257 | #:tests? #f | ||
| 1258 | #:modules '((guix build gnu-build-system) | ||
| 1259 | (guix build utils) | ||
| 1260 | (ice-9 match) | ||
| 1261 | (sxml simple)) | ||
| 1262 | #:phases | ||
| 1263 | #~(modify-phases %standard-phases | ||
| 1264 | (delete 'configure) | ||
| 1265 | (add-after 'unpack 'fix-cmake-minimum-version | ||
| 1266 | (lambda _ | ||
| 1267 | ;; pegparser.generator uses cmake 3.0 which is rejected by newer cmake. | ||
| 1268 | (substitute* "graalpython/com.oracle.graal.python.pegparser.generator/CMakeLists.txt" | ||
| 1269 | (("cmake_minimum_required\\(VERSION 3\\.0\\)") | ||
| 1270 | "cmake_minimum_required(VERSION 3.5)")))) | ||
| 1271 | (add-after 'unpack 'setup-graal-sources | ||
| 1272 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1273 | ;; mx expects to find the graal repository as a sibling directory. | ||
| 1274 | ;; The graalpython suite.py imports sdk, truffle, tools, regex from graal. | ||
| 1275 | ;; | ||
| 1276 | ;; We MUST use copy-recursively here, NOT symlink, because mx needs | ||
| 1277 | ;; to write to various directories during the build: | ||
| 1278 | ;; | ||
| 1279 | ;; 1. ShadedLibraryProject (mx_sdk_shaded.py): These projects generate | ||
| 1280 | ;; shaded/relocated Java bytecode at build time. mx creates output | ||
| 1281 | ;; directories like truffle/src/com.oracle.truffle.api.impl.asm/ | ||
| 1282 | ;; to store the generated .class files. There are ~10 such projects | ||
| 1283 | ;; across espresso, sdk, substratevm, and truffle suites. | ||
| 1284 | ;; | ||
| 1285 | ;; 2. DefaultNativeProject (mx_native.py): These projects create | ||
| 1286 | ;; 'include' subdirectories for header files and write build | ||
| 1287 | ;; artifacts to various locations within native project directories. | ||
| 1288 | ;; | ||
| 1289 | ;; 3. Build outputs: mx writes various build artifacts, caches, and | ||
| 1290 | ;; intermediate files throughout the source tree during compilation. | ||
| 1291 | (let ((graal-src (assoc-ref inputs "graal-25.0.1-checkout"))) | ||
| 1292 | (copy-recursively graal-src "../graal") | ||
| 1293 | (when (not (file-exists? "../graal/sdk/mx.sdk/suite.py")) | ||
| 1294 | (error "graal source not set up correctly"))))) | ||
| 1295 | (add-before 'build 'setup-mx-urlrewrites | ||
| 1296 | #$(make-mx-urlrewrites-phase %mx-rewrites-graalpy)) | ||
| 1297 | (add-after 'setup-graal-sources 'setup-environment | ||
| 1298 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1299 | (let ((jdk (assoc-ref inputs "openjdk"))) | ||
| 1300 | (setenv "JAVA_HOME" jdk)) | ||
| 1301 | ;; Do NOT set STANDALONE_JAVA_HOME - we want mx to build a full | ||
| 1302 | ;; jimage with libgraal (libjvmcicompiler.so) baked in. | ||
| 1303 | (setenv "MX_PYTHON" (which "python3")) | ||
| 1304 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 1305 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 1306 | ;; CONFIG_SHELL is needed so autoconf-based builds (like libffi) | ||
| 1307 | ;; use the correct shell instead of /bin/sh which doesn't exist | ||
| 1308 | (setenv "CONFIG_SHELL" (which "bash")) | ||
| 1309 | (setenv "SHELL" (which "bash")) | ||
| 1310 | ;; OpenJDK JVMCI: 25.0.1, GraalVM expects: 25.0.1+8-jvmci-b01 | ||
| 1311 | (setenv "JVMCI_VERSION_CHECK" "ignore"))) | ||
| 1312 | (add-before 'build 'patch-libgraal-env | ||
| 1313 | (lambda _ | ||
| 1314 | ;; Add svm,ni so native-image is available to build libjvmcicompiler.so. | ||
| 1315 | (substitute* "mx.graalpython/jvm-ce-libgraal" | ||
| 1316 | (("COMPONENTS=LibGraal") | ||
| 1317 | "COMPONENTS=LibGraal,svm,ni")) | ||
| 1318 | ;; Remove musl from extra_native_targets to avoid needing musl toolchain. | ||
| 1319 | (substitute* "../graal/substratevm/mx.substratevm/mx_substratevm.py" | ||
| 1320 | (("'linux-default-glibc', 'linux-default-musl'") | ||
| 1321 | "'linux-default-glibc'")) | ||
| 1322 | ;; Fix launcher_template.sh shebang - /usr/bin/env doesn't exist in Guix. | ||
| 1323 | ;; The native-image bash launcher uses this template. | ||
| 1324 | (let ((bash (which "bash"))) | ||
| 1325 | (substitute* "../graal/sdk/mx.sdk/vm/launcher_template.sh" | ||
| 1326 | (("#!/usr/bin/env bash") | ||
| 1327 | (string-append "#!" bash)))) | ||
| 1328 | ;; Propagate gcc environment variables through native-image's env sanitization. | ||
| 1329 | ;; native-image's sanitizeJVMEnvironment (NativeImage.java) strips all env vars | ||
| 1330 | ;; except a whitelist (PATH, HOME, etc). The -E<varname> flag passes vars through. | ||
| 1331 | ;; mx already does this for JVMCI_VERSION_CHECK; we add gcc include/library paths. | ||
| 1332 | (substitute* "../graal/sdk/mx.sdk/mx_sdk_vm_impl.py" | ||
| 1333 | (("'-EJVMCI_VERSION_CHECK',") | ||
| 1334 | (string-append "'-EJVMCI_VERSION_CHECK',\n" | ||
| 1335 | " '-EC_INCLUDE_PATH',\n" | ||
| 1336 | " '-ECPLUS_INCLUDE_PATH',\n" | ||
| 1337 | " '-ELIBRARY_PATH',\n" | ||
| 1338 | " '-ECPATH', # C include path\n"))))) | ||
| 1339 | (replace 'build | ||
| 1340 | (lambda _ | ||
| 1341 | ;; Build Python for JVM with Graal JIT compiler using jvm-ce-libgraal env. | ||
| 1342 | ;; Also build GRAALPYTHON_RESOURCES for Maven embedding use cases. | ||
| 1343 | (invoke "mx" "--user-home" (getcwd) | ||
| 1344 | "--env" "jvm-ce-libgraal" | ||
| 1345 | "build" | ||
| 1346 | "--target" "GRAALPY_JVM_STANDALONE,GRAALPYTHON_RESOURCES"))) | ||
| 1347 | (replace 'install | ||
| 1348 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 1349 | (let ((out (assoc-ref outputs "out"))) | ||
| 1350 | (match (find-files (string-append (getcwd) "/mxbuild-output/graalpython") | ||
| 1351 | "^GRAALPY_JVM_STANDALONE$" | ||
| 1352 | #:directories? #t) | ||
| 1353 | ((standalone-dir . _) | ||
| 1354 | (copy-recursively standalone-dir out)))))) | ||
| 1355 | ;; Install all GraalVM JARs as Maven artifacts in /lib/m2 format. | ||
| 1356 | ;; This enables maven-build-system packages to depend on graalpy-community. | ||
| 1357 | (add-after 'install 'install-m2 | ||
| 1358 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 1359 | (let* ((out (assoc-ref outputs "out")) | ||
| 1360 | (modules-dir (string-append out "/modules")) | ||
| 1361 | (version #$%graalvm-version) | ||
| 1362 | ;; Mapping: (jar-basename group-id artifact-id) | ||
| 1363 | ;; Only install JARs unique to graalpy-community. | ||
| 1364 | ;; Other JARs are provided by: graal-sdk, graal-truffle, | ||
| 1365 | ;; graal-tools, graal-regex. | ||
| 1366 | (jar-mapping | ||
| 1367 | '(;; org.graalvm.python - graalpy-specific | ||
| 1368 | ("graalpython" "org.graalvm.python" "python-language") | ||
| 1369 | ("graalpython-launcher" "org.graalvm.python" "python-launcher"))) | ||
| 1370 | ;; POM-only metapackages (no JARs, just dependency aggregators) | ||
| 1371 | ;; These are needed for Maven dependency resolution. | ||
| 1372 | ;; Dependency format: (dependency group artifact [type] [scope]) | ||
| 1373 | ;; When type/scope are omitted, Maven defaults to jar/compile. | ||
| 1374 | (pom-metapackages | ||
| 1375 | '(;; org.graalvm.python:python - aggregates python-language + deps | ||
| 1376 | ("org.graalvm.python" "python" | ||
| 1377 | ((dependency "org.graalvm.python" "python-language") | ||
| 1378 | (dependency "org.graalvm.python" "python-resources") | ||
| 1379 | (dependency "org.graalvm.truffle" "truffle-runtime"))) | ||
| 1380 | ;; org.graalvm.polyglot:python - meta-package for embedding | ||
| 1381 | ;; This wraps org.graalvm.python:python with type=pom, scope=runtime | ||
| 1382 | ("org.graalvm.polyglot" "python" | ||
| 1383 | ((dependency "org.graalvm.python" "python" "pom" "runtime")))))) | ||
| 1384 | ;; Install JARs | ||
| 1385 | (for-each | ||
| 1386 | (match-lambda | ||
| 1387 | ((jar-basename group-id artifact-id) | ||
| 1388 | (let* ((jar-file (string-append modules-dir "/" jar-basename ".jar")) | ||
| 1389 | (m2-dir (string-append out "/lib/m2/" | ||
| 1390 | (string-join (string-split group-id #\.) "/") | ||
| 1391 | "/" artifact-id "/" version)) | ||
| 1392 | (jar-dest (string-append m2-dir "/" artifact-id "-" version ".jar")) | ||
| 1393 | (pom-dest (string-append m2-dir "/" artifact-id "-" version ".pom"))) | ||
| 1394 | (when (file-exists? jar-file) | ||
| 1395 | (format #t "Installing ~a -> ~a~%" jar-basename m2-dir) | ||
| 1396 | (mkdir-p m2-dir) | ||
| 1397 | (copy-file jar-file jar-dest) | ||
| 1398 | ;; Create minimal POM for Maven dependency resolution | ||
| 1399 | (call-with-output-file pom-dest | ||
| 1400 | (lambda (port) | ||
| 1401 | (sxml->xml | ||
| 1402 | `(*TOP* | ||
| 1403 | (*PI* xml "version=\"1.0\"") | ||
| 1404 | (project | ||
| 1405 | (modelVersion "4.0.0") | ||
| 1406 | (groupId ,group-id) | ||
| 1407 | (artifactId ,artifact-id) | ||
| 1408 | (version ,version))) | ||
| 1409 | port))))))) | ||
| 1410 | jar-mapping) | ||
| 1411 | ;; Install POM-only metapackages (no JARs) | ||
| 1412 | (for-each | ||
| 1413 | (match-lambda | ||
| 1414 | ((group-id artifact-id deps) | ||
| 1415 | (let* ((m2-dir (string-append out "/lib/m2/" | ||
| 1416 | (string-join (string-split group-id #\.) "/") | ||
| 1417 | "/" artifact-id "/" version)) | ||
| 1418 | (pom-dest (string-append m2-dir "/" artifact-id "-" version ".pom"))) | ||
| 1419 | (format #t "Installing POM metapackage ~a:~a~%" group-id artifact-id) | ||
| 1420 | (mkdir-p m2-dir) | ||
| 1421 | (call-with-output-file pom-dest | ||
| 1422 | (lambda (port) | ||
| 1423 | (sxml->xml | ||
| 1424 | `(*TOP* | ||
| 1425 | (*PI* xml "version=\"1.0\"") | ||
| 1426 | (project | ||
| 1427 | (modelVersion "4.0.0") | ||
| 1428 | (groupId ,group-id) | ||
| 1429 | (artifactId ,artifact-id) | ||
| 1430 | (version ,version) | ||
| 1431 | (packaging "pom") | ||
| 1432 | (dependencies | ||
| 1433 | ,@(map (match-lambda | ||
| 1434 | (('dependency dep-group dep-artifact) | ||
| 1435 | `(dependency | ||
| 1436 | (groupId ,dep-group) | ||
| 1437 | (artifactId ,dep-artifact) | ||
| 1438 | (version ,version))) | ||
| 1439 | (('dependency dep-group dep-artifact dep-type dep-scope) | ||
| 1440 | `(dependency | ||
| 1441 | (groupId ,dep-group) | ||
| 1442 | (artifactId ,dep-artifact) | ||
| 1443 | (version ,version) | ||
| 1444 | (type ,dep-type) | ||
| 1445 | (scope ,dep-scope)))) | ||
| 1446 | deps)))) | ||
| 1447 | port)))))) | ||
| 1448 | pom-metapackages) | ||
| 1449 | ;; Install python-resources JAR from mx build output. | ||
| 1450 | ;; This JAR contains the Python stdlib and is needed for Maven embedding. | ||
| 1451 | (let* ((resources-jar | ||
| 1452 | (match (find-files (string-append (getcwd) "/mxbuild-output") | ||
| 1453 | "python-resources\\.jar$") | ||
| 1454 | ((jar . _) jar) | ||
| 1455 | (_ #f))) | ||
| 1456 | (m2-dir (string-append out "/lib/m2/org/graalvm/python/python-resources/" version)) | ||
| 1457 | (jar-dest (string-append m2-dir "/python-resources-" version ".jar")) | ||
| 1458 | (pom-dest (string-append m2-dir "/python-resources-" version ".pom"))) | ||
| 1459 | (if resources-jar | ||
| 1460 | (begin | ||
| 1461 | (format #t "Installing python-resources.jar from ~a~%" resources-jar) | ||
| 1462 | (mkdir-p m2-dir) | ||
| 1463 | (copy-file resources-jar jar-dest) | ||
| 1464 | (call-with-output-file pom-dest | ||
| 1465 | (lambda (port) | ||
| 1466 | (sxml->xml | ||
| 1467 | `(*TOP* | ||
| 1468 | (*PI* xml "version=\"1.0\"") | ||
| 1469 | (project | ||
| 1470 | (modelVersion "4.0.0") | ||
| 1471 | (groupId "org.graalvm.python") | ||
| 1472 | (artifactId "python-resources") | ||
| 1473 | (version ,version))) | ||
| 1474 | port)))) | ||
| 1475 | (error "python-resources.jar not found in build output"))))))))) | ||
| 1476 | (native-inputs | ||
| 1477 | (list (list "mx" graalvm-mx) | ||
| 1478 | ;; Use openjdk graal-builder-jdk output which provides static JDK libraries | ||
| 1479 | ;; required for SubstrateVM's JvmFuncsFallbacks build task. | ||
| 1480 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 1481 | (list "python" python-3) | ||
| 1482 | (list "graal-25.0.1-checkout" %graal-source) | ||
| 1483 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 1484 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 1485 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 1486 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 1487 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 1488 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 1489 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 1490 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 1491 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 1492 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 1493 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 1494 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 1495 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 1496 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 1497 | (list "java-json" java-json-for-graal-truffle) | ||
| 1498 | (list "java-capnproto-runtime" java-capnproto-runtime-for-graal-truffle) | ||
| 1499 | (list "java-bcprov" java-bcprov-for-graalpy) | ||
| 1500 | (list "java-bcutil" java-bcutil-for-graalpy) | ||
| 1501 | (list "java-bcpkix" java-bcpkix-for-graalpy) | ||
| 1502 | (list "java-trufflejws" java-trufflejws-for-graal) | ||
| 1503 | (list "ninja" ninja-for-graal-truffle) | ||
| 1504 | (list "cmake" cmake) | ||
| 1505 | (list "git" git-minimal) | ||
| 1506 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)) | ||
| 1507 | (list "bzip2-1.0.8.tar.gz" (package-source bzip2)) | ||
| 1508 | (list "xz-5.6.2.tar.gz" (package-source xz-for-graal-truffle)))) | ||
| 1509 | (inputs (list zlib | ||
| 1510 | bzip2 | ||
| 1511 | xz)) | ||
| 1512 | (home-page "https://www.graalvm.org/python/") | ||
| 1513 | (synopsis "Python 3.12 implementation on GraalVM") | ||
| 1514 | (description "GraalPy is a high-performance Python 3.12 implementation | ||
| 1515 | built on the Truffle framework. Run @command{graalpy} or @command{python3} | ||
| 1516 | to execute Python scripts. Use @code{import java} to access Java classes | ||
| 1517 | directly from Python, or embed Python in Java via @code{Context.newBuilder(\"python\")}. | ||
| 1518 | Supports pip for package installation and the system toolchain for C extensions.") | ||
| 1519 | (license upl1.0))) | ||
| 1520 | |||
| 1521 | (define-public graalvm-ce | ||
| 1522 | (package | ||
| 1523 | (name "graalvm-ce") | ||
| 1524 | (version %graalvm-version) | ||
| 1525 | (source (origin | ||
| 1526 | (inherit %graal-source) | ||
| 1527 | (patches (search-patches "graal-optional-binary-deps.patch")))) | ||
| 1528 | (build-system gnu-build-system) | ||
| 1529 | (arguments | ||
| 1530 | (list | ||
| 1531 | #:tests? #f | ||
| 1532 | #:modules '((guix build gnu-build-system) | ||
| 1533 | (guix build utils) | ||
| 1534 | (ice-9 match)) | ||
| 1535 | #:phases | ||
| 1536 | #~(modify-phases %standard-phases | ||
| 1537 | (delete 'configure) | ||
| 1538 | (add-after 'unpack 'chdir-to-vm | ||
| 1539 | (lambda _ | ||
| 1540 | (chdir "vm"))) | ||
| 1541 | (add-after 'chdir-to-vm 'setup-environment | ||
| 1542 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1543 | (let ((jdk (assoc-ref inputs "openjdk"))) | ||
| 1544 | (setenv "JAVA_HOME" jdk)) | ||
| 1545 | (setenv "MX_PYTHON" (which "python3")) | ||
| 1546 | (setenv "MX_ALT_OUTPUT_ROOT" (string-append (getcwd) "/mxbuild-output")) | ||
| 1547 | (setenv "MX_CACHE_DIR" (string-append (getcwd) "/mx-cache")) | ||
| 1548 | (setenv "CONFIG_SHELL" (which "bash")) | ||
| 1549 | (setenv "SHELL" (which "bash")) | ||
| 1550 | (setenv "JVMCI_VERSION_CHECK" "ignore"))) | ||
| 1551 | (add-before 'build 'patch-build-scripts | ||
| 1552 | (lambda _ | ||
| 1553 | ;; Fix launcher_template.sh shebang - /usr/bin/env doesn't exist in Guix. | ||
| 1554 | (let ((bash (which "bash"))) | ||
| 1555 | (substitute* "../sdk/mx.sdk/vm/launcher_template.sh" | ||
| 1556 | (("#!/usr/bin/env bash") | ||
| 1557 | (string-append "#!" bash)))))) | ||
| 1558 | (add-before 'build 'create-minimal-env | ||
| 1559 | (lambda _ | ||
| 1560 | ;; Create a minimal env file that builds just the JIT compiler | ||
| 1561 | ;; without substratevm (which requires LLVM and JAVACPP binaries). | ||
| 1562 | ;; Note: tflm (truffle-llvm) requires LLVM binaries which we don't have. | ||
| 1563 | (call-with-output-file "mx.vm/guix-ce" | ||
| 1564 | (lambda (port) | ||
| 1565 | (display "# Minimal GraalVM CE for Guix\n" port) | ||
| 1566 | (display "DYNAMIC_IMPORTS=/compiler,/sdk,/truffle,/tools\n" port) | ||
| 1567 | (display "COMPONENTS=cmp,gvm,sdk,tfl,tflc\n" port) | ||
| 1568 | (display "NATIVE_IMAGES=false\n" port))))) | ||
| 1569 | (add-before 'build 'setup-mx-urlrewrites | ||
| 1570 | #$(make-mx-urlrewrites-phase %mx-rewrites-vm-ce)) | ||
| 1571 | (replace 'build | ||
| 1572 | (lambda _ | ||
| 1573 | ;; Build minimal GraalVM CE with our custom env file. | ||
| 1574 | (invoke "mx" "--user-home" (getcwd) | ||
| 1575 | "--env" "guix-ce" | ||
| 1576 | "build"))) | ||
| 1577 | (replace 'install | ||
| 1578 | (lambda* (#:key outputs #:allow-other-keys) | ||
| 1579 | (let ((out (assoc-ref outputs "out"))) | ||
| 1580 | ;; Find the built GraalVM distribution | ||
| 1581 | (match (find-files (string-append (getcwd) "/mxbuild-output") | ||
| 1582 | "^graalvm-ce-java[0-9]+" | ||
| 1583 | #:directories? #t) | ||
| 1584 | ((graalvm-dir . _) | ||
| 1585 | (copy-recursively graalvm-dir out))))))))) | ||
| 1586 | (native-inputs | ||
| 1587 | (list (list "mx" graalvm-mx) | ||
| 1588 | (list "openjdk" openjdk "graal-builder-jdk") | ||
| 1589 | (list "python" python-3) | ||
| 1590 | (list "java-asm" java-asm-for-graal-truffle) | ||
| 1591 | (list "java-asm-tree" java-asm-tree-for-graal-truffle) | ||
| 1592 | (list "java-asm-analysis" java-asm-analysis-for-graal-truffle) | ||
| 1593 | (list "java-asm-util" java-asm-util-for-graal-truffle) | ||
| 1594 | (list "java-asm-commons" java-asm-commons-for-graal-truffle) | ||
| 1595 | (list "java-antlr4-runtime" java-antlr4-runtime-for-graal-truffle) | ||
| 1596 | (list "java-hamcrest-core" java-hamcrest-core-for-graal-truffle) | ||
| 1597 | (list "java-icu4j" java-icu4j-for-graal-truffle) | ||
| 1598 | (list "java-icu4j-charset" java-icu4j-charset-for-graal-truffle) | ||
| 1599 | (list "java-xz" java-xz-for-graal-truffle) | ||
| 1600 | (list "java-jline-terminal" java-jline-terminal-for-graal-truffle) | ||
| 1601 | (list "java-jline-reader" java-jline-reader-for-graal-truffle) | ||
| 1602 | (list "java-jline-builtins" java-jline-builtins-for-graal-truffle) | ||
| 1603 | (list "java-jline-terminal-ffm" java-jline-terminal-ffm-for-graal-truffle) | ||
| 1604 | (list "java-json" java-json-for-graal-truffle) | ||
| 1605 | (list "java-trufflejws" java-trufflejws-for-graal) | ||
| 1606 | (list "java-capnproto-runtime" java-capnproto-runtime-for-graal-truffle) | ||
| 1607 | (list "java-jcodings" java-jcodings-for-graal-truffle) | ||
| 1608 | (list "java-guava" java-guava-for-graal-truffle) | ||
| 1609 | (list "java-jimfs" java-jimfs-for-graal-truffle) | ||
| 1610 | (list "java-visualvm-jfluid-heap" java-visualvm-jfluid-heap-for-graal-truffle) | ||
| 1611 | (list "java-allocation-instrumenter" java-allocation-instrumenter-for-graal-truffle) | ||
| 1612 | (list "java-junit" java-junit-for-graal) | ||
| 1613 | (list "ninja" ninja-for-graal-truffle) | ||
| 1614 | (list "cmake" cmake) | ||
| 1615 | (list "libffi-3.4.8.tar.gz" (package-source libffi-for-graal-truffle)) | ||
| 1616 | ;; mx internal dependencies (ASM 9.8 for jacoco, JMH for benchmarks) | ||
| 1617 | (list "java-asm-mx" java-asm-for-graal-mx) | ||
| 1618 | (list "java-asm-tree-mx" java-asm-tree-for-graal-mx) | ||
| 1619 | (list "java-asm-analysis-mx" java-asm-analysis-for-graal-mx) | ||
| 1620 | (list "java-asm-commons-mx" java-asm-commons-for-graal-mx) | ||
| 1621 | (list "java-jopt-simple-4" java-jopt-simple-4) | ||
| 1622 | (list "java-commons-math3-mx" java-commons-math3-for-graal-mx) | ||
| 1623 | (list "java-jmh-mx" java-jmh-for-graal-mx) | ||
| 1624 | (list "java-jmh-generator-annprocess-mx" java-jmh-generator-annprocess-for-graal-mx))) | ||
| 1625 | (inputs (list zlib)) | ||
| 1626 | (home-page "https://www.graalvm.org/") | ||
| 1627 | (synopsis "GraalVM Community Edition with Native Image") | ||
| 1628 | (description "GraalVM CE is a high-performance JDK with the Graal JIT compiler | ||
| 1629 | and Native Image. It includes the base GraalVM components: sdk, truffle, compiler, | ||
| 1630 | and substratevm. Use @command{native-image} to compile Java applications to | ||
| 1631 | standalone executables.") | ||
| 1632 | (license license:gpl2))) | ||
| 1633 | |||
| 1634 | (define-public graalpy-maven-plugin | ||
| 1635 | (package | ||
| 1636 | (name "graalpy-maven-plugin") | ||
| 1637 | (version "25.0.0") ; graalpy-extensions version | ||
| 1638 | (source (origin | ||
| 1639 | (method git-fetch) | ||
| 1640 | (uri (git-reference | ||
| 1641 | (url "https://github.com/oracle/graalpy-extensions") | ||
| 1642 | (commit (string-append "v" version)))) | ||
| 1643 | (file-name (git-file-name name version)) | ||
| 1644 | (sha256 | ||
| 1645 | (base32 "0rah2cllx131s4yjfay47pifsv2vgjn92hnhxgib8jwqfd671i80")))) | ||
| 1646 | (build-system maven-build-system) | ||
| 1647 | (arguments | ||
| 1648 | (list | ||
| 1649 | #:jdk openjdk | ||
| 1650 | #:tests? #f | ||
| 1651 | #:exclude '(("org.codehaus.mojo" "flatten-maven-plugin" | ||
| 1652 | "exec-maven-plugin") | ||
| 1653 | ("org.apache.maven.plugins" "maven-deploy-plugin" | ||
| 1654 | "maven-gpg-plugin" | ||
| 1655 | "maven-javadoc-plugin" | ||
| 1656 | "maven-source-plugin" | ||
| 1657 | "maven-antrun-plugin" | ||
| 1658 | "maven-assembly-plugin" | ||
| 1659 | "maven-release-plugin" | ||
| 1660 | "maven-enforcer-plugin" | ||
| 1661 | "maven-site-plugin" | ||
| 1662 | "maven-archetype-plugin") | ||
| 1663 | ("org.apache.maven.archetype" "archetype-packaging") | ||
| 1664 | ("org.sonatype.plugins" "nexus-staging-maven-plugin") | ||
| 1665 | ("com.diffplug.spotless" "spotless-maven-plugin") | ||
| 1666 | ("com.github.spotbugs" "spotbugs-maven-plugin") | ||
| 1667 | ("org.netbeans.tools" "sigtest-maven-plugin")) | ||
| 1668 | #:phases | ||
| 1669 | #~(modify-phases %standard-phases | ||
| 1670 | (add-after 'unpack 'fix-shebang | ||
| 1671 | (lambda _ | ||
| 1672 | (substitute* "org.graalvm.python.embedding.tools/src/main/java/org/graalvm/python/embedding/tools/vfs/VFSUtils.java" | ||
| 1673 | (("#!/usr/bin/env bash") "#!/bin/sh")))) | ||
| 1674 | (add-after 'unpack 'fix-plugin-version-lookup | ||
| 1675 | (lambda _ | ||
| 1676 | ;; The plugin resolves itself to get python-launcher dependency, | ||
| 1677 | ;; using getGraalPyVersion() which returns the GraalPy runtime | ||
| 1678 | ;; version. This fails when plugin version differs from runtime. | ||
| 1679 | ;; Fix: use the actual plugin version matching our source. | ||
| 1680 | (substitute* "graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java" | ||
| 1681 | (("String version = getGraalPyVersion\\(project\\);") | ||
| 1682 | (string-append "String version = \"" #$version "\"; // patched for Guix build"))))) | ||
| 1683 | (add-before 'fix-pom-files 'resolve-maven-properties | ||
| 1684 | (lambda _ | ||
| 1685 | (use-modules (ice-9 textual-ports) | ||
| 1686 | (ice-9 regex)) | ||
| 1687 | (for-each | ||
| 1688 | (lambda (pom) | ||
| 1689 | (when (file-exists? pom) | ||
| 1690 | ;; First do line-based substitutions | ||
| 1691 | (substitute* pom | ||
| 1692 | (("\\$\\{project\\.groupId\\}") | ||
| 1693 | "org.graalvm.python") | ||
| 1694 | (("\\$\\{project\\.python\\.artifact\\}") | ||
| 1695 | "python") | ||
| 1696 | ;; Resolve dependency version to match graalpy-community. | ||
| 1697 | ;; Keep ${revision} as-is (project's own version). | ||
| 1698 | (("\\$\\{project\\.polyglot\\.version\\}") | ||
| 1699 | #$%graalvm-version)) | ||
| 1700 | ;; Remove test dependencies (multi-line) - fix-pom-dependencies | ||
| 1701 | ;; leaves them unchanged, causing Maven to try resolving them. | ||
| 1702 | (let* ((content (call-with-input-file pom get-string-all)) | ||
| 1703 | (cleaned (regexp-substitute/global | ||
| 1704 | #f | ||
| 1705 | "<dependency>[\n\r\t ]*<groupId>[^<]+</groupId>[\n\r\t ]*<artifactId>[^<]+</artifactId>[\n\r\t ]*<version>[^<]+</version>[\n\r\t ]*<scope>test</scope>[\n\r\t ]*</dependency>" | ||
| 1706 | content | ||
| 1707 | 'pre 'post))) | ||
| 1708 | (call-with-output-file pom | ||
| 1709 | (lambda (port) | ||
| 1710 | (display cleaned port)))))) | ||
| 1711 | (find-files "." "pom\\.xml$")) | ||
| 1712 | ;; Remove submodules that require unavailable packaging extensions. | ||
| 1713 | (substitute* "pom.xml" | ||
| 1714 | (("<module>graalpy-archetype-polyglot-app</module>") | ||
| 1715 | "")) | ||
| 1716 | )) | ||
| 1717 | (replace 'fix-pom-files | ||
| 1718 | (lambda* (#:key inputs local-packages exclude #:allow-other-keys) | ||
| 1719 | (let ((local-packages | ||
| 1720 | (pom-local-packages "pom.xml" | ||
| 1721 | #:local-packages local-packages))) | ||
| 1722 | (format (current-error-port) | ||
| 1723 | "Fix pom files with local packages: ~a~%" local-packages) | ||
| 1724 | (for-each | ||
| 1725 | (lambda (pom) | ||
| 1726 | (when (file-exists? pom) | ||
| 1727 | (chmod pom #o644) | ||
| 1728 | (format #t "fixing ~a~%" pom) | ||
| 1729 | (fix-pom-dependencies | ||
| 1730 | pom (map cdr inputs) | ||
| 1731 | #:with-plugins? #t | ||
| 1732 | #:with-build-dependencies? #f | ||
| 1733 | #:with-modules? #t | ||
| 1734 | #:local-packages local-packages | ||
| 1735 | #:excludes exclude))) | ||
| 1736 | ;; Skip javainterfacegen - it requires pip to download from PyPI. | ||
| 1737 | (pom-and-submodules "pom.xml"))))) | ||
| 1738 | (add-before 'build 'set-maven-opts | ||
| 1739 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 1740 | ;; cglib needs reflective access to ClassLoader.defineClass. | ||
| 1741 | ;; Also set graalpy.vfs.venvLauncher to use graalpy-community launcher | ||
| 1742 | ;; instead of generated one with incomplete classpath. | ||
| 1743 | (let ((graalpy (search-input-file inputs "bin/graalpy"))) | ||
| 1744 | (setenv "MAVEN_OPTS" | ||
| 1745 | (string-append | ||
| 1746 | "--add-opens=java.base/java.lang=ALL-UNNAMED " | ||
| 1747 | "--add-opens=java.base/java.io=ALL-UNNAMED " | ||
| 1748 | "-Dgraalpy.vfs.venvLauncher=" graalpy))))) | ||
| 1749 | (add-before 'build 'fix-source-date-epoch | ||
| 1750 | (lambda _ | ||
| 1751 | ;; JDK jar tool's --date option requires dates between 1980-2099. | ||
| 1752 | ;; Guix sets SOURCE_DATE_EPOCH=1 (1970-01-01), which is invalid. | ||
| 1753 | ;; Set to 1980-01-02 (315619200) for reproducible builds. | ||
| 1754 | (setenv "SOURCE_DATE_EPOCH" "315619200"))) | ||
| 1755 | (replace 'build | ||
| 1756 | (lambda _ | ||
| 1757 | ;; Skip javainterfacegen module - requires pip to download mypy. | ||
| 1758 | ;; Deactivate sigtest-on-unix profile - runs API signature | ||
| 1759 | ;; verification (compares public API against snapshot.sigtest | ||
| 1760 | ;; to catch breaking changes). Needs exec-maven-plugin which | ||
| 1761 | ;; we don't have, and doesn't affect the built JARs. | ||
| 1762 | (invoke "mvn" "package" "-o" "-X" | ||
| 1763 | "-DskipJavainterfacegen=true" | ||
| 1764 | "-P" "!sigtest-on-unix" | ||
| 1765 | (string-append "-Duser.home=" (getenv "HOME")) | ||
| 1766 | "-Dmaven.test.skip=true"))) | ||
| 1767 | (replace 'install | ||
| 1768 | (lambda _ | ||
| 1769 | ;; Use -Dmaven.test.skip=true to skip both compilation AND execution. | ||
| 1770 | ;; Default -DskipTests only skips execution, causing test compile errors | ||
| 1771 | ;; when test dependencies (JUnit) are not available. | ||
| 1772 | (invoke "mvn" "install" "-o" "-e" | ||
| 1773 | "-DskipJavainterfacegen=true" | ||
| 1774 | "-P" "!sigtest-on-unix" | ||
| 1775 | "-Dmaven.test.skip=true" | ||
| 1776 | (string-append "-Duser.home=" (getenv "HOME")))))))) | ||
| 1777 | (inputs | ||
| 1778 | (list graalpy-community ; provides python-specific /lib/m2 artifacts | ||
| 1779 | graal-sdk ; provides org.graalvm.sdk, org.graalvm.polyglot | ||
| 1780 | graal-truffle ; provides org.graalvm.truffle | ||
| 1781 | graal-tools ; provides org.graalvm.tools | ||
| 1782 | graal-regex ; provides org.graalvm.regex | ||
| 1783 | apache-parent-pom-34 | ||
| 1784 | maven-parent-pom-34 | ||
| 1785 | maven-parent-pom-43 | ||
| 1786 | maven-parent-pom-44 | ||
| 1787 | maven-plugin-plugin | ||
| 1788 | maven-compiler-plugin | ||
| 1789 | ;; Surefire skipped via -Dsurefire.skip=true, exclude to avoid dep chain | ||
| 1790 | plexus-parent-pom-10 ; parent for plexus-io 3.6.0 and plexus-archiver 4.10.4 | ||
| 1791 | plexus-parent-pom-15 ; for other plexus components | ||
| 1792 | junit-bom-5.10 ; for plexus-parent-pom-15, sisu 0.9.0.M3 | ||
| 1793 | junit-bom-5.10.2 ; for sisu 0.9.0.M3 via maven-plugin-api 3.9.9 | ||
| 1794 | junit-bom-5.11 ; for java-plexus-java-1, commons-lang3-3.17 | ||
| 1795 | junit-bom-5.11.0 ; for commons-lang3 3.17.0 via maven-resolver-impl | ||
| 1796 | junit-bom-5.12 ; for maven-parent-pom-44 and apache-parent-pom-34 | ||
| 1797 | maven-common-artifact-filters ; for surefire 3.5.3 | ||
| 1798 | java-plexus-java-1 ; for surefire 3.5.3 | ||
| 1799 | java-plexus-java | ||
| 1800 | java-plexus-utils-4 ; 4.0.1 for maven-resources-plugin 3.x | ||
| 1801 | java-eclipse-sisu-plexus-0.9 ; 0.9.0.M2 for maven-resources-plugin | ||
| 1802 | java-eclipse-sisu-inject-0.9 ; 0.9.0.M3 for maven-resources-plugin | ||
| 1803 | java-slf4j-api ; for surefire 3.5.3 | ||
| 1804 | java-snakeyaml-2 | ||
| 1805 | java-commons-compress ; 1.21 for surefire 3.5.3 | ||
| 1806 | java-plexus-io ; for plexus-archiver runtime | ||
| 1807 | java-plexus-archiver ; for ArchiverManager injection | ||
| 1808 | java-plexus-xml)) ; for maven-resources-plugin | ||
| 1809 | (home-page "https://www.graalvm.org/python/") | ||
| 1810 | (synopsis "Maven plugin for GraalPy Python embedding") | ||
| 1811 | (description "The graalpy-maven-plugin handles Python package management | ||
| 1812 | and resource preparation for Maven-based GraalPy Java polyglot applications. | ||
| 1813 | It provides goals for installing pip packages, locking dependencies, and | ||
| 1814 | generating Virtual File System resources for embedded Python code.") | ||
| 1815 | (license upl1.0))) | ||
