Skip to content

Commit ee88bf3

Browse files
sjrdhamzaremmal
andcommitted
Wire sjsSandbox and sjsJUnitTests for the new stdlib.
Co-authored-by: Hamza Remmal <hamza@remmal.net>
1 parent e3f1aa1 commit ee88bf3

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

.github/workflows/stdlib.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,4 +533,4 @@ jobs:
533533
cache: 'sbt'
534534
- uses: sbt/setup-sbt@v1
535535
- name: Test Scala.js
536-
run: ./project/scripts/sbt sjsCompilerTests/test
536+
run: ./project/scripts/sbt "sjsCompilerTests/test; sjsJUnitTests/test"

project/Build.scala

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,48 @@ object Build {
29362936
BuildInfoPlugin.buildInfoDefaultSettings
29372937
)
29382938

2939+
/** Common settings for sjsSandbox and sjsJUnitTests */
2940+
lazy val regularScalaJSProjectSettings: Seq[Setting[_]] = Def.settings(
2941+
version := dottyVersion,
2942+
scalaVersion := referenceVersion,
2943+
crossPaths := true,
2944+
autoScalaLibrary := false, // do not add a dependency to stdlib, we depend on it with dependsOn
2945+
// Add the source directories
2946+
Compile / unmanagedSourceDirectories := Seq(baseDirectory.value / "src"),
2947+
Test / unmanagedSourceDirectories := Seq(baseDirectory.value / "test"),
2948+
// NOTE: The only difference here is that we drop `-Werror` and semanticDB for now
2949+
Compile / scalacOptions := Seq("-deprecation", "-feature", "-unchecked", "-encoding", "UTF8", "-language:implicitConversions"),
2950+
Compile / scalacOptions += "-scalajs", // we really need this one for Scala.js projects
2951+
// Don't publish
2952+
publish / skip := false,
2953+
// Configure to use the non-bootstrapped compiler
2954+
scalaInstance := {
2955+
val externalCompilerDeps = (`scala3-compiler-nonbootstrapped` / Compile / externalDependencyClasspath).value.map(_.data).toSet
2956+
2957+
// IMPORTANT: We need to use actual jars to form the ScalaInstance and not
2958+
// just directories containing classfiles because sbt maintains a cache of
2959+
// compiler instances. This cache is invalidated based on timestamps
2960+
// however this is only implemented on jars, directories are never
2961+
// invalidated.
2962+
val tastyCore = (`tasty-core-nonbootstrapped` / Compile / packageBin).value
2963+
val scalaLibrary = (`scala-library-nonbootstrapped` / Compile / packageBin).value
2964+
val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
2965+
val scala3Compiler = (`scala3-compiler-nonbootstrapped` / Compile / packageBin).value
2966+
2967+
Defaults.makeScalaInstance(
2968+
dottyNonBootstrappedVersion,
2969+
libraryJars = Array(scalaLibrary),
2970+
allCompilerJars = Seq(tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
2971+
allDocJars = Seq.empty,
2972+
state.value,
2973+
scalaInstanceTopLoader.value
2974+
)
2975+
},
2976+
scalaCompilerBridgeBinaryJar := {
2977+
Some((`scala3-sbt-bridge-nonbootstrapped` / Compile / packageBin).value)
2978+
},
2979+
)
2980+
29392981
/** A sandbox to play with the Scala.js back-end of dotty.
29402982
*
29412983
* This sandbox is compiled with dotty with support for Scala.js. It can be
@@ -2947,9 +2989,9 @@ object Build {
29472989
*/
29482990
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
29492991
enablePlugins(DottyJSPlugin).
2950-
dependsOn(`scala3-library-bootstrappedJS`).
2992+
dependsOn(`scala-library-sjs`).
29512993
settings(
2952-
commonBootstrappedSettings,
2994+
regularScalaJSProjectSettings,
29532995
// Required to run Scala.js tests.
29542996
Test / fork := false,
29552997

@@ -2965,9 +3007,9 @@ object Build {
29653007
*/
29663008
lazy val sjsJUnitTests = project.in(file("tests/sjs-junit")).
29673009
enablePlugins(DottyJSPlugin).
2968-
dependsOn(`scala3-library-bootstrappedJS`).
3010+
dependsOn(`scala-library-sjs`).
29693011
settings(
2970-
commonBootstrappedSettings,
3012+
regularScalaJSProjectSettings,
29713013
bspEnabled := false,
29723014
scalacOptions --= Seq("-Werror", "-deprecation"),
29733015

0 commit comments

Comments
 (0)