diff options
-rw-r--r-- | stage1/Stage1Lib.scala | 35 | ||||
-rw-r--r-- | stage2/plugins/Dotty.scala | 18 | ||||
-rw-r--r-- | stage2/plugins/Frege.scala | 11 |
3 files changed, 30 insertions, 34 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index f73995e..4f3f592 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -201,8 +201,6 @@ class Stage1Lib( logger: Logger ) extends BaseLib{ val d = Dependencies(dependencies) val classpath = d.classpath val cp = classpath.string - if(classpath.files.isEmpty) - throw new Exception("Trying to compile with empty classpath. Source files: " ++ sourceFiles.toString) if( sourceFiles.isEmpty ){ None @@ -258,29 +256,28 @@ class Stage1Lib( logger: Logger ) extends BaseLib{ try{ lib.runMain( _class, - dualArgs ++ singleArgs ++ Seq( - "-cp", cp // let's put cp last. It so long + dualArgs ++ singleArgs ++ ( + if(cp.isEmpty) Nil else Seq("-cp", cp) ) ++ sourceFiles.map(_.toString), zinc.classLoader(classLoaderCache) ) } catch { - case e: Exception => + case scala.util.control.NonFatal(e) => System.err.println(red("The Scala compiler crashed. Try running it by hand:")) System.out.println(s""" - java -cp \\ - ${zinc.classpath.strings.mkString(":\\\n")} \\ - \\ - ${_class} \\ - \\ - ${dualArgs.grouped(2).map(_.mkString(" ")).mkString(" \\\n")} \\ - \\ - ${singleArgs.mkString(" \\\n")} \\ - \\ - -cp \\ - ${classpath.strings.mkString(":\\\n")} \\ - \\ - ${sourceFiles.sorted.mkString(" \\\n")} - """ +java -cp \\ +${zinc.classpath.strings.mkString(":\\\n")} \\ +\\ +${_class} \\ +\\ +${dualArgs.grouped(2).map(_.mkString(" ")).mkString(" \\\n")} \\ +\\ +${singleArgs.mkString(" \\\n")} \\ +\\ +${if(cp.isEmpty) "" else (" -classpath \\\n" ++ classpath.strings.mkString(":\\\n"))} \\ +\\ +${sourceFiles.sorted.mkString(" \\\n")} +""" ) redirectOutToErr( e.printStackTrace ) diff --git a/stage2/plugins/Dotty.scala b/stage2/plugins/Dotty.scala index 4934568..8a49257 100644 --- a/stage2/plugins/Dotty.scala +++ b/stage2/plugins/Dotty.scala @@ -107,8 +107,6 @@ class DottyLib( val d = Dependencies(dependencies) val classpath = d.classpath val cp = classpath.string - if(classpath.files.isEmpty) - throw new Exception("Trying to compile with empty classpath. Source files: " ++ sourceFiles.toString) if( sourceFiles.isEmpty ){ None @@ -123,7 +121,7 @@ class DottyLib( "-d", compileTarget.toString ) val singleArgs = dottyOptions.map( "-S" ++ _ ) - + val cl = dependency.classLoader(classLoaderCache) val code = try{ System.err.println("Compiling with Dotty to " ++ compileTarget.toString) @@ -132,15 +130,17 @@ class DottyLib( lib.runMain( _class, dualArgs ++ singleArgs ++ Seq( - "-bootclasspath", dependency.classpath.string, // let's put cp last. It so long - "-classpath", classpath.string // let's put cp last. It so long + "-bootclasspath", dependency.classpath.string + ) ++ ( + if(cp.isEmpty) Nil else Seq("-classpath", cp) // let's put cp last. It so long ) ++ sourceFiles.map(_.toString), - dependency.classLoader(classLoaderCache) + cl ) } } catch { case e: Exception => System.err.println(red("Dotty crashed. See https://github.com/lampepfl/dotty/issues. To reproduce run:")) + System.err.println(cl) System.out.println(s""" java -cp \\ ${dependency.classpath.strings.mkString(":\\\n")} \\ @@ -153,13 +153,13 @@ ${singleArgs.mkString(" \\\n")} \\ \\ -bootclasspath \\ ${dependency.classpath.strings.mkString(":\\\n")} \\ --classpath \\ -${classpath.strings.mkString(":\\\n")} \\ +${if(cp.isEmpty) "" else (" -classpath \\\n" ++ classpath.strings.mkString(":\\\n"))} \\ \\ ${sourceFiles.sorted.mkString(" \\\n")} + """ ) - ExitCode.Failure + throw e } if(code == ExitCode.Success){ diff --git a/stage2/plugins/Frege.scala b/stage2/plugins/Frege.scala index c0868af..b5a4dd0 100644 --- a/stage2/plugins/Frege.scala +++ b/stage2/plugins/Frege.scala @@ -67,8 +67,6 @@ class FregeLib( val d = Dependencies(dependencies) val classpath = d.classpath val cp = classpath.string - if(classpath.files.isEmpty) - throw new Exception("Trying to compile with empty classpath. Source files: " ++ sourceFiles.toString) if( sourceFiles.isEmpty ){ None @@ -78,11 +76,13 @@ class FregeLib( if( d.lastModified > lastCompiled || sourceFiles.exists(_.lastModified > lastCompiled) ){ val _class = "frege.compiler.Main" + val fp = (fregeDependency.classpath.strings ++ fregeDependencies.map(_.classpath.string)) val dualArgs = Seq( "-target", fregeTarget, - "-d", compileTarget.toString, - "-fp", (fregeDependency.classpath.strings ++ fregeDependencies.map(_.classpath.string)).mkString(":") + "-d", compileTarget.toString + ) ++ ( + if(fp.isEmpty) Nil else Seq("-fp", fp.mkString(":")) ) val singleArgs = fregeOptions val code = @@ -111,8 +111,7 @@ ${singleArgs.mkString(" \\\n")} \\ \\ -bootclasspath \\ ${fregeDependency.classpath.strings.mkString(":\\\n")} \\ --classpath \\ -${classpath.strings.mkString(":\\\n")} \\ +${if(classpath.strings.isEmpty) "" else (" -fp \\\n" ++ classpath.strings.mkString(":\\\n"))} \\ \\ ${sourceFiles.sorted.mkString(" \\\n")} """ |