From c7a97719e9de236d569a0e40abd5a3cd122dd5a5 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 8 Aug 2016 12:28:21 -0700 Subject: Don't create output files until the compiler succeeds Creating the output file preemptively screws up make, as on subsequent executions of make, it thinks the task succeeded. --- src/main/scala/firrtl/Driver.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/scala/firrtl/Driver.scala b/src/main/scala/firrtl/Driver.scala index bd7210f4..1a72746d 100644 --- a/src/main/scala/firrtl/Driver.scala +++ b/src/main/scala/firrtl/Driver.scala @@ -27,7 +27,6 @@ MODIFICATIONS. package firrtl -import java.io.{PrintWriter, Writer, File} import scala.io.Source import scala.collection.mutable import Annotations._ @@ -57,9 +56,12 @@ Options: infoMode: InfoMode = IgnoreInfo, annotations: AnnotationMap = new AnnotationMap(Seq.empty)) = { val parsedInput = Parser.parse(Source.fromFile(input).getLines, infoMode) - val writerOutput = new PrintWriter(new File(output)) - compiler.compile(parsedInput, annotations, writerOutput) - writerOutput.close + val outputBuffer = new java.io.CharArrayWriter + compiler.compile(parsedInput, annotations, outputBuffer) + + val outputFile = new java.io.PrintWriter(output) + outputFile.write(outputBuffer.toString) + outputFile.close() } /** -- cgit v1.2.3