diff --git a/.gitignore b/.gitignore index 0fc39ecbae5b..7ee4342439be 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,8 @@ testlogs/ local/ compiler/test/debug/Gen.jar +/bin/.cp + before-pickling.txt after-pickling.txt bench/compile.txt diff --git a/bin/commonQ b/bin/commonQ new file mode 100755 index 000000000000..a25d52db3d90 --- /dev/null +++ b/bin/commonQ @@ -0,0 +1,6 @@ +cp=$(cat $ROOT/bin/.cp) 2> /dev/null + +if [[ "$cp" == "" ]]; then + echo "run 'sbt buildQuick' first" + exit 1 +fi diff --git a/bin/scalaQ b/bin/scalaQ new file mode 100755 index 000000000000..c14a2f0372ff --- /dev/null +++ b/bin/scalaQ @@ -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 "$@" diff --git a/bin/scalacQ b/bin/scalacQ new file mode 100755 index 000000000000..094491834a88 --- /dev/null +++ b/bin/scalacQ @@ -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 "$@" diff --git a/bin/scaladocQ b/bin/scaladocQ new file mode 100755 index 000000000000..3f63b482837e --- /dev/null +++ b/bin/scaladocQ @@ -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 "$@" diff --git a/docs/_docs/contributing/getting-started.md b/docs/_docs/contributing/getting-started.md index 63e968902600..482aeda99807 100644 --- a/docs/_docs/contributing/getting-started.md +++ b/docs/_docs/contributing/getting-started.md @@ -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 diff --git a/project/Build.scala b/project/Build.scala index ba6fe5a555fd..e126fed8a322 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -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") @@ -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."