Skip to content

Commit

Permalink
simple scripts to run non-bootstrapped compiler after 'sbt buildQuick'
Browse files Browse the repository at this point in the history
  • Loading branch information
lrytz committed Apr 4, 2024
1 parent c36c390 commit 0d8f8b9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ testlogs/
local/
compiler/test/debug/Gen.jar

/bin/.cp

before-pickling.txt
after-pickling.txt
bench/compile.txt
Expand Down
6 changes: 6 additions & 0 deletions bin/commonQ
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cp=$(cat $ROOT/bin/.cp) 2> /dev/null

if [[ "$cp" == "" ]]; then
echo "run 'sbt buildQuick' first"
exit 1
fi
6 changes: 6 additions & 0 deletions bin/scalaQ
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
. $ROOT/bin/commonQ

java -cp $cp dotty.tools.MainGenericRunner -usejavacp "$@"
6 changes: 6 additions & 0 deletions bin/scalacQ
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
. $ROOT/bin/commonQ

java -cp $cp dotty.tools.dotc.Main -usejavacp "$@"
6 changes: 6 additions & 0 deletions bin/scaladocQ
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" >& /dev/null && pwd)/.."
. $ROOT/bin/commonQ

java -cp $cp dotty.tools.scaladoc.Main -usejavacp "$@"
7 changes: 7 additions & 0 deletions docs/_docs/contributing/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ $ scalac tests/pos/HelloWorld.scala
$ scala HelloWorld
```

Note that the `scalac` and `scala` scripts have slow roundtrip times when working on the compiler codebase: whenever
any source file changes they invoke `sbt dist/pack` first.

As an alternative, run the `buildQuick` task in sbt and then use the `scalacQ`, `scalaQ` and `scaladocQ` scripts
in the `bin/` folder. These scripts invoke the compiler using the classfiles from the `out/` directory which are
updated incrementally when working on the compiler.

## Starting a REPL

```bash
Expand Down
6 changes: 6 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ object Build {

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

val buildQuick = taskKey[Unit]("builds the compiler and enables bin/scalaQ, bin/scalacQ, bin/scaladocQ")

// Compiles the documentation and static site
val genDocs = inputKey[Unit]("run scaladoc to generate static documentation site")

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

0 comments on commit 0d8f8b9

Please sign in to comment.