Closed pepijndevos closed 3 years ago
FWIW the CI error on windows is
Failed to run `"pkg-config" "--libs" "--cflags" "glib-2.0" "glib-2.0 >= 2.44"`: The system cannot find the file specified. (os error 2)`
which is because there is no pkg-config on the path, and the gtk-rs sys crates use system_deps which only support pkg-config according to the docs. It's not clear to me how this used to work. Did the sys crates look at the LIB and GTK_LIB_DIR variables? Did vcpkg include pkg-config on the path? As far as I can tell there is no pkg-config package in vcpkg, it appears very much centred around Visual Studio and CMake.
So given that apparently the method with environment variables no longer works and pkg-config is not a thing in MSVC land, the GNU way seems more appealing for now. Just need to reverse-engineer those pesky launchers.
After a bit of prodding, this seems to do the trick:
msys2_shell.cmd -mingw64 -defterm -no-start -c "/c/Users/pepij/.cargo/bin/cargo"
Problem: this would require wrapping every single command in this mess.
It appears another way is to source the /etc/profile from a bash shell on windows. Currently this gets you the git for windows shell, but there is actually a PR to change it to the MSYS2 git shell: https://github.com/actions/virtual-environments/issues/1525
I'll probably hold off on this until that gets merged. This should make everything a lot easier. Just a single pacman command and the already existing cargo commands.
This actually gets you a working app. So now the challenge is getting this into CI. The good news is the
windows-latest
image includes MSYS2 already. The bad news is it doesn't allow installation caching.
You might want to have a look at https://github.com/msys2/setup-msys2#context
The most annoying part is figuring out how to enter the "MSYS2 MinGW 64-bit" universe without the GUI launcher.
Also https://github.com/msys2/setup-msys2#usage and https://github.com/msys2/setup-msys2#path-type.
Thanks @eine I managed to get it working :)
Currently the CI is failing on the windows build. This process is based on the no longer existing gtk-rs documentation: https://github.com/gtk-rs/gtk-rs.github.io/blob/0ae94ecbeaea692db8775229b06d66a7612b1653/docs-src/requirements.md
I'll document my progress and solicit input in this issue.
I am following the official GTK instructions which documents MSYS2, which installs a GNU toolchain, and suggests using gvsbuild if you want a MSVC toolchain. vcpkg isn't mentioned anywhere. I think gvsbuild builds GTK completely from source. I don't know if people have strong feelings over different Windows toolchains and package managers, but I'm inclined to follow the GTK documentation and use MSYS2.
After some initial confusion that is common when I touch Windows, it was actually quite easy.
Install MSYS2 and launch their "MSYS2 MSYS" terminal
Then I installed rust with
rustup-init.exe
as per https://forge.rust-lang.org/infra/other-installation-methods.html#other-ways-to-install-rustup I did not pay attention and ended up with a MSVC. So had to do tell rustup to install the GNU one.Now the confusing bit is that cargo lives is in the Windows universe, but GTK lives in the MSYS2 universe. To get access to the mingw toolchain you need to run the "MSYS2 MinGW 64-bit" app. From there you need to break out to the Windows world and run cargo.
This actually gets you a working app. So now the challenge is getting this into CI. The good news is the
windows-latest
image includes MSYS2 already. The bad news is it doesn't allow installation caching. The most annoying part is figuring out how to enter the "MSYS2 MinGW 64-bit" universe without the GUI launcher.I found on StackOverflow you can call their bash binary like
\msys64\usr\bin\bash -l -c "pwd"
but that seems to get you into the MSYS2 universe, which is different from the MinGW universe. This will probably involve reveres-engineering the GUI launcher, which is a struggle for another day.