Skip to content

Commit

Permalink
[svsim] Better error message when verilator not on PATH (#3829) (#3833)
Browse files Browse the repository at this point in the history
(cherry picked from commit 41dd267)

Co-authored-by: Jack Koenig <koenig@sifive.com>
  • Loading branch information
mergify[bot] and jackkoenig authored Feb 16, 2024
1 parent d7cab5d commit 353dfb5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions svsim/src/main/scala/verilator/Backend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
package svsim.verilator

import svsim._
import java.io.{BufferedReader, InputStreamReader}
import scala.sys.process._
import scala.collection.mutable

object Backend {
object CompilationSettings {
Expand All @@ -22,10 +23,12 @@ object Backend {
enableAllAssertions: Boolean = false)

def initializeFromProcessEnvironment() = {
val process = Runtime.getRuntime().exec(Array("which", "verilator"))
val outputReader = new BufferedReader(new InputStreamReader(process.getInputStream()))
val executablePath = outputReader.lines().findFirst().get()
process.waitFor()
val output = mutable.ArrayBuffer.empty[String]
val exitCode = List("which", "verilator").!(ProcessLogger(output += _))
if (exitCode != 0) {
throw new Exception(s"verilator not found on the PATH!\n${output.mkString("\n")}")
}
val executablePath = output.head.trim
new Backend(executablePath = executablePath)
}
}
Expand Down

0 comments on commit 353dfb5

Please sign in to comment.