-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Model abigen!
s Source::Path
behaviour after include_str!
#97
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
Comments
So I took a look into this. Originally I thought we could use the I then started to look at using span to get this information out. Turns out you can use a span to get access to the calling file path, but currently it's an unstable feature. See this open issue It provides a method on span |
From memory, this needed to be solved in order for us to properly support native Windows builds. This is due to how paths are handled between windows and unix systems. See this tracking issue in the sway repo. I just re-checked the issue I mentioned above and it seems that this PR just got merged 2 weeks ago that might allow us to move forward here. Might possibly be available in the next rust release. |
Follow-up to #94.
Currently the path passed to the right hand side argument of
abigen!
is expected to be relative to thestd::env::current_dir
:fuels-rs/fuels-core/src/source.rs
Line 47 in f6d4cc0
This evaluates to whatever happens to be the current directory at the time of macro expansion. This means that the necessary path given to
abigen!
can change when the project is moved to a different subdirectory of the same workspace, or if its moved from a workspace into its own project, or vice versa. Ideally, we want oursrc
not to be dependent on the directory that the project happens to be executed within.To fix this, we could model our behaviour after the std
include_str!
macro.include_str!
accepts a path that is relative to the file in which it is invoked. For example if we have:the
abigen!
macro could then be invoked within theproject/tests/harness.rs
withThe text was updated successfully, but these errors were encountered: