summaryrefslogtreecommitdiff
path: root/src/compiler/scala
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2006-01-19 15:32:26 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2006-01-19 15:32:26 +0000
commit64b3256bbb6d9c6d4efd2c9fe54f2bc31b2ae849 (patch)
treef637a1af1a7ebdee98f7a111a2ad9613b2d795a8 /src/compiler/scala
parentd3eec69c3351e6583152ea0b6683a83f06b0c048 (diff)
downloadscala-64b3256bbb6d9c6d4efd2c9fe54f2bc31b2ae849.tar.gz
scala-64b3256bbb6d9c6d4efd2c9fe54f2bc31b2ae849.tar.bz2
scala-64b3256bbb6d9c6d4efd2c9fe54f2bc31b2ae849.zip
Updated Scalac to support a mode (triggered by ...
Updated Scalac to support a mode (triggered by setting 'scalacdebugging' to true) that prints the compiled files and any stack trace generated by the compiler. Use it in SABBUS for quick and strap.
Diffstat (limited to 'src/compiler/scala')
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala98
1 files changed, 61 insertions, 37 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index cd67dba06e..415b7001f4 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -118,6 +118,10 @@ package scala.tools.ant {
/** Instruct the compiler to generate debugging information */
private var addParams: String = ""
+ /** Whether the compiler is being debuged. Prints more information in case
+ * in case of failure. */
+ private var scalacDebugging: Boolean = false
+
/******************************************************************************\
** Properties setters **
\******************************************************************************/
@@ -262,6 +266,10 @@ package scala.tools.ant {
def setAddparams(input: String): Unit =
addParams = input
+ /** Set the scalac debugging attribute. */
+ def setScalacdebugging(input: Boolean): Unit =
+ scalacDebugging = input
+
/******************************************************************************\
** Properties getters **
\******************************************************************************/
@@ -380,28 +388,41 @@ package scala.tools.ant {
// If force is false, only files were the .class file in destination is
// older than the .scala file will be used.
val sourceFiles: List[File] =
- for (val originDir <- getOrigin;
- val originFile <- {
- var includedFiles =
- getDirectoryScanner(originDir).getIncludedFiles()
- if (!force) {
- includedFiles = new SourceFileScanner(this).
- restrict(includedFiles, originDir, destination.get, mapper)
- }
- (List.fromArray(includedFiles)).
- map(nameToFile(originDir))
- })
- yield {
+ for {
+ val originDir <- getOrigin;
+ val originFile <- {
+ var includedFiles =
+ getDirectoryScanner(originDir).getIncludedFiles()
+ if (!force) {
+ includedFiles = new SourceFileScanner(this).
+ restrict(includedFiles, originDir, destination.get, mapper)
+ }
+ val list = List.fromArray(includedFiles)
+ if (scalacDebugging && list.length > 0)
+ log(
+ list.mkString(
+ "Compiling source file" +
+ (if (list.length > 1) "s: " else ": "),
+ ", ",
+ " "
+ ) + "to " + getDestination.toString()
+ )
+ else if (list.length > 0)
+ log(
+ "Compiling " + list.length + " source file" +
+ (if (list.length > 1) "s" else "") +
+ (" to " + getDestination.toString())
+ )
+ else
+ log("No files selected for compilation", Project.MSG_VERBOSE)
+
+ list
+ }
+ } yield {
log(originFile.toString(), Project.MSG_DEBUG)
- originFile
+ nameToFile(originDir)(originFile)
}
- if (sourceFiles.length == 0)
- log("No files selected for compilation", Project.MSG_VERBOSE)
- else log("Compiling " + sourceFiles.length + " source file" +
- (if (sourceFiles.length > 1) "s" else "") +
- (" to " + getDestination.toString()))
-
// Builds-up the compilation settings for Scalac with the existing Ant
// parameters.
val reporter = new ConsoleReporter()
@@ -446,27 +467,30 @@ package scala.tools.ant {
try {
(new compiler.Run).compile(sourceFiles.map(f:File=>f.toString()))
if (reporter.errors > 0)
- error("Compile failed with " +
- reporter.errors + " error" +
- (if (reporter.errors > 1) "s" else "") +
- "; see the compiler error output for details."
- )
- }
- catch {
- case exception @ FatalError(msg) => {
- exception.printStackTrace()
- if (settings.debug.value) exception.printStackTrace()
- error("Compile failed because of an internal compiler error (" + msg +
- "); see the error output for details.")
- }
- }
- if (reporter.warnings > 0)
- log("Compile suceeded with " +
+ error (
+ "Compile failed with " +
+ reporter.errors + " error" +
+ (if (reporter.errors > 1) "s" else "") +
+ "; see the compiler error output for details."
+ )
+ else if (reporter.warnings > 0)
+ log (
+ "Compile suceeded with " +
reporter.warnings + " warning" +
(if (reporter.warnings > 1) "s" else "") +
"; see the compiler output for details."
- )
- reporter.printSummary()
+ )
+ reporter.printSummary()
+ } catch {
+ case exception: Throwable if (exception.getMessage != null) =>
+ if (scalacDebugging) exception.printStackTrace()
+ error("Compile failed because of an internal compiler error (" +
+ exception.getMessage + "); see the error output for details.")
+ case exception =>
+ if (scalacDebugging) exception.printStackTrace()
+ error("Compile failed because of an internal compiler error " +
+ "(no error message provided); see the error output for details.")
+ }
}
}