Skip to content

Commit c612a79

Browse files
committed
provide API to use absolute path for SourceInfo
1 parent 96cc1b7 commit c612a79

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/src/main/scala/chisel3/internal/SourceInfoFileResolver.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ private[internal] object SourceInfoFileResolver {
1616
def resolve(source: scala.reflect.internal.util.SourceFile): String = {
1717
val userDir = sys.props.get("user.dir") // Figure out what to do if not provided
1818
val projectRoot = sys.props.get("chisel.project.root")
19+
val isAbs = sys.props.get("chisel.project.root.absolute").isDefined
1920
val root = projectRoot.orElse(userDir)
2021

2122
val path = root.map(r => source.file.canonicalPath.stripPrefix(r)).getOrElse(source.file.name)
2223
val pathNoStartingSlash = if (path(0) == '/') path.tail else path
23-
pathNoStartingSlash
24+
if(isAbs) pathNoStartingSlash else source.file.path
2425
}
2526
}

0 commit comments

Comments
 (0)