-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: Add @__RELOCDIR__
, a relocatable version of @__DIR__
#55146
base: master
Are you sure you want to change the base?
Conversation
Open questions:
|
I often use |
I'm not a big fan of the fact that something as simple as: const data = joinpath(@__RELOCDIR__, "myfile.data") is still non-relocatable. The alternative path in my mind would be to have That might be too extreme to be worth hooking into low-level libraries, but it's the only way I can imagine getting good relocatability behavior "transparently" |
If We could perhaps handle the |
I think that's too risky - Scanning all the String's in your application and modifying some of them seems like a great way to mess up programs. What happens if it was already used as a key in a Dict, etc.? We wouldn't be able to mark |
I don't disagree. But having the cost of prefix checking before operations in the file handling code seems suboptimal. I kinda want it to return a |
The scan for a prefix is probably pretty cheap (compared to the syscall), but the fact that we have multiple depot paths is definitely a huge pain.. that would require additional syscalls and may not even be possible to soundly emulate So yeah, maybe the |
This adds the
@__RELOCDIR__
macro which shall not hinder relocation of packages, unlike@__DIR__
.It works by splitting
@__DIR__
intodepot
andsubpath
at macro expansion time.Resolution of
@__RELOCDIR__
happens at runtime by trying to find a dir atdepot/subpath
.If used in scripts or with
julia -e <expr>
the macro behaves like@__DIR__
.If resolution of
@__RELOCDIR__
fails the value of@__DIR__
is returned.Fixes #54430