After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 785210 - meson: Support build on Windows (using Visual Studio at least)
meson: Support build on Windows (using Visual Studio at least)
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: .General
3.91.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2017-07-21 07:34 UTC by Fan, Chun-wei
Modified: 2018-05-02 18:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Meson: Support builds on Windows/MSVC (11.12 KB, patch)
2017-07-21 07:52 UTC, Fan, Chun-wei
none Details | Review
gdk/gdkconfig.h.meson: Add configuration variable for Windows (845 bytes, patch)
2017-08-01 09:11 UTC, Fan, Chun-wei
committed Details | Review
gtk/gentypefuncs.py: Open files with UTF-8 encoding on Python 3.x (1.37 KB, patch)
2017-08-01 09:14 UTC, Fan, Chun-wei
committed Details | Review
meson: Support Windows builds (Visual Studio at least) (6.63 KB, patch)
2017-08-01 09:23 UTC, Fan, Chun-wei
none Details | Review
testsuite/gtk/builder.c: Fix test on Visual Studio builds (3.33 KB, patch)
2017-08-01 09:27 UTC, Fan, Chun-wei
committed Details | Review
meson: Build the .rc files on Windows (3.78 KB, patch)
2017-08-07 11:19 UTC, Fan, Chun-wei
accepted-commit_now Details | Review
meson: Fix build when including immodules into the main GTK+ .dll/.so (1.65 KB, patch)
2017-08-11 09:01 UTC, Fan, Chun-wei
none Details | Review
meson: Fix the Vulkan library name on Visual Studio builds (1.61 KB, patch)
2017-08-11 09:12 UTC, Fan, Chun-wei
none Details | Review
meson: Fix Vulkan shader compilation (5.23 KB, patch)
2017-08-11 09:18 UTC, Fan, Chun-wei
none Details | Review
build: Add fallback dependency discovery for Visual Studio build on Meson (4.67 KB, patch)
2017-08-22 08:57 UTC, Fan, Chun-wei
none Details | Review
meson: Fix the Vulkan library name on Visual Studio builds (take ii) (1.78 KB, patch)
2017-08-22 09:04 UTC, Fan, Chun-wei
none Details | Review
meson: Support Windows builds (Visual Studio at least) (take ii) (8.74 KB, patch)
2017-09-12 05:44 UTC, Fan, Chun-wei
needs-work Details | Review
meson: Fix the Vulkan library name on Visual Studio builds (take iii) (1.74 KB, patch)
2017-09-12 05:45 UTC, Fan, Chun-wei
committed Details | Review
build: Correct PangoCairo required version (989 bytes, patch)
2017-09-12 05:46 UTC, Fan, Chun-wei
committed Details | Review
build: Add fallback dependency discovery for Visual Studio build on Meson (take ii) (4.32 KB, patch)
2017-09-12 05:49 UTC, Fan, Chun-wei
committed Details | Review
meson: Support Windows builds (Visual Studio at least) (take iii) (8.96 KB, patch)
2017-09-15 14:05 UTC, Fan, Chun-wei
committed Details | Review

Description Fan, Chun-wei 2017-07-21 07:34:10 UTC
Hi,

We have some Meson build files that are now usable for building GTK+, but at the moment they only support builds on and for *NIX.  This patch series, along with the patches to the sources in bug 773299, attempts to make GTK+-3.9x/4.x buildable and running on Windows.

I will attach patches shortly to update the Meson build files to include such support.

With blessings, thank you!
Comment 1 Fan, Chun-wei 2017-07-21 07:52:16 UTC
Created attachment 356086 [details] [review]
Meson: Support builds on Windows/MSVC

Hi,

This is the patch to support builds of GTK+-3.9x/4.x on Windows using Visual Studio at least.  Please see the commit comment for what is covered by the patch.

Note that for building introspection files (i.e. Gtk-4.0.gir), this will fail on any Windows builds done on Windows because the command line for g-ir-scanner is too long (Windows has a limit of 8192 characters for each command line).  To fix this, we will need to make Meson generate a filelist of the files that we want the introspection scanner to scan, and use the --filelist option for g-ir-scanner in order for the introspection build to complete successfully, but this is not covered here as this is something that needs to be fixed/updated in Meson, IMO.

With the patches that I will post in 773299, I was able to build the latest git master using Visual Studio 2015, at least.

With blessings, thank you!
Comment 2 Fan, Chun-wei 2017-08-01 09:11:38 UTC
Created attachment 356697 [details] [review]
gdk/gdkconfig.h.meson: Add configuration variable for Windows

Hi,

I decided to split up the patch to support Meson builds on Windows...

First up is the patch to put GDK_WINDOWING_WIN32 in gdk/gdkconfig.h.meson that can be activated once we know we are building for Windows...
Comment 3 Fan, Chun-wei 2017-08-01 09:14:56 UTC
Created attachment 356699 [details] [review]
gtk/gentypefuncs.py: Open files with UTF-8 encoding on Python 3.x

Hi,

I am not sure whether this script will be called by Python 2.x, but in case it does...

This makes the script open files in utf-8 encoding, as contents in the files opened may not be supported on the Windows system locale (such as in the case of non-English Windows), on Python 3.x.

On Python 2.x, since encodings are not supported, open it as we did before...
Comment 4 Fan, Chun-wei 2017-08-01 09:23:38 UTC
Created attachment 356702 [details] [review]
meson: Support Windows builds (Visual Studio at least)

Hi,

This adds the items that we need to support native Windows builds, where:

-We disable X11/Wayland support (which is on by default) once we know
 we are building for Windows, and instead activate the Windows-related
 items.

-Don't build *NIX-only items in gtk/, and don't use *NIX dependencies.

-Use GLib's msvc_recommended_pragmas.h, to clean up things a bit...

Note that further patches are needed to build the IME support (for CJK Windows) and to link in the resource (.rc) file for Windows builds, as well as embedding the libgtk4.manifest file for obtaining a better-looking print dialog on Windows.

Note also that a PR has been opened in Meson [1] to use filelists for g-ir-scanner, as that is needed to build introspection files successfully on Windows, otherwise the command line expands beyond 8192 characters, breaking the introspection builds.

With blessings, thank you!

[1]: https://github.com/mesonbuild/meson/pull/2125
Comment 5 Fan, Chun-wei 2017-08-01 09:27:50 UTC
Created attachment 356703 [details] [review]
testsuite/gtk/builder.c: Fix test on Visual Studio builds

Hi,

For the builder test, we need to decorate the symbols that we need to export using __declspec(dllexport) as Visual Studio does not support things like -Wl,export-dynamic, so we only pass in that flag when not building on Visual Studio, and use a macro that is defined as __declspec(dllexport) on Visual Studio builds instead.

With blessings, thank you!
Comment 6 Fan, Chun-wei 2017-08-07 11:19:54 UTC
Created attachment 357100 [details] [review]
meson: Build the .rc files on Windows

Hi,

This builds the .rc file on Windows, so that:

-One can keep track of the version info of the DLL more easily.
-Have a default icon for GTK+ apps
-Make the Windows print dialog themed[1]

[1]: We move the manifest embedding that is required for this back into the .rc file since this is supported in the Visual Studio versions that we care about in GTK+-4, to make maintenance easier on ourside.

With blessings, thank you!
Comment 7 Fan, Chun-wei 2017-08-11 09:01:17 UTC
Created attachment 357397 [details] [review]
meson: Fix build when including immodules into the main GTK+ .dll/.so

Hi,

The option to include the immodules during the Meson build process is not done completely, (as it is an option that is actually done in the Visual Studio projects) as we need to do the following as well:

-Make sure that each immodule source that we are building into the main GTK+
 DLL/.so is built with the corresponding INCLUDE_IM_xxx macro defined
-Make sure the GTK+ source (gtkimmodule.c specifically) is built with all the
 -DINCLUDE_IM_xxx macros that we are enabling as a result.

Not doing the first will cause the GTK+ DLL/.so to fail to link, and not doing the second will cause GTK+ not to load the immodules that are built in.

With blessings, thank you!
Comment 8 Fan, Chun-wei 2017-08-11 09:12:21 UTC
Created attachment 357399 [details] [review]
meson: Fix the Vulkan library name on Visual Studio builds

Hi,

For detecting a LunarG Vulkan SDK installation on Visual Studio, we need to look for vulkan-1.lib, not vulkan.lib, so update the library name in the Meson build files accordingly.

Note that I am not sure whether the LunarG SDK will work for MinGW/mingw-w64 builds as only the Visual Studio-style .lib files are provided with the SDK.

With blessings, thank you!
Comment 9 Fan, Chun-wei 2017-08-11 09:18:12 UTC
Created attachment 357400 [details] [review]
meson: Fix Vulkan shader compilation

Hi,

Meson does not like path separators in its output files, which will cause configuration to fail when Vulkan is enabled and when glslc is found and to be used.

Fix this by getting the glslc bits into gsk/resources/vulkan, and including it in gsk/meson.build.

With blessings, thank you!
Comment 10 Fan, Chun-wei 2017-08-22 06:40:48 UTC
Comment on attachment 357400 [details] [review]
meson: Fix Vulkan shader compilation

Hi,

For records, this issue has been fixed upstream in 4904491.

With blessings, thank you!
Comment 11 Fan, Chun-wei 2017-08-22 08:57:55 UTC
Created attachment 358113 [details] [review]
build: Add fallback dependency discovery for Visual Studio build on Meson

Hi,

As in the other parts of the stack, we still face a problem where pkg-config files are not generated for some of the dependencies that we need in their Visual Studio build files.  As a result, we need to add a fallback mechanism on Visual Studio builds to find the dependencies manually using cc.hsa_header() and cc.find_library() when the respective pkg-config files cannot be found.

Note that for the GNOME items, libepoxy and Graphene, since we are building via Meson (or in the case of Visual Studio projects, the pkg-config files *are* generated), this does not attempt to cover these dependencies.

This will cover the case for HarfBuzz and Cairo.

With blessings, thank you!
Comment 12 Fan, Chun-wei 2017-08-22 09:04:20 UTC
Created attachment 358115 [details] [review]
meson: Fix the Vulkan library name on Visual Studio builds (take ii)

Hi,

I am re-uploading this patch as the correct Vulkan library name needs to be in the pkg-config files as well.

With blessings, thank you!
Comment 13 Fan, Chun-wei 2017-09-04 04:05:25 UTC
Hi,

For records...

(In reply to Fan, Chun-wei from comment #4)
> 
> Note also that a PR has been opened in Meson [1] to use filelists for
> g-ir-scanner, ...
> 
> [1]: https://github.com/mesonbuild/meson/pull/2125

The PR for Meson has been merged upstream, so the next release (or latest master checkout) of Meson will enable one to build the introspection files for GTK+ master on Windows.

With blessings, and cheers!
Comment 14 Fan, Chun-wei 2017-09-12 05:44:06 UTC
Created attachment 359573 [details] [review]
meson: Support Windows builds (Visual Studio at least) (take ii)

Hi,

I am re-uploading this patch as it has to be rebased, and we don't want to use the fallbacks on non-X11/non-Wayland for PangoFT2 (optional) and for gio-unix (not available on Windows; which is replaced with gio-win32 here).

With blessings, thank you!
Comment 15 Fan, Chun-wei 2017-09-12 05:45:03 UTC
Created attachment 359574 [details] [review]
meson: Fix the Vulkan library name on Visual Studio builds (take iii)

Hi,

I am re-uploading this patch as it has to be rebased.

With blessings, thank you!
Comment 16 Fan, Chun-wei 2017-09-12 05:46:06 UTC
Created attachment 359576 [details] [review]
build: Correct PangoCairo required version

Hi,

There is a typo in the version required for PangoCairo, so this corrects this to be the same with Pango.

With blessings, thank you!
Comment 17 Fan, Chun-wei 2017-09-12 05:49:38 UTC
Created attachment 359578 [details] [review]
build: Add fallback dependency discovery for Visual Studio build on Meson (take ii)

Hi,

This patch is re-uploaded as it has to be rebased.

With blessings, thank you!

The patches need to go in this order (at least the first 3):
356697
356699
359573
357100
357397
359574
359576
<this patch here in this comment>
356703

With blessings, thank you!
Comment 18 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:24:05 UTC
Review of attachment 356697 [details] [review]:

Sure
Comment 19 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:25:16 UTC
Review of attachment 356699 [details] [review]:

Looks good
Comment 20 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:27:13 UTC
Review of attachment 356703 [details] [review]:

Fine for me
Comment 21 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:28:11 UTC
Review of attachment 357100 [details] [review]:

Sure
Comment 22 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:34:31 UTC
Review of attachment 359573 [details] [review]:

See the comments inline

::: gtk/meson.build
@@ -242,3 @@
   'gtkpopovermenu.c',
   'gtkprintcontext.c',
-  'gtkprintoperation-portal.c',

what about this file? where does it go?

::: meson.build
@@ +343,3 @@
 
+if host_machine.system() == 'windows'
+  libgio_dep = giowin32_dep

I don't like this name much, it feels to me like we are talking about gio while it is the platform specific gio dep. Let's call it platform_gio_dep?
Comment 23 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:35:12 UTC
Review of attachment 359574 [details] [review]:

Looks good
Comment 24 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:36:14 UTC
Review of attachment 359576 [details] [review]:

Looks good
Comment 25 Ignacio Casal Quinteiro (nacho) 2017-09-15 11:38:53 UTC
Review of attachment 359578 [details] [review]:

Looks good
Comment 26 Fan, Chun-wei 2017-09-15 13:55:29 UTC
Review of attachment 356697 [details] [review]:

Hi Nacho,

Thanks, I pushed this patch as e5a1de1.

With blessings, thank you!
Comment 27 Fan, Chun-wei 2017-09-15 13:56:20 UTC
Review of attachment 356699 [details] [review]:

Hi Nacho,

Thanks, I pushed the patch as 0332dbc.

With blessings, thank you!
Comment 28 Fan, Chun-wei 2017-09-15 13:57:00 UTC
Review of attachment 356703 [details] [review]:

Hi Nacho,

Thanks, I pushed this patch as 60297b9.

With blessings, thank you!
Comment 29 Fan, Chun-wei 2017-09-15 14:00:54 UTC
Hi Nacho,

Thanks, I pushed the following patches as follows:
-Attachment 359574 [details]: 0b783f6
-Attachment 359576 [details]: fc5f391 (had to rebase this a bit, since 359573 needs to be updated)
-Attachment 359578 [details]: 84ff9e9 (had to rebase this a bit, since 359573 needs to be updated)

With blessings, thank you!
Comment 30 Fan, Chun-wei 2017-09-15 14:05:46 UTC
Created attachment 359850 [details] [review]
meson: Support Windows builds (Visual Studio at least) (take iii)

Hi Nacho,

Here's the new patch on supporting building GTK+ master via Meson using Visual Studio with the suggestions.  I am deferring pushing attachment 357100 [details] [review] until after this gets in.

(In reply to Ignacio Casal Quinteiro (nacho) from comment #22)
> -  'gtkprintoperation-portal.c',

Well, this file is actually duplicated, in a "if os_unix" block starting at circa line 596, so it is just removed here.

With blessings, thank you!
Comment 31 Jaime Velasco 2017-09-16 09:34:49 UTC
Review of attachment 357100 [details] [review]:

::: gtk/gtk-win32.rc.body.in
@@ +21,3 @@
 	VALUE "FileVersion", "@GTK_VERSION@.0"
 	VALUE "InternalName", "libgtk-win32-@GTK_API_VERSION@-@LT_CURRENT_MINUS_AGE@"
+	VALUE "LegalCopyright", "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald. Modified by the GTK+ Team and others 1997-2011."

Here you can encode the copyright sign as \xa9.
I think InternalName and OriginalFilename should be fixed as the name of the binary will be libgtk-4-0.xxxx.0, not libgtk-win32-xx-xx.
Comment 32 Ignacio Casal Quinteiro (nacho) 2017-10-20 08:53:17 UTC
Review of attachment 359850 [details] [review]:

Looks good to me
Comment 33 Fan, Chun-wei 2017-10-24 17:08:41 UTC
Review of attachment 359850 [details] [review]:

Hi Nacho,

Thanks for reviewing this.   Sorry, I forgot to write back here after pushing the patch, which was pushed as 18abb78.

With blessings, thank you!
Comment 34 GNOME Infrastructure Team 2018-05-02 18:45:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gtk/issues/859.