Skip to content

Conversation

@na-trium-144
Copy link
Contributor

@na-trium-144 na-trium-144 commented Nov 17, 2024

closes #13699

On Windows, the windows-style configure command path (like C:/path/to/configure) seems to break many configure scripts because they treat the colon in the drive letter as path separator.
Converting the configure command to unix-style path (like /c/path/to/configure) using cygpath command fixes the issue.
cygpath should be available on cygwin, msys2 and gitbash.

Edit: This conversion is done only if cygpath command is available. Otherwise it is left as is.

Edit: this PR also includes fix for enabling test cases/common/230 external project on msys2. (related to #13895)
To enable this, I had to add windows and !windows as platform value in test configuration.

Edit: Also includes fix for a bug where the leading / in the prefix is missing on MinGW, which appears to be introduced in #13886.

Edit: It turned out that with the previous approach which just removes the drive letter from prefix the generated pkg-config file has wrong prefix in it.
So this PR also convert the prefix to unix-style path when cygpath is available.

I'm new to contributing to meson. Please let me know if there are something I need to change.

@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch 2 times, most recently from fdc35d9 to 20a9be7 Compare November 17, 2024 17:39
@eli-schwartz
Copy link
Member

cygpath should be available on cygwin, msys2 and gitbash.

How do we know that all scripts for configuring an external project via --prefix etc. are necessarily running from cygwin? In comparison, we have existing functions for determining if meson is being run from a cygwin or msys2 environment.

I suppose that it may be fairly rare for homebrewed build systems to exist and actual autoconf scripts won't run without some runtime environment similar to cygwin / msys2. How does a bare mingw install handle this?

@na-trium-144
Copy link
Contributor Author

na-trium-144 commented Nov 17, 2024

It does not necessarily need to be running on cygwin, as long as there is sh and cygpath. msys2 and gitbash also provides cygpath (in spite of its name).

Initially I didn't think about other environment that provide sh command without cygpath command on Windows.
However now I searched a little and found at least two: BusyBox and UnxUtils.
Although I have not tested whether these can run autoconf scripts, it seems both of these have sh and do not have cygpath, and both of these uses windows style path.

So if we need to support such environments, maybe the path conversion should be done only when cygpath exists?
Then this PR would at least fix the behavior on cygwin, msys2, and gitbash, while keeping the behavior in other environment as-is, I think.

Edit: I've updated the code for this.
(But then it may fail when there are multiple sh environment installed and pick wrong cygpath. Should I care about such edge cases?)

@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch from 482c609 to 699562d Compare November 19, 2024 13:55
@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch 2 times, most recently from bd1f2ea to 2675d06 Compare November 20, 2024 13:25
@na-trium-144 na-trium-144 marked this pull request as draft November 20, 2024 13:25
@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch from 2675d06 to d413795 Compare November 20, 2024 14:30
@na-trium-144 na-trium-144 marked this pull request as ready for review November 20, 2024 16:01
@na-trium-144
Copy link
Contributor Author

I've pushed some additional fixes (see edited description), and now CI passed.
Could someone review this please?
maybe @eli-schwartz ?

Copy link
Member

@eli-schwartz eli-schwartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these commits are missing explanations for why they are needed.

Using "added" for some commits and "fix" for others is inconsistent style ;) consistency would be "add / fix" or "added / fixed". Git style is to use imperative mood: https://cbea.ms/git-commit/#imperative

@na-trium-144

This comment was marked as resolved.

@na-trium-144 na-trium-144 marked this pull request as draft November 21, 2024 15:40
@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch 2 times, most recently from c579566 to e5eeb77 Compare November 23, 2024 14:52
@na-trium-144 na-trium-144 marked this pull request as ready for review November 23, 2024 16:35
@na-trium-144
Copy link
Contributor Author

@eli-schwartz Thanks for review! I fixed them all, so please check it again.

@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch from e5eeb77 to 1f89511 Compare December 16, 2024 18:19
@bonzini bonzini added this to the 1.8 milestone Jan 30, 2025
@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch 3 times, most recently from 41d56e3 to 6e61077 Compare February 3, 2025 06:41
Copy link
Member

@bruchar1 bruchar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. I think the 3 last commits could be squashed in one.

@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch from 6e61077 to cdbe956 Compare February 5, 2025 16:58
@eli-schwartz
Copy link
Member

I object to using ctypes at all. :) It's fragile and not meaningfully faster than running a single external command right before running a configure script.

Additionally we currently use ctypes only twice, and both times are guarded by Windows conditionals to avoid meson being broken and failing to run on Unix systems where python was manually compiled and ctypes isn't available. This isn't an uncommon occurrence. So please keep that in mind one way or the other.

@moi15moi
Copy link

moi15moi commented Jul 4, 2025

In this case, is there anything else to be done?

moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Jul 10, 2025
@jpakkane
Copy link
Member

This could use a release note snippet explaining how and when the path conversion happens.

@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch from ff17017 to 9c4843e Compare July 31, 2025 07:10
@bonzini bonzini modified the milestones: 1.9, 1.10, 1.9.1 Aug 20, 2025
@moi15moi
Copy link

Is there any reason why this is delayed to 1.9.1 or 1.10.0?
If there is anything that needs to be done, I can help na-trium-144.

@bonzini
Copy link
Collaborator

bonzini commented Aug 22, 2025

I don't know why it wasn't reviewed so far, but after 1.9-rc3 only a really bad regression would warrant another release candidate.

@bonzini
Copy link
Collaborator

bonzini commented Aug 26, 2025

@na-trium-144 can you rebase and push?

On Cygwin, MSYS2 and GitBash, the configure command and the prefix
should be converted to unix style path by cygpath command,
because the colon in the drive letter breaks many configure scripts.

This also fixes bugs of previous approach where leading slash was
missing from prefix and it sometimes use wrong directory as base path.
In addition removing drive letter should be done on rel_prefix only.
Implemented 'windows' and '!windows' as platform value in test
configuration for this.
In MSVC environment this test is ignored anyway since make command is
not available.
@na-trium-144 na-trium-144 force-pushed the configure_path_windows branch from 9c4843e to 83aad41 Compare August 26, 2025 09:45
@bonzini bonzini modified the milestones: 1.9.1, 1.9.2 Sep 14, 2025
moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Oct 21, 2025
…project module with ffms2

gstreamer ffmpeg isn't always up to date. For example, ffmpeg 8.0 have been released 2025-08-22, but as of 2025-10-20, gstreamer still only use the version 7.1.
Also, I don't like the fact that gstreamer doesn't use the official build system. There might be difference, so let's not take any chance and use the official build system.

I wanted to use the ffmpeg build system with meson External Project module https://mesonbuild.com/External-Project-module.html, but it just doesn't work. It seems that subproject (in this case bestsource) can't depend on a external project module because they don't use -uninstalled.pc, but i'm not sure.
Also, the external project module doesn't use the .pc file to retrieve the dependencies, so I need to maintain it manually which sucks: mesonbuild/meson#14767
Finally, the external project module doesn't work on msys2. There is a PR that have been opened almost a year ago and work fine, but for a reason, it's not getting merge: mesonbuild/meson#13916

So, for all these reason, let's directly use autotools for ffms2 and the official ffmpeg build system by building them "manually".
moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Oct 25, 2025
…project module with ffms2

gstreamer ffmpeg isn't always up to date. For example, ffmpeg 8.0 have been released 2025-08-22, but as of 2025-10-20, gstreamer still only use the version 7.1.
Also, I don't like the fact that gstreamer doesn't use the official build system. There might be difference, so let's not take any chance and use the official build system.

I wanted to use the ffmpeg build system with meson External Project module https://mesonbuild.com/External-Project-module.html, but it just doesn't work. It seems that subproject (in this case bestsource) can't depend on a external project module because they don't use -uninstalled.pc, but i'm not sure.
Also, the external project module doesn't use the .pc file to retrieve the dependencies, so I need to maintain it manually which sucks: mesonbuild/meson#14767
Finally, the external project module doesn't work on msys2. There is a PR that have been opened almost a year ago and work fine, but for a reason, it's not getting merge: mesonbuild/meson#13916

So, for all these reason, let's directly use autotools for ffms2 and the official ffmpeg build system by building them "manually".
moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Oct 25, 2025
…project module with ffms2

gstreamer ffmpeg isn't always up to date. For example, ffmpeg 8.0 have been released 2025-08-22, but as of 2025-10-20, gstreamer still only use the version 7.1.
Also, I don't like the fact that gstreamer doesn't use the official build system. There might be difference, so let's not take any chance and use the official build system.

I wanted to use the ffmpeg build system with meson External Project module https://mesonbuild.com/External-Project-module.html, but it just doesn't work. It seems that subproject (in this case bestsource) can't depend on a external project module because they don't use -uninstalled.pc, but i'm not sure.
Also, the external project module doesn't use the .pc file to retrieve the dependencies, so I need to maintain it manually which sucks: mesonbuild/meson#14767
Finally, the external project module doesn't work on msys2. There is a PR that have been opened almost a year ago and work fine, but for a reason, it's not getting merge: mesonbuild/meson#13916

So, for all these reason, let's directly use autotools for ffms2 and the official ffmpeg build system by building them "manually".
moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Oct 26, 2025
…project module with ffms2

gstreamer ffmpeg isn't always up to date. For example, ffmpeg 8.0 have been released 2025-08-22, but as of 2025-10-20, gstreamer still only use the version 7.1.
Also, I don't like the fact that gstreamer doesn't use the official build system. There might be difference, so let's not take any chance and use the official build system.

I wanted to use the ffmpeg build system with meson External Project module https://mesonbuild.com/External-Project-module.html, but it just doesn't work. It seems that subproject (in this case bestsource) can't depend on a external project module because they don't use -uninstalled.pc, but i'm not sure.
Also, the external project module doesn't use the .pc file to retrieve the dependencies, so I need to maintain it manually which sucks: mesonbuild/meson#14767
Finally, the external project module doesn't work on msys2. There is a PR that have been opened almost a year ago and work fine, but for a reason, it's not getting merge: mesonbuild/meson#13916

So, for all these reason, let's directly use autotools for ffms2 and the official ffmpeg build system by building them "manually".
moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Oct 26, 2025
…project module with ffms2

gstreamer ffmpeg isn't always up to date. For example, ffmpeg 8.0 have been released 2025-08-22, but as of 2025-10-20, gstreamer still only use the version 7.1.
Also, I don't like the fact that gstreamer doesn't use the official build system. There might be difference, so let's not take any chance and use the official build system.

I wanted to use the ffmpeg build system with meson External Project module https://mesonbuild.com/External-Project-module.html, but it just doesn't work. It seems that subproject (in this case bestsource) can't depend on a external project module because they don't use -uninstalled.pc, but i'm not sure.
Also, the external project module doesn't use the .pc file to retrieve the dependencies, so I need to maintain it manually which sucks: mesonbuild/meson#14767
Finally, the external project module doesn't work on msys2. There is a PR that have been opened almost a year ago and work fine, but for a reason, it's not getting merge: mesonbuild/meson#13916

So, for all these reason, let's directly use autotools for ffms2 and the official ffmpeg build system by building them "manually".
moi15moi added a commit to moi15moi/VideoTimestamps that referenced this pull request Oct 26, 2025
…project module with ffms2

gstreamer ffmpeg isn't always up to date. For example, ffmpeg 8.0 have been released 2025-08-22, but as of 2025-10-20, gstreamer still only use the version 7.1.
Also, I don't like the fact that gstreamer doesn't use the official build system. There might be difference, so let's not take any chance and use the official build system.

I wanted to use the ffmpeg build system with meson External Project module https://mesonbuild.com/External-Project-module.html, but it just doesn't work. It seems that subproject (in this case bestsource) can't depend on a external project module because they don't use -uninstalled.pc, but i'm not sure.
Also, the external project module doesn't use the .pc file to retrieve the dependencies, so I need to maintain it manually which sucks: mesonbuild/meson#14767
Finally, the external project module doesn't work on msys2. There is a PR that have been opened almost a year ago and work fine, but for a reason, it's not getting merge: mesonbuild/meson#13916

So, for all these reason, let's directly use autotools for ffms2 and the official ffmpeg build system by building them "manually".
# Work around that issue by removing the drive from prefix.
if self.prefix.drive:
self.prefix = Path(relpath(self.prefix, self.prefix.drive))
self.prefix = self._cygpath_convert(self.prefix)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case cygpath is not found we don't remove the drive from self.prefix anymore. That means we now run configure --prefix=c:/foo instead of configure --prefix=/foo. Is that intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if you also need to convert self.install_dir as that's used for DESTDIR?

Copy link
Contributor Author

@na-trium-144 na-trium-144 Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means we now run configure --prefix=c:/foo instead of configure --prefix=/foo.

I don't know which is appropriate in that case, but the latter has the problem of not working with another drive. If anyone has an environment with sh but no cygpath, they may submit an issue or PR.

I'm wondering if you also need to convert self.install_dir as that's used for DESTDIR?

Unlike the prefix used by configure, DESTDIR is used by make, right? So far I haven't had any issues with the drive letter for install_dir.

configure_prog = state.find_program(configure_path.as_posix())
configure_cmd = configure_prog.get_command()
if len(configure_cmd) >= 2 and configure_cmd[-1] == configure_path.as_posix():
configure_cmd = configure_cmd[:-1] + [self._cygpath_convert(configure_path).as_posix()]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? run_command('configure') would not do this and I assume it's working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main point of this PR. see #13699.

echo "failed to extract $srcdir using path separator $PATH_SEPARATOR"
exit 1
fi
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this is doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a test for the fix related to the comment above.
I wrote it to resemble the processing done by the existing configure script, but it might be the same if I simply checked whether srcdir contains a colon.

@bonzini bonzini modified the milestones: 1.9.2, 1.11 Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug OS:windows Winodows OS specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External Project module executes configure script via absolute windows-style path on MinGW, but it should be unix-style

7 participants