Skip to content

Commit 5bf2d63

Browse files
committed
Drop scala3-runtime, scala3-graal & scala3-graal-processor
1 parent 863bec3 commit 5bf2d63

File tree

10 files changed

+23
-413
lines changed

10 files changed

+23
-413
lines changed

build.mill.scala

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@ object `test-runner` extends Cross[TestRunner](Scala.runnerScalaVersions)
109109
with CrossScalaDefaultToRunner
110110
object `tasty-lib` extends Cross[TastyLib](Scala.scala3MainVersions)
111111
with CrossScalaDefaultToInternal
112-
// Runtime classes used within native image on Scala 3 replacing runtime from Scala
113-
object `scala3-runtime` extends Cross[Scala3Runtime](Scala.scala3MainVersions)
114-
with CrossScalaDefaultToInternal
115-
// Logic to process classes that is shared between build and the scala-cli itself
116-
object `scala3-graal` extends Cross[Scala3Graal](Scala.scala3MainVersions)
117-
with CrossScalaDefaultToInternal
118-
// Main app used to process classpath within build itself
119-
object `scala3-graal-processor` extends Cross[Scala3GraalProcessor](Scala.scala3MainVersions)
120-
with CrossScalaDefaultToInternal
121112

122113
object `scala-cli-bsp` extends JavaModule with ScalaCliPublishModule {
123114
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Seq(
@@ -685,38 +676,6 @@ trait Options extends ScalaCliCrossSbtModule with ScalaCliPublishModule with Has
685676
}
686677
}
687678

688-
trait Scala3Runtime extends CrossSbtModule with ScalaCliPublishModule {
689-
override def crossScalaVersion: String = crossValue
690-
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps()
691-
}
692-
693-
trait Scala3Graal extends ScalaCliCrossSbtModule
694-
with ScalaCliPublishModule with ScalaCliScalafixModule {
695-
override def crossScalaVersion: String = crossValue
696-
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(
697-
Deps.asm,
698-
Deps.osLib
699-
)
700-
701-
override def resources: T[Seq[PathRef]] = Task.Sources {
702-
val extraResourceDir = Task.dest / "extra"
703-
// scala3RuntimeFixes.jar is also used within
704-
// resource-config.json and BytecodeProcessor.scala
705-
os.copy.over(
706-
`scala3-runtime`(crossScalaVersion).jar().path,
707-
extraResourceDir / "scala3RuntimeFixes.jar",
708-
createFolders = true
709-
)
710-
super.resources() ++ Seq(mill.PathRef(extraResourceDir))
711-
}
712-
}
713-
714-
trait Scala3GraalProcessor extends CrossScalaModule with ScalaCliPublishModule {
715-
override def moduleDeps: Seq[SonatypeCentralPublishModule] =
716-
Seq(`scala3-graal`(crossScalaVersion))
717-
override def finalMainClass: T[String] = "scala.cli.graal.CoursierCacheProcessor"
718-
}
719-
720679
trait Build extends ScalaCliCrossSbtModule
721680
with ScalaCliPublishModule
722681
with HasTests
@@ -926,7 +885,6 @@ trait Cli extends CrossSbtModule with ProtoBuildModule with CliLaunchers
926885
def moduleDeps: Seq[SonatypeCentralPublishModule] = Seq(
927886
`build-module`(crossScalaVersion),
928887
config(crossScalaVersion),
929-
`scala3-graal`(crossScalaVersion),
930888
`specification-level`(crossScalaVersion)
931889
)
932890

@@ -948,27 +906,15 @@ trait Cli extends CrossSbtModule with ProtoBuildModule with CliLaunchers
948906
Deps.signingCli.exclude((organization, "config_2.13")),
949907
Deps.slf4jNop, // to silence jgit
950908
Deps.sttp,
951-
Deps.scalafixInterfaces
909+
Deps.scalafixInterfaces,
910+
Deps.scala3Graal // TODO: drop this if we ever bump internal JDK to 24+
952911
)
953912
override def compileIvyDeps: T[Agg[Dep]] = super.compileIvyDeps() ++ Agg(
954913
Deps.jsoniterMacros,
955914
Deps.svm
956915
)
957916
override def mainClass: T[Option[String]] = Some("scala.cli.ScalaCli")
958917

959-
override def nativeImageClassPath: T[Seq[PathRef]] = Task {
960-
val classpath = super.nativeImageClassPath().map(_.path).mkString(File.pathSeparator)
961-
val cache = Task.dest / "native-cp"
962-
// `scala3-graal-processor`.run() do not give me output and I cannot pass dynamically computed values like classpath
963-
val res = mill.util.Jvm.callProcess(
964-
mainClass = `scala3-graal-processor`(crossScalaVersion).finalMainClass(),
965-
classPath = `scala3-graal-processor`(crossScalaVersion).runClasspath().map(_.path),
966-
mainArgs = Seq(cache.toNIO.toString, classpath)
967-
)
968-
val cp = res.out.trim()
969-
cp.split(File.pathSeparator).toSeq.map(p => PathRef(os.Path(p)))
970-
}
971-
972918
override def localRepoJar: T[PathRef] = `local-repo`.localRepoJar()
973919

974920
object test extends ScalaCliTests with ScalaCliScalafixModule {

modules/cli/src/main/scala/scala/cli/packaging/NativeImage.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import java.io.File
55
import scala.annotation.tailrec
66
import scala.build.internal.{ManifestJar, Runner}
77
import scala.build.internals.EnvVar
8-
import scala.build.{Build, Logger, Positioned}
8+
import scala.build.{Build, Logger, Positioned, coursierVersion}
99
import scala.cli.errors.GraalVMNativeImageError
1010
import scala.cli.graal.{BytecodeProcessor, TempCache}
1111
import scala.cli.internal.CachedBinary
@@ -206,7 +206,9 @@ object NativeImage {
206206
// seems native-image doesn't correctly parse paths in manifests - this is especially a problem on Windows
207207
wrongSimplePathsInManifest = true
208208
) { processedClassPath =>
209-
val needsProcessing = builds.head.scalaParams.exists(_.scalaVersion.startsWith("3."))
209+
val needsProcessing =
210+
builds.head.scalaParams.map(_.scalaVersion.coursierVersion)
211+
.exists(sv => (sv >= "3.0.0".coursierVersion) && (sv < "3.3.0".coursierVersion))
210212
val (classPath, toClean, scala3extraOptions) =
211213
if needsProcessing then {
212214
val cpString = processedClassPath.mkString(File.pathSeparator)

modules/integration/src/test/scala/scala/cli/integration/TestNativeImageOnScala3.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,21 @@ class TestNativeImageOnScala3 extends ScalaCliSuite {
4040
}
4141
}
4242

43-
test("lazy vals") {
44-
runTest("1")("2") {
45-
"""//> using scala 3.1.1
46-
|class A(a: String) { lazy val b = a.toInt + 1 }
47-
|@main def add1(i: String) = println(A(i).b)
48-
|""".stripMargin
49-
}
43+
for {
44+
scalaVersion <- TestUtil.legacyScalaVersionsOnePerMinor.sorted ++ Seq(
45+
Constants.scala3Lts,
46+
Constants.scala3Next,
47+
Constants.scala3NextRc
48+
)
5049
}
50+
test(s"lazy vals ($scalaVersion)") {
51+
runTest("1")("2") {
52+
s"""//> using scala $scalaVersion
53+
|class A(a: String) { lazy val b = a.toInt + 1 }
54+
|@main def add1(i: String) = println(A(i).b)
55+
|""".stripMargin
56+
}
57+
}
5158

5259
test("lazy vals and enums with default scala version") {
5360
runTest("1")("2", "A") {

modules/scala3-graal-processor/src/scala/cli/graal/CoursierCacheProcessor.scala

Lines changed: 0 additions & 15 deletions
This file was deleted.

modules/scala3-graal/src/main/scala/scala/cli/graal/BytecodeProcessor.scala

Lines changed: 0 additions & 220 deletions
This file was deleted.

modules/scala3-graal/src/main/scala/scala/cli/graal/ClassPathEntry.scala

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)