Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
CxxsimTask: use pkg-config automagically.
Browse files Browse the repository at this point in the history
  • Loading branch information
kivikakk committed May 16, 2024
1 parent 70721ac commit 2affaf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ package ee.hrzn.chryse.platform.cxxrtl

import chisel3.BlackBox

import scala.sys.process._

final case class CXXRTLOptions(
clockHz: Int,
blackboxes: Seq[Class[_ <: BlackBox]] = Seq(),
cxxFlags: Seq[String] = Seq(),
ldFlags: Seq[String] = Seq(),
)
pkgConfig: Seq[String] = Seq(),
) {
val allCxxFlags: Seq[String] = cxxFlags ++ pkgConfig.flatMap(
Seq("pkg-config", "--cflags", _).!!.trim.split(' '),
)
val allLdFlags: Seq[String] = ldFlags ++ pkgConfig.flatMap(
Seq("pkg-config", "--libs", _).!!.trim.split(' '),
)
}
6 changes: 3 additions & 3 deletions src/main/scala/ee/hrzn/chryse/tasks/CxxsimTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ object CxxsimTask extends BaseTask {
cc.replace(s"$cxxsimDir/", s"$buildDir/")
.replace(".cc", ".o")

def compileCmdForCc(cc: String, obj: String) = Seq(
def compileCmdForCc(cc: String, obj: String): Seq[String] = Seq(
"c++",
s"-I$buildDir",
s"-I$yosysDatDir/include/backends/cxxrtl/runtime",
"-c",
cc,
"-o",
obj,
) ++ cxxOpts ++ cxxrtlOptions.cxxFlags
) ++ cxxOpts ++ cxxrtlOptions.allCxxFlags

// XXX: depend on what look like headers for now.
val cus = for {
Expand All @@ -163,7 +163,7 @@ object CxxsimTask extends BaseTask {
binPath,
Seq("c++", "-o", binPath) ++ cxxOpts ++ cus.map(
_.outPath,
) ++ cxxrtlOptions.ldFlags,
) ++ cxxrtlOptions.allLdFlags,
)
runCu("linking", linkCu)

Expand Down

0 comments on commit 2affaf3

Please sign in to comment.