Skip to content

Commit 06a3d47

Browse files
felixmuldersmarter
authored andcommitted
Move sjs, make sure that partest compiles everything in dirs
1 parent 0da788c commit 06a3d47

File tree

18 files changed

+149
-187
lines changed

18 files changed

+149
-187
lines changed

src/scalaShadowing/language.scala renamed to library/src/scalaShadowing/language.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ package scalaShadowing
2525
* - [[higherKinds `higherKinds`]] enables writing higher-kinded types
2626
* - [[existentials `existentials`]] enables writing existential types
2727
* - [[experimental `experimental`]] contains newer features that have not yet been tested in production
28-
*
28+
*
2929
* and, for dotty:
30-
*
30+
*
3131
* - [[Scala2 `Scala2`] backwards compatibility mode for Scala2
32-
* - [[noAtoTupling `noAutoTupling`]] disable auto-tupling
32+
* - [[noAtoTupling `noAutoTupling`]] disable auto-tupling
3333
*
3434
* @groupname production Language Features
3535
* @groupname experimental Experimental Language Features
3636
* @groupprio experimental 10
37-
*
37+
*
3838
* Dotty-specific features come at the end.
39-
*
39+
*
4040
* Note: Due to the more restricted language import mechanism in dotty (only
4141
* imports count, implicits are disregarded) we don't need the constructions
4242
* of the inherited language features. A simple object for each feature is
@@ -189,10 +189,10 @@ object language {
189189
*/
190190
@volatile implicit lazy val macros: macros = languageFeature.experimental.macros
191191
}
192-
192+
193193
/** Where imported, a backwards compatibility mode for Scala2 is enabled */
194194
object Scala2
195-
195+
196196
/** Where imported, auto-tupling is disabled */
197197
object noAutoTupling
198198
}

project/Build.scala

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ object DottyBuild extends Build {
135135
// command line arguments get passed to the last task in an aliased
136136
// sequence (see partest alias below), so this works.
137137
val args = Def.spaceDelimited("<arg>").parsed
138-
val jars = Seq((packageBin in Compile).value.getAbsolutePath) ++
139-
getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
140-
val dottyJars = "-dottyJars " + (jars.length + 1) + " dotty-lib.jar" + " " + jars.mkString(" ")
138+
val jars = List(
139+
(packageBin in Compile).value.getAbsolutePath,
140+
(packageBin in (`dotty-library`, Compile)).value.getAbsolutePath,
141+
(packageBin in (`dotty-interfaces`, Compile)).value.getAbsolutePath
142+
) ++ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
143+
val dottyJars =
144+
s"""-dottyJars ${jars.length + 2} dotty.jar dotty-lib.jar ${jars.mkString(" ")}"""
141145
// Provide the jars required on the classpath of run tests
142146
runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" "))
143147
},
@@ -147,32 +151,33 @@ object DottyBuild extends Build {
147151
* of scalajs-ir built with a different Scala compiler, we add its
148152
* sources instead of depending on the binaries.
149153
*/
150-
ivyConfigurations += config("sourcedeps").hide,
151-
libraryDependencies +=
152-
"org.scala-js" %% "scalajs-ir" % scalaJSVersion % "sourcedeps",
153-
sourceGenerators in Compile += Def.task {
154-
val s = streams.value
155-
val cacheDir = s.cacheDirectory
156-
val trgDir = (sourceManaged in Compile).value / "scalajs-ir-src"
157-
158-
val report = updateClassifiers.value
159-
val scalaJSIRSourcesJar = report.select(
160-
configuration = Set("sourcedeps"),
161-
module = (_: ModuleID).name.startsWith("scalajs-ir_"),
162-
artifact = artifactFilter(`type` = "src")).headOption.getOrElse {
163-
sys.error(s"Could not fetch scalajs-ir sources")
164-
}
165-
166-
FileFunction.cached(cacheDir / s"fetchScalaJSIRSource",
167-
FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
168-
s.log.info(s"Unpacking scalajs-ir sources to $trgDir...")
169-
if (trgDir.exists)
170-
IO.delete(trgDir)
171-
IO.createDirectory(trgDir)
172-
IO.unzip(scalaJSIRSourcesJar, trgDir)
173-
(trgDir ** "*.scala").get.toSet
174-
} (Set(scalaJSIRSourcesJar)).toSeq
175-
}.taskValue,
154+
//TODO: disabling until moved to separate project
155+
//ivyConfigurations += config("sourcedeps").hide,
156+
//libraryDependencies +=
157+
// "org.scala-js" %% "scalajs-ir" % scalaJSVersion % "sourcedeps",
158+
//sourceGenerators in Compile += Def.task {
159+
// val s = streams.value
160+
// val cacheDir = s.cacheDirectory
161+
// val trgDir = (sourceManaged in Compile).value / "scalajs-ir-src"
162+
163+
// val report = updateClassifiers.value
164+
// val scalaJSIRSourcesJar = report.select(
165+
// configuration = Set("sourcedeps"),
166+
// module = (_: ModuleID).name.startsWith("scalajs-ir_"),
167+
// artifact = artifactFilter(`type` = "src")).headOption.getOrElse {
168+
// sys.error(s"Could not fetch scalajs-ir sources")
169+
// }
170+
171+
// FileFunction.cached(cacheDir / s"fetchScalaJSIRSource",
172+
// FilesInfo.lastModified, FilesInfo.exists) { dependencies =>
173+
// s.log.info(s"Unpacking scalajs-ir sources to $trgDir...")
174+
// if (trgDir.exists)
175+
// IO.delete(trgDir)
176+
// IO.createDirectory(trgDir)
177+
// IO.unzip(scalaJSIRSourcesJar, trgDir)
178+
// (trgDir ** "*.scala").get.toSet
179+
// } (Set(scalaJSIRSourcesJar)).toSeq
180+
//}.taskValue,
176181

177182
// Adjust classpath for running dotty
178183
mainClass in (Compile, run) := Some("dotty.tools.dotc.Main"),
@@ -185,29 +190,34 @@ object DottyBuild extends Build {
185190

186191
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
187192
javaOptions <++= (dependencyClasspath in Runtime, packageBin in Compile) map { (attList, bin) =>
188-
// put the Scala {library, reflect} in the classpath
193+
// put needed dependencies on classpath:
189194
val path = for {
190195
file <- attList.map(_.data)
191196
path = file.getAbsolutePath
197+
// FIXME: when we snip the cord, this should go bye-bye
198+
if path.contains("scala-library") ||
199+
// FIXME: currently needed for tests referencing scalac internals
200+
path.contains("scala-reflect") ||
201+
// FIXME: currently needed for tests referencing scalac internals
202+
path.contains("scala-compile") ||
203+
// FIXME: should go away when xml literal parsing is removed
204+
path.contains("scala-xml") ||
205+
// needed for the xsbti interface
206+
path.contains("sbt-interface")
192207
} yield "-Xbootclasspath/p:" + path
193-
// dotty itself needs to be in the bootclasspath
194-
val fullpath = /*("-Xbootclasspath/p:" + "dotty.jar") ::*/ ("-Xbootclasspath/a:" + bin) :: path.toList
195-
// System.err.println("BOOTPATH: " + fullpath)
196208

197209
val travis_build = // propagate if this is a travis build
198210
if (sys.props.isDefinedAt(JENKINS_BUILD))
199211
List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit
200-
else
201-
List()
212+
else List()
202213

203214
val tuning =
204215
if (sys.props.isDefinedAt("Oshort"))
205216
// Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
206217
List("-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1")
207-
else
208-
List()
218+
else List()
209219

210-
("-DpartestParentID=" + pid) :: tuning ::: agentOptions ::: travis_build ::: fullpath
220+
("-DpartestParentID=" + pid) :: tuning ::: agentOptions ::: travis_build ::: path.toList
211221
}
212222
).
213223
settings(

src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import core.DenotTransformers.DenotTransformer
1717
import core.Denotations.SingleDenotation
1818

1919
import dotty.tools.backend.jvm.{LabelDefs, GenBCode, CollectSuperCalls}
20-
import dotty.tools.backend.sjs.GenSJSIR
2120

2221
/** The central class of the dotc compiler. The job of a compiler is to create
2322
* runs, which process given `phases` in a given `rootContext`.
@@ -98,7 +97,6 @@ class Compiler {
9897
new DropInlined, // Drop Inlined nodes, since backend has no use for them
9998
new MoveStatics, // Move static methods to companion classes
10099
new LabelDefs), // Converts calls to labels to jumps
101-
List(new GenSJSIR), // Generate .js code
102100
List(new GenBCode) // Generate JVM bytecode
103101
)
104102

@@ -117,20 +115,7 @@ class Compiler {
117115
*/
118116
def rootContext(implicit ctx: Context): Context = {
119117
ctx.initialize()(ctx)
120-
val actualPhases = if (ctx.settings.scalajs.value) {
121-
// Remove phases that Scala.js does not want
122-
phases.mapConserve(_.filter {
123-
case _: FunctionalInterfaces => false
124-
case _ => true
125-
}).filter(_.nonEmpty)
126-
} else {
127-
// Remove Scala.js-related phases
128-
phases.mapConserve(_.filter {
129-
case _: GenSJSIR => false
130-
case _ => true
131-
}).filter(_.nonEmpty)
132-
}
133-
ctx.setPhasePlan(actualPhases)
118+
ctx.setPhasePlan(phases)
134119
val rootScope = new MutableScope
135120
val bootstrap = ctx.fresh
136121
.setPeriod(Period(nextRunId, FirstPhaseId))

src/dotty/tools/dotc/config/PathResolver.scala

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,7 @@ object PathResolver {
4646
def classPathEnv = envOrElse("CLASSPATH", "")
4747
def sourcePathEnv = envOrElse("SOURCEPATH", "")
4848

49-
def javaBootClassPath =
50-
propOrElse("sun.boot.class.path", searchForBootClasspath)
51-
.split(":")
52-
.filterNot { jar =>
53-
// let's blacklist locally compiled classes:
54-
jar.contains("/dotty/library/target/classes") ||
55-
jar.contains("/dotty/library/target/scala-2.11/classes") ||
56-
jar.contains("/dotty/interfaces/target/classes") ||
57-
jar.contains("/dotty/target/scala-2.11/classes") ||
58-
jar.contains("/dotty/target/classes")
59-
}
60-
.mkString(":")
49+
def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath)
6150

6251
def javaExtDirs = propOrEmpty("java.ext.dirs")
6352
def scalaHome = propOrEmpty("scala.home")
@@ -266,8 +255,15 @@ class PathResolver(implicit ctx: Context) {
266255
def containers = Calculated.containers
267256

268257
lazy val result: JavaClassPath = {
269-
val (dottyJars, others) = containers.partition(_.name.contains("dotty"))
270-
val cp = new JavaClassPath((dottyJars ++ others).toIndexedSeq, context)
258+
// Prioritize `dotty.jar` and `dotty-lib.jar` to shadow others
259+
val (dottyJars, others) =
260+
containers.partition(x => x.name.contains("dotty-lib.jar") || x.name.contains("dotty.jar"))
261+
// Then any jars with `dotty` in the name - putting them before scala-library
262+
val (dottyCp, remaining) =
263+
others.partition(_.name.contains("dotty-"))
264+
265+
val cp = new JavaClassPath((dottyJars ++ dottyCp ++ remaining).toIndexedSeq, context)
266+
271267
if (settings.Ylogcp.value) {
272268
Console.println("Classpath built from " + settings.toConciseString(ctx.sstate))
273269
Console.println("Defaults: " + PathResolver.Defaults)

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import reporting._
2727
import collection.mutable
2828
import collection.immutable.BitSet
2929
import printing._
30-
import config.{Settings, ScalaSettings, Platform, JavaPlatform, SJSPlatform}
30+
import config.{Settings, ScalaSettings, Platform, JavaPlatform}
3131
import language.implicitConversions
3232
import DenotTransformers.DenotTransformer
3333
import util.Property.Key
@@ -550,8 +550,7 @@ object Contexts {
550550
}
551551

552552
protected def newPlatform(implicit ctx: Context): Platform =
553-
if (settings.scalajs.value) new SJSPlatform
554-
else new JavaPlatform
553+
new JavaPlatform
555554

556555
/** The loader that loads the members of _root_ */
557556
def rootLoader(root: TermSymbol)(implicit ctx: Context): SymbolLoader = platform.rootLoader(root)

test/dotc/tests.scala

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dotc
33
import test._
44
import org.junit.{Before, Test}
55

6+
import java.io.{ File => JFile }
67
import scala.reflect.io.Directory
78
import scala.io.Source
89

@@ -23,20 +24,34 @@ class tests extends CompilerTest {
2324
"-d", defaultOutputDir
2425
)
2526

26-
val classPath = List(
27+
val checkOptions = List(
2728
"-Yno-deep-subtypes",
2829
"-Yno-double-bindings",
2930
"-Yforce-sbt-phases",
30-
"-color:never",
31-
"-classpath",
32-
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" +
33-
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
31+
"-color:never"
3432
)
3533

34+
val classPath = {
35+
val paths = List(
36+
"./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar",
37+
"./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar",
38+
"./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar"
39+
).map { p =>
40+
val file = new JFile(p)
41+
assert(
42+
file.exists,
43+
s"""File "$p" couldn't be found. Run `packageAll` from build tool before testing"""
44+
)
45+
file.getAbsolutePath
46+
}.mkString(":")
47+
48+
List("-classpath", paths)
49+
}
50+
3651
implicit val defaultOptions = noCheckOptions ++ {
3752
if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
3853
else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
39-
} ++ classPath
54+
} ++ checkOptions ++ classPath
4055

4156
val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler", "-Yprintpos")
4257

@@ -189,32 +204,10 @@ class tests extends CompilerTest {
189204
@Test def compileIndexedSeq = compileLine("./scala-scala/src/library/scala/collection/immutable/IndexedSeq.scala")
190205

191206
// Not a junit test anymore since it is order dependent
192-
def dottyBootedLib = compileDir(
193-
libDir,
194-
".",
195-
List(
196-
"-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir +
197-
":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" +
198-
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" +
199-
":./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar"
200-
)
201-
)(allowDeepSubtypes) // note the -deep argument
207+
def dottyBootedLib = compileDir(libDir, ".")(allowDeepSubtypes) // note the -deep argument
202208

203209
// Not a junit test anymore since it is order dependent
204-
def dottyDependsOnBootedLib = compileDir(
205-
dottyDir,
206-
".",
207-
List(
208-
"-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir +
209-
":./dotty-lib.jar" +
210-
":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" +
211-
// this needs to get compiled together with the compiler:
212-
//":./target/scala-2.11/src_managed/main/scalajs-ir-src/"
213-
// but falling back to:
214-
":/home/fixel/.ivy2/cache/org.scala-js/scalajs-ir_2.11/jars/scalajs-ir_2.11-0.6.8.jar"
215-
// for the time being.
216-
)
217-
)(allowDeepSubtypes) // note the -deep argument
210+
@Test def dottyDependsOnBootedLib = compileDir(dottyDir, ".")(allowDeepSubtypes) // note the -deep argument
218211

219212
@Test def dotc_ast = compileDir(dotcDir, "ast")
220213
@Test def dotc_config = compileDir(dotcDir, "config")
@@ -279,7 +272,7 @@ class tests extends CompilerTest {
279272
"scalaPrimitives.scala"
280273
) map (s"${backendDir}jvm/" + _), testPickling)
281274

282-
@Test def tasty_backend_sjs = compileDir(s"${backendDir}", "sjs", testPickling)
275+
//@Test def tasty_backend_sjs = compileDir(s"${backendDir}", "sjs", testPickling)
283276

284277
@Test def tasty_dotc = compileDir(toolsDir, "dotc", testPickling)
285278
@Test def tasty_dotc_ast = compileDir(dotcDir, "ast", testPickling)

0 commit comments

Comments
 (0)