MINGW-packages icon indicating copy to clipboard operation
MINGW-packages copied to clipboard

Linux based Docker image for cross-compilation in CI (non-GitHub)

Open AvtechScientific opened this issue 2 years ago • 11 comments

It would be nice if you could create a Linux based docker image that contains MSYS2 and could be used in CI other than GitHub. For example in GitLab, etc.. It would be a more generic approach. You might derive it from Debian, Fedora or Arch Linux (that has the same package manager as MSYS2). It could be used without requiring a Windows virtual machine. Here is an example on how a Fedora docker image is used to cross-compile a GTK application for Windows (without requiring Windows).

https://github.com/manisandro/gImageReader/blob/master/.github/workflows/build.yml

Maybe you can use Wine or add packages like it was done in the above mentioned Fedora based approach.

Thank you very much!

PS: maybe it is possible already to use MSYS2 in GitLab CI without requiring Windows but I miss it?

AvtechScientific avatar Jun 22 '22 11:06 AvtechScientific

I would like to help to cross-compile this application:

https://gitlab.gnome.org/GNOME/gnome-text-editor

It doesn't seem to be hosted on regular GitLab... it looks more like Gnome's own instance... So I'm not sure they offer Windows image... Or am I wrong?

Also - do you have an example of GitLab CI that uses MSYS2?

Thank you!

AvtechScientific avatar Jun 22 '22 12:06 AvtechScientific

For general CI guidelines, this can be followed https://www.msys2.org/docs/ci/. Some projects use msys2/mingw in CI. e.g. gstreamer, pango, fontconfig, inkscape etc.

Biswa96 avatar Jun 22 '22 13:06 Biswa96

@Biswa96 - thank you, for this info. I saw that page however it seems that all written there is Windows based, which makes MSYS2 less generally applicable as if it were based on Linux image.

AvtechScientific avatar Jun 22 '22 14:06 AvtechScientific

Yes, msys2 is windows based. There are attempts to run msys2 in wine but I don't know if those are fully in usable state. AFAIK, the GitLab CI uses Windows in those repositories.

Biswa96 avatar Jun 22 '22 14:06 Biswa96

However MinGW can run on Linux even without Wine. The only problem with that approach is that MinGW in Fedora is updated much less often than MSYS2 and lacks many packages. But the principle of Linux-based docker image with MinGW works very well.

AvtechScientific avatar Jun 22 '22 14:06 AvtechScientific

MSYS2 is based on Cygwin which doesn't work under Wine: https://github.com/msys2/MSYS2-packages/issues/682

However MinGW can run on Linux even without Wine.

No, what you have linked is a native Linux cross compiler targeting MinGW.

mati865 avatar Jun 22 '22 14:06 mati865

Here's my current ongoing attempt at this https://gist.github.com/1480c1/9340585a2f8096f3b9ea992d147f3cc2.

It sorta works, sorta doesn't

One issue was solved in https://github.com/git-for-windows/git/pull/3875, but there are a few others mentioned in https://github.com/git-for-windows/git/issues/3881

But most of the issue stems from bash from cygwin not really working well

1480c1 avatar Jun 22 '22 22:06 1480c1

@1480c1 - great work! But I see it will not be easy to make Wine and MSYS2 work inside container... Do you think it will be possible to make a native Linux cross compiler targeting MinGW as I have mentioned above, but based on the Arch docker image instead of Fedora? Is it a route that will provide more stable results eventually?

AvtechScientific avatar Jun 23 '22 09:06 AvtechScientific

Do you think it will be possible to make a native Linux cross compiler targeting MinGW as I have mentioned above, but based on the Arch docker image instead of Fedora?

Of course, there is mingw-w64-gcc available in Arch Linux repo. You will have to build additional libraries from AUR though.

mati865 avatar Jun 23 '22 14:06 mati865

You will have to build additional libraries from AUR though.

There are unofficial repositories like this one https://github.com/Martchus/PKGBUILDs/. With that, one does not have to cross compile mingw-w64 packages in ArchLinux. Just add the repository link in pacman.conf and install the packages.

Biswa96 avatar Jun 23 '22 15:06 Biswa96

Interesting! But I specifically need gtk4, libadwaita and gtksourceview5 which are not in that repository. And I didn't find them anywhere except for MSYS2. It seems to be much better supported then any other cross-compile project (including Fedora).

AvtechScientific avatar Jun 23 '22 15:06 AvtechScientific