Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple scripts to run non-bootstrapped compiler after 'sbt buildQuick' #19894

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.MainGenericCompiler -usejavacp "$@"
6 changes: 6 additions & 0 deletions docs/_docs/contributing/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ $ 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. It builds the compiler and writes its classpath to the `bin/.cp`
file, which enables the `scalacQ` and `scalaQ` scripts in the `bin/` folder.

## Starting a REPL

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

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

val buildQuick = taskKey[Unit]("builds the compiler and writes the classpath to bin/.cp to enable the bin/scalacQ and bin/scalaQ scripts")

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

Expand Down Expand Up @@ -2136,6 +2138,11 @@ object Build {
// default.
addCommandAlias("publishLocal", "scala3-bootstrapped/publishLocal"),
repl := (`scala3-compiler-bootstrapped` / repl).value,
buildQuick := {
val _ = (`scala3-compiler` / Compile / compile).value
val cp = (`scala3-compiler` / Compile / fullClasspath).value.map(_.data.getAbsolutePath).mkString(File.pathSeparator)
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