diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2016-04-27 09:45:56 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2016-04-28 13:34:01 -0400 |
commit | b37ccc12d3d6e8fc5fcf2730fc498f5bb8b08655 (patch) | |
tree | 994972a042688aef87b0fd07b1111ea915498561 /stage1 | |
parent | 17da8b5c94c3de3053654d83948df630ffe0d0c2 (diff) | |
download | cbt-b37ccc12d3d6e8fc5fcf2730fc498f5bb8b08655.tar.gz cbt-b37ccc12d3d6e8fc5fcf2730fc498f5bb8b08655.tar.bz2 cbt-b37ccc12d3d6e8fc5fcf2730fc498f5bb8b08655.zip |
if compiler crashed, print commands to reproduce it outside of cbt
Diffstat (limited to 'stage1')
-rw-r--r-- | stage1/Stage1Lib.scala | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/stage1/Stage1Lib.scala b/stage1/Stage1Lib.scala index cb84310..f484bbf 100644 --- a/stage1/Stage1Lib.scala +++ b/stage1/Stage1Lib.scala @@ -193,21 +193,50 @@ class Stage1Lib( val logger: Logger ) extends BaseLib{ val start = System.currentTimeMillis - val code = redirectOutToErr{ - lib.runMain( - "com.typesafe.zinc.Main", - Seq( - "-scala-compiler", scalaCompiler.toString, - "-scala-library", scalaLibrary.toString, - "-sbt-interface", sbtInterface.toString, - "-compiler-interface", compilerInterface.toString, - "-scala-extra", scalaReflect.toString, - "-cp", cp, - "-d", compileTarget.toString - ) ++ scalacOptions.map("-S"++_) ++ files.map(_.toString), - zinc.classLoader(classLoaderCache) + val _class = "com.typesafe.zinc.Main" + val dualArgs = + Seq( + "-scala-compiler", scalaCompiler.toString, + "-scala-library", scalaLibrary.toString, + "-sbt-interface", sbtInterface.toString, + "-compiler-interface", compilerInterface.toString, + "-scala-extra", scalaReflect.toString, + "-d", compileTarget.toString ) - } + val singleArgs = scalacOptions.map( "-S" ++ _ ) + + val code = + try{ + redirectOutToErr{ + lib.runMain( + _class, + dualArgs ++ singleArgs ++ Seq( + "-cp", cp // let's put cp last. It so long + ) ++ files.map(_.toString), + zinc.classLoader(classLoaderCache) + ) + } + } catch { + case e: Exception => + 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")} \\ +\\ +${files.sorted.mkString(" \\\n")} +""" + ) + ExitCode.Failure + } if(code == ExitCode.Success){ // write version and when last compilation started so we can trigger |