@@ -83,8 +83,6 @@ object DottyBuild extends Build {
83
83
" org.scala-lang.modules" %% " scala-partest" % " 1.0.11" % " test" ,
84
84
" com.novocode" % " junit-interface" % " 0.11" % " test" ,
85
85
" jline" % " jline" % " 2.12" ),
86
- libraryDependencies +=
87
- " org.scala-js" %% " scalajs-ir" % scalaJSVersion,
88
86
89
87
// enable improved incremental compilation algorithm
90
88
incOptions := incOptions.value.withNameHashing(true ),
@@ -116,6 +114,38 @@ object DottyBuild extends Build {
116
114
runTask(Test , " dotty.partest.DPConsoleRunner" , dottyJars + " " + args.mkString(" " ))
117
115
},
118
116
117
+ /* Add the sources of scalajs-ir.
118
+ * To guarantee that dotty can bootstrap without depending on a version
119
+ * of scalajs-ir built with a different Scala compiler, we add its
120
+ * sources instead of depending on the binaries.
121
+ */
122
+ ivyConfigurations += config(" sourcedeps" ).hide,
123
+ libraryDependencies +=
124
+ " org.scala-js" %% " scalajs-ir" % scalaJSVersion % " sourcedeps" ,
125
+ sourceGenerators in Compile += Def .task {
126
+ val s = streams.value
127
+ val cacheDir = s.cacheDirectory
128
+ val trgDir = (sourceManaged in Compile ).value / " scalajs-ir-src"
129
+
130
+ val report = updateClassifiers.value
131
+ val scalaJSIRSourcesJar = report.select(
132
+ configuration = Set (" sourcedeps" ),
133
+ module = (_ : ModuleID ).name.startsWith(" scalajs-ir_" ),
134
+ artifact = artifactFilter(`type` = " src" )).headOption.getOrElse {
135
+ sys.error(s " Could not fetch scalajs-ir sources " )
136
+ }
137
+
138
+ FileFunction .cached(cacheDir / s " fetchScalaJSIRSource " ,
139
+ FilesInfo .lastModified, FilesInfo .exists) { dependencies =>
140
+ s.log.info(s " Unpacking scalajs-ir sources to $trgDir... " )
141
+ if (trgDir.exists)
142
+ IO .delete(trgDir)
143
+ IO .createDirectory(trgDir)
144
+ IO .unzip(scalaJSIRSourcesJar, trgDir)
145
+ (trgDir ** " *.scala" ).get.toSet
146
+ } (Set (scalaJSIRSourcesJar)).toSeq
147
+ }.taskValue,
148
+
119
149
// Adjust classpath for running dotty
120
150
mainClass in (Compile , run) := Some (" dotty.tools.dotc.Main" ),
121
151
fork in run := true ,
0 commit comments