-
Notifications
You must be signed in to change notification settings - Fork 1.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
How to get the path(s) from a files
object?
#5273
Comments
Just stumbled across this same problem, although with the returned object from (maybe I'm a little late, but commenting for future record...) |
What is this needed for? Generally, you can just use the objects themselves and they'll do the right thing. |
Having String objects rather than File objects is useful if you plan to call string methods on it. In my personal use case, I had a textures = files(
...
)
foreach texture : textures
tex_target = configure_file(input: texture, output: '@PLAINNAME@', copy: true)
if host_machine.system() == 'emscripten'
# embed files in web build, or else textures cannot be opened
link_args += ['--embed-file', '@0@'.format(tex_target)]
endif
endforeach
executable('name',
sources,
link_args: link_args,
...
) |
From an implementation POV, I think it is now really easy to implement because we have FileHolder class that allows adding API on it. That's one of the nice things we get from the recent Holder refactoring. |
If |
I realize I'm late to this discussion, but at least as of Meson 0.55.3,
|
This is more of a problem (for me) with Meson 1.3.0, as now the workaround code gives the error:
Changing it to
I can’t find a way out of this hole. |
OK that seems to have been fixed by commit 85e4ee5 on |
Deprecation warnings are, by themselves, just warnings. You can ignore the warning and it won't change your build results. However it is a general sign that your build may have been broken all along, since the python-level The full_path method is always equal to |
Sure, I know that, but it’s a bug in Meson if it’s putting out a warning and it’s not possible to avoid that warning in my project. As an aside, it would be helpful if Meson gave more advice about how to fix a deprecation warning when it prints one (e.g. link to a docs page which documents the deprecation and suggests common ways of doing the right thing instead). I can file that as a separate bug if that would be helpful?
The build definitely worked before, but as you say this was apparently by accident.
That’s the point of my comment: it doesn’t seem to be possible to use
|
Without getting into whether this is a bug or not, you originally said it is "uncompilable", and that is all I was disagreeing about.
Maybe. What should we do about other deprecation warnings? |
Ah yes, fair point, my wording was incorrect there. :)
I was thinking maybe have a docs link for each/every deprecation warning? The docs could be more or less expansive depending on how trivial the deprecation warning is (e.g. is it a like-for-like replacement with a different function call, or does it require people to rework their meson.build to use types differently?). Shall I file an issue about it for further discussion? |
Sure. Can't hurt. |
Alpine 3.19 ships with Meson 1.3.0, which has broken handling of File objects and their paths. This causes (as far as I can tell) un-work-around-able breakage of GLib’s build. See mesonbuild/meson#5273 (comment) That should be fixed in Meson 1.4.0, but that might not be released for a while. Because we’re here to test GLib, not Meson, let’s pin the Meson version in the Alpine CI image to 1.2.3, which we know works and is reasonably up to date (and is what the other CI images use). Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/3361388 Signed-off-by: Philip Withnall <pwithnall@gnome.org>
⇒ #12689, sorry for the festive delay |
The feature '@0@'.format(name) was used - probably derived from: mesonbuild/meson#5273 This resulted in the warning: DEPRECATION: Project uses feature that was always broken, and is now deprecated since '1.3.0' Rework meson.build files so that this feature is no longer used.
Now the devs will be stuck with fat red deprecation messages locally, as obviously we can't yet use a feature that won't reach many distros for years, and though I tried hard, I fail to see another way. |
if meson.version().version_compare('>=1.4')
p = that_file.full_path()
else
# this emits a deprecation warning ONLY on 1.3, not on previous versions
# also it's not obvious what the actual resulting value is
p = meson.current_source_dir() / '@0@'.format(that_file)
endif You're stuck with the deprecation warning for 1.3 anyways since we can't change how an already released version works. |
Oh, thanks, conditionals like this can be done to cover both. I don't know why I thought that deprecations would be emitted even for if-branches that weren't taken. |
Once upon a time they were emitted. This bothered someone, who did a bit of clever coding to locally override the meson_version in a restorable context whenever you enter an if block. It's a beautifully dirty hack because it involves having a dedicated node type for strings depending on whether they are the result of a specific function call (the meson.version() one). I forget exactly which version that was implemented. It was a while ago, but against meson's lengthy history it wasn't that long ago. |
I'd like to avoid duplicating things in my build scripts, so where possible, I'd like to obtain the canonical paths from a
files()
object so that I can use these definitions.Is there a way to do this? I couldn't find it anywhere in the documentation.
I'm looking for something akin to Python's
pathlib.Path
I suppose.The text was updated successfully, but these errors were encountered: