graceful handling of empty files
This commit is contained in:
@@ -376,18 +376,19 @@ object MacroCompiler extends App {
|
|||||||
throw new Exception(usage)
|
throw new Exception(usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
def run(args: List[String]) = {
|
def run(args: List[String]) {
|
||||||
val (params, synflops) = parseArgs(Map[MacroParam, File](), false, args)
|
val (params, synflops) = parseArgs(Map[MacroParam, File](), false, args)
|
||||||
try {
|
try {
|
||||||
val macros = readJSON(params get Macros).get map (x => (new Macro(x)).blackbox)
|
val macros = readJSON(params get Macros).get map (x => (new Macro(x)).blackbox)
|
||||||
val circuit = Circuit(NoInfo, macros, macros.last.name)
|
|
||||||
val annotations = AnnotationMap(Seq(MacroCompilerAnnotation(
|
|
||||||
circuit.main, params(Macros), params get Library, synflops)))
|
|
||||||
val state = CircuitState(circuit, HighForm, Some(annotations))
|
|
||||||
val verilog = new FileWriter(params(Verilog))
|
val verilog = new FileWriter(params(Verilog))
|
||||||
val result = new MacroCompiler compile (state, verilog)
|
if (macros.nonEmpty) {
|
||||||
|
val circuit = Circuit(NoInfo, macros, macros.last.name)
|
||||||
|
val annotations = AnnotationMap(Seq(MacroCompilerAnnotation(
|
||||||
|
circuit.main, params(Macros), params get Library, synflops)))
|
||||||
|
val state = CircuitState(circuit, HighForm, Some(annotations))
|
||||||
|
val result = new MacroCompiler compile (state, verilog)
|
||||||
|
}
|
||||||
verilog.close
|
verilog.close
|
||||||
result
|
|
||||||
} catch {
|
} catch {
|
||||||
case e: java.util.NoSuchElementException =>
|
case e: java.util.NoSuchElementException =>
|
||||||
throw new Exception(usage)
|
throw new Exception(usage)
|
||||||
|
|||||||
@@ -128,10 +128,10 @@ object Utils {
|
|||||||
case (res, _) => res
|
case (res, _) => res
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
case _ => None
|
case _ => Some(Nil)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case _: Throwable => None
|
case _: Throwable => Some(Nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user