-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Ability to determine the file a module is in without complete knowledge of the compilations module dependency graph #20999
Comments
@src().module
cannot uniquely distinguish modules@src().module
alone does not uniquely distinguish modules
The issue title is a little inaccurate -- the module names are definitely unique, and your example shows that -- but I think your issue text is presenting the problem correctly. One possible solution here would be to provide a Before thinking too hard about solutions, though: is there a concrete use case here? What are you actually trying to use |
If I can't determine the file path on disk (relative to build.zig) from So I was thinking about a module name to module base path lookup but then realised the module string can't be relied upon without knowledge of the full module graph. |
I've tried building Zig a few times today (no luck), specifically to try the new Here's the line in For my library to keep working, I need some reliable way to go from the output of The simplest solution to this dilemma is the first one I proposed: save the full path-relative file name to If it's also useful to the build system to have a |
The download page has the change now. |
@src().module
alone does not uniquely distinguish modules
Thanks for the update. My problem was down to a silly typo in So with a nice comptime conditional, I added a logging step to module: root
file: ohsnap.zig The output from module:
file: src/ohsnap.zig So the remaining difficulty is that I have no way, so far as I know, of mapping the module name The difficulty is easy to illustrate: I made a copy of .root_source_file = b.path("test/ohsnap.zig"), As expected, this new file builds and runs correctly, and with Zig module: root
file: ohsnap.zig On Zig 0.13: module:
file: test/ohsnap.zig So I can't simply guess that the directory of the module I'm sure that there are a few ways to handle this, my use case requires some way to go from the output of Be that as it may, so long as there is some way to get from the output of |
I'd like to encourage some design work on this issue, it's important to me that it get solved before the 0.14 release. Background: the ohsnap library, based on TigerBeetle's snapshot testing (which will have the same problem) uses The goal is for user code to be able to call A less ideal, but acceptable solution, would involve user code providing some sort of data available to user code but not library code, perhaps something from What does a good solution to this look like? I admit ignorance in why the change was made in the first place, while assuming that the reasons are good (I could make some guesses but that doesn't seem important). I'm hoping, since this issue remains open, that the goal doesn't include making it impossible for user code to communicate its full source location to libraries, since that's a useful and powerful thing to be able to do, and, I would guess, the main use of Again, if there's already a way forward and I missed it, great! Point me at it and we can close this issue. Thanks for your consideration in this matter. |
Zig Version
0.14.0-dev.985+cf87a1a7c
Steps to Reproduce and Observed Behavior
Within a single compilation multiple modules can have the same name, the build system de-duplicates these by appending a number to the name.
But this means you cannot determine which module a file is actually in, as the
@src().module
string depends on both if that module has a name collision with another and also on the order the imports were added, which with the package manager and transitive dependencies is a challenge :).Expected Behavior
Ability to determine the module a file is in without complete knowledge of the compilations module dependency graph.
The text was updated successfully, but these errors were encountered: