-
Notifications
You must be signed in to change notification settings - Fork 637
[svsim/ChiselSim] Discover the project's root directory in a sandboxed build #4931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…-system sandboxing (e.g., as in the newer versions of mill). - adds public `getProjectRootOrCwd` in `svsim.Workspace` as a more reliable way to discover the current project's root path - adds workingDirectory to `svsim.Simulation`, resolved absolute path to `workingDirectoryPath`, resolved using `getProjectRootOrCwd`. - changes `FileCheck`, `HasTestingDirectory`, and `WithTestingDirectory` to use `getProjectRootOrCwd`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a much better way of handling this.
I've been annoyed/surprised by the deep placement of the build area in out/
.
svsim/src/main/scala/Workspace.scala
Outdated
def getProjectRootOrCwd: Path = | ||
sys.props | ||
.get("chisel.project.root") | ||
.orElse(sys.env.get("CHISEL_PROJECT_ROOT")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider enshrining CHISEL_PROJECT_ROOT
elsewhere like here:
val projectRoot = sys.props.get("chisel.project.root") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's good to have consistent behavior, but I'd do that in a separate PR.
For the record, the justification for such an environment variable is that the "native" versions of mill (and bloop), at least on macOS, seem to ignore -Dprop=value
from both .mill-jvm-opts
and the command line arguments. Therefore, it would be helpful to provide an alternative method for specifying this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's annoying that native is ignoring -Dprop
, will have to look into that at some point, would you mind filing an issue about that so when I forget I eventually notice the issue and remember again?
Thank you so much for the quick review! |
+revert added black line
@kammoh it does look like some tests are failing, some due to things that used to be relative paths not being relative anymore:
|
No longer assuming `testingDirectory.getDirectory` is necessarily a relative path
Oops! It should be fixed now. |
Newer versions of
mill
run tests inside a sandboxed folder under the 'out/' folder.The current svsim/ChiselSim code does not consider this, resulting in a weird, deeply-nested, and hard to predict simulation path. This can be confusing for users. It's particularly annoying when trying to access trace files created by the simulation.
This is taken from #4911 with some modifications. #4911 will be updated after this PR is merged.
getProjectRootOrCwd
insvsim.Workspace
as a more reliable way to discover the current project's root path, especially in the presence of build-system sandboxing.svsim.Simulation
, resolved absolute path toworkingDirectoryPath
, resolved usinggetProjectRootOrCwd
.FileCheck
,HasTestingDirectory
, andWithTestingDirectory
to usegetProjectRootOrCwd
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
and clean up the commit message.Create a merge commit
.