Skip to content

Add default output directory scalac in dotty project #19226

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

Merged
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
12 changes: 9 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ object Build {
val externalDeps = externalCompilerClasspathTask.value
val jars = packageAll.value

val argsWithDefaultClasspath: List[String] =
if (args.contains("-classpath")) args
else insertClasspathInArgs(args, (baseDirectory.value / ".." / "out" / "default-last-scalac-out.jar").getPath)

val scalaLib = findArtifactPath(externalDeps, "scala-library")
val dottyLib = jars("scala3-library")

Expand All @@ -725,7 +729,7 @@ object Build {
} else if (scalaLib == "") {
println("Couldn't find scala-library on classpath, please run using script in bin dir instead")
} else if (args.contains("-with-compiler")) {
val args1 = args.filter(_ != "-with-compiler")
val args1 = argsWithDefaultClasspath.filter(_ != "-with-compiler")
val asm = findArtifactPath(externalDeps, "scala-asm")
val dottyCompiler = jars("scala3-compiler")
val dottyStaging = jars("scala3-staging")
Expand All @@ -734,7 +738,7 @@ object Build {
val tastyCore = jars("tasty-core")
val compilerInterface = findArtifactPath(externalDeps, "compiler-interface")
run(insertClasspathInArgs(args1, List(dottyCompiler, dottyInterfaces, asm, dottyStaging, dottyTastyInspector, tastyCore, compilerInterface).mkString(File.pathSeparator)))
} else run(args)
} else run(argsWithDefaultClasspath)
},

run := scalac.evaluated,
Expand All @@ -750,6 +754,8 @@ object Build {
val decompile = args0.contains("-decompile")
val printTasty = args0.contains("-print-tasty")
val debugFromTasty = args0.contains("-Ythrough-tasty")
val defaultOutputDirectory =
if (printTasty || decompile || debugFromTasty || args0.contains("-d")) Nil else List("-d", (baseDirectory.value / ".." / "out" / "default-last-scalac-out.jar").getPath)
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
arg != "-with-compiler" && arg != "-Ythrough-tasty" && arg != "-print-tasty")
val main =
Expand Down Expand Up @@ -783,7 +789,7 @@ object Build {
extraClasspath ++= Seq(dottyCompiler, dottyInterfaces, asm, dottyStaging, dottyTastyInspector, tastyCore, compilerInterface)
}

val fullArgs = main :: (if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator)))
val fullArgs = main :: defaultOutputDirectory ::: (if (printTasty) args else insertClasspathInArgs(args, extraClasspath.mkString(File.pathSeparator)))

(Compile / runMain).toTask(fullArgs.mkString(" ", " ", ""))
}.evaluated,
Expand Down
2 changes: 1 addition & 1 deletion project/scripts/cmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ grep -qe "$EXPECTED_OUTPUT" "$tmp"

echo "testing sbt scalac -print-tasty"
clear_out "$OUT"
"$SBT" ";scalac $SOURCE -d $OUT ;scalac -print-tasty -color:never $TASTY" > "$tmp"
"$SBT" ";scalac $SOURCE -d $OUT ;scalac -print-tasty -color:never $OUT/$TASTY" > "$tmp"
grep -qe "0: ASTs" "$tmp"
grep -qe "0: 41 \[tests/pos/HelloWorld.scala\]" "$tmp"

Expand Down