Skip to content

Commit 19a453d

Browse files
committed
simple scripts to run non-bootstrapped compiler after 'sbt buildQuick'
1 parent 95a8a9c commit 19a453d

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ testlogs/
6464
local/
6565
compiler/test/debug/Gen.jar
6666

67+
/bin/.cp
68+
6769
before-pickling.txt
6870
after-pickling.txt
6971
bench/compile.txt

Diff for: bin/commonQ

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
cp=$(cat $ROOT/bin/.cp) 2> /dev/null
2+
3+
if [[ "$cp" == "" ]]; then
4+
echo "run 'sbt buildQuick' first"
5+
exit 1
6+
fi

Diff for: bin/scalaQ

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
4+
. $ROOT/bin/commonQ
5+
6+
java -cp $cp dotty.tools.MainGenericRunner -usejavacp "$@"

Diff for: bin/scalacQ

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
4+
. $ROOT/bin/commonQ
5+
6+
java -cp $cp dotty.tools.MainGenericCompiler -usejavacp "$@"

Diff for: docs/_docs/contributing/getting-started.md

+6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ $ scalac tests/pos/HelloWorld.scala
8181
$ scala HelloWorld
8282
```
8383

84+
Note that the `scalac` and `scala` scripts have slow roundtrip times when working on the compiler codebase: whenever
85+
any source file changes they invoke `sbt dist/pack` first.
86+
87+
As an alternative, run the `buildQuick` task in sbt. It builds the compiler and writes its classpath to the `bin/.cp`
88+
file, which enables the `scalacQ` and `scalaQ` scripts in the `bin/` folder.
89+
8490
## Starting a REPL
8591

8692
```bash

Diff for: project/Build.scala

+7
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ object Build {
205205

206206
val repl = taskKey[Unit]("spawns a repl with the correct classpath")
207207

208+
val buildQuick = taskKey[Unit]("builds the compiler and writes the classpath to bin/.cp to enable the bin/scalacQ and bin/scalaQ scripts")
209+
208210
// Compiles the documentation and static site
209211
val genDocs = inputKey[Unit]("run scaladoc to generate static documentation site")
210212

@@ -2136,6 +2138,11 @@ object Build {
21362138
// default.
21372139
addCommandAlias("publishLocal", "scala3-bootstrapped/publishLocal"),
21382140
repl := (`scala3-compiler-bootstrapped` / repl).value,
2141+
buildQuick := {
2142+
val _ = (`scala3-compiler` / Compile / compile).value
2143+
val cp = (`scala3-compiler` / Compile / fullClasspath).value.map(_.data.getAbsolutePath).mkString(File.pathSeparator)
2144+
IO.write(baseDirectory.value / "bin" / ".cp", cp)
2145+
},
21392146
(Compile / console) := (Compile / console).dependsOn(Def.task {
21402147
import _root_.scala.io.AnsiColor._
21412148
val msg = "`console` uses the reference Scala version. Use `repl` instead."

0 commit comments

Comments
 (0)