mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.3k stars 1.52k forks source link

Join paths kwargs #13165

Open bruchar1 opened 2 weeks ago

bruchar1 commented 2 weeks ago

Fixes https://github.com/mesonbuild/meson/issues/13130.

Fixes https://github.com/mesonbuild/meson/pull/11456.

join_paths function now have a flavor keyword, to specify whether it joins posix or windows paths.

The default 'meson' flavor keeps compatibility with previous meson versions. 'posix' and 'windows' flavors handle paths as posix or windows paths. 'native' flavor uses 'posix' or 'windows' flavor depending on the host system.

join_paths function now have a mode keyword, to specify how it joins absolute paths.

In 'relative' mode (default), the last absolute component of the path becomes the path starting point.

In 'absolute' mode, each subsequent parts are joined as if they were relative to the preceding parts.

jpakkane commented 2 weeks ago

What is the specific use case for this? I.e. when would you need to explicitly join paths in the non-native way?

bruchar1 commented 2 weeks ago

You're right. The real problem with actual implementation I think is that backslashes should not be replaced on posix paths. I proposed a fix in #13172 . I will rework the actual PR to only keep the other feature (absolute path joining)

Akaricchi commented 1 week ago

What is the specific use case for this? I.e. when would you need to explicitly join paths in the non-native way?

When you're cross-compiling and need to embed a path into your program: https://github.com/taisei-project/taisei/blob/071d1163fdb136b35ff78a538842d8448e95cdaf/meson.build#L529

I don't remember the details, but I was frustrated enough with this to name the actual path conversion script unfuck-path.py.

eli-schwartz commented 1 week ago

I would blindly assume in that case you're usually cross compiling from Linux, to Windows. In which case Windows does accept the same forward slashes Linux does, when using the recommended Windows path handling APIs. I wish the world would just standardize on using those everywhere. :P

Akaricchi commented 1 week ago

I would blindly assume in that case you're usually cross compiling from Linux, to Windows

Usually that would be the case, but if we're striving for some semblance of correctness, then the reverse case must also be acknowledged.

In which case Windows does accept the same forward slashes Linux does, when using the recommended Windows path handling APIs

Yeah, when you're not using native NT paths or some other weird crap windows supports and nobody knows about