From: Julien Lepiller <julien@lepiller.eu>
To: guix-devel@gnu.org
Subject: Scala package
Date: Tue, 18 May 2021 01:01:11 +0200 [thread overview]
Message-ID: <20210518010111.7eea541a@tachikoma.lepiller.eu> (raw)
[-- Attachment #1: Type: text/plain, Size: 560 bytes --]
Hi Guix!
I have the attached file that build Scala, although it's not
bootstrapped at all. It contains %binary-scala, a few dependencies of
Scala we haven't packaged yet, and the final scala, built from
%binary-scala, without sbt (which requires Scala too).
Since I've tried and failed to bootstrap Scala for so long, I think
it's time to give up. I can't always create miracles.
If this is acceptable, I will send actual patches later, and rework the
sbt package I had around 2018 (I managed to build it with a Scala
compiler, without a pre-existing sbt).
[-- Attachment #2: scala.scm --]
[-- Type: text/x-scheme, Size: 10568 bytes --]
(use-modules
(guix build-system ant)
(guix build-system copy)
(guix git-download)
(guix download)
(guix packages)
((guix licenses) #:prefix license:)
(gnu packages java))
(define %binary-scala
(package
(name "scala")
(version "2.13.4")
(source (origin
(method url-fetch)
(uri (string-append "https://downloads.lightbend.com/scala/"
version "/scala-" version ".tgz"))
(sha256
(base32
"1alcnzmxga00nsvgy8yky91zw5b4q0xg2697vrrdgjlglpxiqwdw"))))
(build-system copy-build-system)
(arguments
`(#:install-plan
'(("." ""))
#:phases
(modify-phases %standard-phases
(add-before 'install 'set-java-home
(lambda* (#:key inputs #:allow-other-keys)
(substitute* (find-files "bin" ".")
(("^#!.*" shebang)
(string-append shebang "\nJAVA_HOME="
(assoc-ref inputs "openjdk"))))))
(add-before 'set-java-home 'remove-unneeded
(lambda _
(for-each delete-file (find-files "bin" "bat$")))))))
(inputs
`(("openjdk" ,openjdk14)))
(home-page "https://scala-lang.org/")
(synopsis "Scala programming language")
(description "Scala combines object-oriented and functional programming in
one concise, high-level language. Scala's static types help avoid bugs in
complex applications, and its JVM and JavaScript runtimes let you build
high-performance systems with easy access to huge ecosystems of libraries.")
(license license:bsd-3)))
(define scala-asm
(package
(inherit java-asm)
(version "9.1.0")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/scala/scala-asm")
(commit "s-9.1")))
(file-name (git-file-name "scala-asm" version))
(sha256
(base32
"1wsrlb6kb0fwxjdqanxqgmq4qcyq9gqn129w3l4bj7gvlspll33l"))))
(arguments
`(#:jar-name "java-asm.jar"
#:source-dir "src/main/java"
;; no tests
#:tests? #f))))
(define java-jline3-terminal
(package
(name "java-jline3-terminal")
(version "3.19.0")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/jline/jline3")
(commit (string-append "jline-parent-" version))))
(file-name (git-file-name name version))
(sha256
(base32
"16cfbkbj925c92xnwq5sbg7v57yh840g0mh95iyzkkajxirz9qn9"))
(snippet
;; calls maven, and conflicts with ant
`(delete-file "build"))))
(build-system ant-build-system)
(arguments
`(#:jar-name "jline3-terminal.jar"
#:source-dir "terminal/src/main/java"
#:test-dir "terminal/src/test"
#:phases
(modify-phases %standard-phases
;(add-after 'unpack 'make-files-writable
; (lambda _
; (for-each make-file-writable (find-files "."))
; #t))
(add-before 'build 'copy-resources
(lambda _
(copy-recursively
"terminal/src/main/resources/"
"build/classes")
#t)))))
(native-inputs
`(("java-easymock" ,java-easymock)
("java-junit" ,java-junit)))
(home-page "")
(synopsis "")
(description "")
(license #f)))
(define java-jline3-reader
(package
(inherit java-jline3-terminal)
(name "java-jline3-reader")
(arguments
`(#:jar-name "jline3-reader.jar"
#:source-dir "reader/src/main/java"
#:test-dir "reader/src/test"))
(inputs
`(("java-jline3-terminal" ,java-jline3-terminal)))))
(define scala
(package
(inherit %binary-scala)
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/scala/scala")
(commit (string-append "v" (package-version %binary-scala)))))
(file-name (git-file-name "scala" (package-version %binary-scala)))
(sha256
(base32
"0a6n0wnklya5mvcj03b64my7c30m2zw7spm9j1byv1rraxxjm1q1"))))
(build-system ant-build-system)
(arguments
`(#:tests? #f
#:phases
(modify-phases %standard-phases
(replace 'build
(lambda* (#:key inputs #:allow-other-keys)
(define* (build-project directory name #:optional (jar? #t))
(let* ((build-dir (string-append "build/class/" name))
(jar-name (string-append name ".jar"))
(java-files (find-files directory ".*.java$"))
(scala-files (find-files directory ".*.scala$")))
(mkdir-p build-dir)
(format #t "Building project ~a...~%" name)
(unless (eq? scala-files '())
(apply invoke "scalac" "-classpath"
(string-append
;; Add any top-level directory in build that may contain
;; .class files, but don't actually add build/ iteself or
;; any individual class file.
(string-join
(filter (lambda (s) (eq? (string-count s #\/) 1))
(find-files "build" "." #:directories? #t))
":"))
"-d" build-dir "-nobootcp"
(append scala-files java-files)))
(unless (eq? java-files '())
(apply invoke "javac" "-classpath"
(string-append
(getenv "CLASSPATH") ":"
(string-join
(filter (lambda (s) (eq? (string-count s #\/) 1))
(find-files "build" "." #:directories? #t))
":"))
"-g" "-source" "1.8" "-target" "1.8"
"-d" build-dir java-files))
(mkdir-p "build/jar")
(if jar?
(invoke "jar" "cf" (string-append "build/jar/" jar-name)
"-C" build-dir "."))))
(let ((scala-asm (assoc-ref inputs "scala-asm")))
(setenv "CLASSPATH" (string-join (find-files scala-asm ".*.jar$") ":")))
(setenv "JAVA_OPTS" "-Xmx1G")
(build-project "src/library" "scala-library")
(build-project "src/reflect" "scala-reflect")
(build-project "src/compiler" "scala-compiler" #f)
(build-project "src/interactive" "scala-compiler-interactive" #f)
(build-project "src/scaladoc" "scala-compiler-doc" #f)
(build-project "src/repl" "scala-repl" #f)
(build-project "src/repl-frontend" "scala-repl-frontend" #f)
(build-project "src/scalap" "scalap")
;; create scala-compiler.jar as a union of some of those above
(mkdir-p "build/class/compiler")
(with-directory-excursion "build/class/compiler"
(let ((scala-asm (assoc-ref inputs "scala-asm")))
(invoke "jar" "xf" (car (find-files scala-asm ".*.jar$"))))
(copy-recursively "../scala-compiler" ".")
(copy-recursively "../scala-compiler-interactive" ".")
(copy-recursively "../scala-compiler-doc" ".")
(copy-recursively "../scala-repl" ".")
(copy-recursively "../scala-repl-frontend" "."))
(invoke "jar" "cf" "build/jar/scala-compiler.jar"
"-C" "build/class/compiler" ".")))
(replace 'install
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(lib (string-append out "/lib"))
(jna (assoc-ref inputs "java-native-access"))
(jline-terminal (assoc-ref inputs "java-jline3-terminal"))
(jline-reader (assoc-ref inputs "java-jline3-reader")))
(mkdir-p lib)
(for-each
(lambda (jar)
(copy-file jar (string-append lib "/" (basename jar))))
(find-files "build/jar" ".*.jar$"))
(symlink (car (find-files jna "linux-.*.jar$"))
(string-append lib "/jna-lib.jar"))
(symlink (car (find-files jna "jna.jar$"))
(string-append lib "/jna.jar"))
(symlink (car (find-files jline-reader ".*.jar$"))
(string-append lib "/jline-reader.jar"))
(symlink (car (find-files jline-terminal ".*.jar$"))
(string-append lib "/jline-terminal.jar")))))
(add-after 'install 'install-bin
(lambda* (#:key outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(bin (string-append out "/bin")))
(define (install-script script class)
(let ((script (string-append bin "/" script)))
(copy-file "src/compiler/templates/tool-unix.tmpl" script)
;; See project/ScalaTool and build.sbt
(substitute* script
(("@@") "@")
(("@class@") class)
(("@properties@") "-Dscala.home=\"$SCALA_HOME\"")
(("@javaflags@") "-Xmx256M -Xms32M")
(("@toolflags@") "")
(("@classpath@") ""))
(chmod script #o755)))
(mkdir-p bin)
(install-script "scala" "scala.tools.nsc.MainGenericRunner")
(install-script "scalac" "scala.tools.nsc.Main")
(install-script "fsc" "scala.tools.nsc.fsc.CompileClient")
(install-script "scaladoc" "scala.tools.nsc.ScalaDoc")
(install-script "scalap" "scala.tools.scalap.Main"))))
)))
(inputs
`(("scala" ,%binary-scala)
("scala-asm" ,scala-asm)
("java-jline3-terminal" ,java-jline3-terminal)
("java-jline3-reader" ,java-jline3-reader)
("java-native-access" ,java-native-access)))))
%binary-scala
;scala-asm
;java-jline3
;scala
next reply other threads:[~2021-05-17 23:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-17 23:01 Julien Lepiller [this message]
2021-05-18 7:08 ` Scala package Leo Prikler
2021-05-18 9:44 ` Ricardo Wurmus
2021-05-18 11:15 ` Julien Lepiller
2021-05-18 11:36 ` Leo Prikler
2021-05-18 12:37 ` Julien Lepiller
2021-05-18 13:52 ` Leo Prikler
2021-05-18 21:35 ` Ludovic Courtès
2021-05-19 15:35 ` Katherine Cox-Buday
2021-05-20 19:09 ` Shyam Saran
2021-05-20 19:34 ` Julien Lepiller
2021-05-21 9:32 ` Shyam Saran
2021-05-18 14:00 ` Daniel Trujillo Viedma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210518010111.7eea541a@tachikoma.lepiller.eu \
--to=julien@lepiller.eu \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.