Skip to content

Commit 0d8f8b9

Browse files
committed
simple scripts to run non-bootstrapped compiler after 'sbt buildQuick'
1 parent c36c390 commit 0d8f8b9

File tree

7 files changed

+39
-0
lines changed

7 files changed

+39
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
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

bin/commonQ

Lines changed: 6 additions & 0 deletions
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

bin/scalaQ

Lines changed: 6 additions & 0 deletions
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 "$@"

bin/scalacQ

Lines changed: 6 additions & 0 deletions
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.dotc.Main -usejavacp "$@"

bin/scaladocQ

Lines changed: 6 additions & 0 deletions
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.scaladoc.Main -usejavacp "$@"

docs/_docs/contributing/getting-started.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ $ 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 and then use the `scalacQ`, `scalaQ` and `scaladocQ` scripts
88+
in the `bin/` folder. These scripts invoke the compiler using the classfiles from the `out/` directory which are
89+
updated incrementally when working on the compiler.
90+
8491
## Starting a REPL
8592

8693
```bash

project/Build.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ object Build {
202202

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

205+
val buildQuick = taskKey[Unit]("builds the compiler and enables bin/scalaQ, bin/scalacQ, bin/scaladocQ")
206+
205207
// Compiles the documentation and static site
206208
val genDocs = inputKey[Unit]("run scaladoc to generate static documentation site")
207209

@@ -2140,6 +2142,10 @@ object Build {
21402142
// default.
21412143
addCommandAlias("publishLocal", "scala3-bootstrapped/publishLocal"),
21422144
repl := (`scala3-compiler-bootstrapped` / repl).value,
2145+
buildQuick := {
2146+
val cp = (LocalProject("scaladoc") / Compile / fullClasspath).value.map(_.data.getAbsolutePath).mkString(":")
2147+
IO.write(baseDirectory.value / "bin" / ".cp", cp)
2148+
},
21432149
(Compile / console) := (Compile / console).dependsOn(Def.task {
21442150
import _root_.scala.io.AnsiColor._
21452151
val msg = "`console` uses the reference Scala version. Use `repl` instead."

0 commit comments

Comments
 (0)