Meson: Support Windows builds

Add the necessary machinery into the Meson definition files so that we
can build for Windows.

Since we don't have Wayland or X support for our use case here, disable
them once we know that we are building for Windows, as they are
(otherwise) enabled by default, and enable the items that need to be
built for Windows builds.

Exclude gtk4-launch from Windows builds as that is something that
is not supported on Windows.

As we won't have gio-unix on Windows, and PangoFT2 is optional, don't use
fallbacks for them when we are on Windows (but do use fallbacks for
gio-win32, as it will be used).

Also, clean up meson.build a bit as we can just force-include
msvc_recommended_pragmas.h from GLib since we depend on GLib, and so we
can handle these warnings from msvc_recommended_pragmas.h instead.

https://bugzilla.gnome.org/show_bug.cgi?id=785210
This commit is contained in:
Chun-wei Fan 2017-08-01 16:49:08 +08:00
parent 73ef640736
commit 18abb78bfd
3 changed files with 56 additions and 34 deletions

View File

@ -121,6 +121,7 @@ gdkmarshal_h = gdk_marshalers[1]
gdkconfig_cdata = configuration_data()
gdkconfig_cdata.set('GDK_WINDOWING_X11', x11_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_WAYLAND', wayland_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_WIN32', win32_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_BROADWAY', broadway_enabled)
gdkconfig_cdata.set('GDK_WINDOWING_MIR', mir_enabled)
gdkconfig_cdata.set('GDK_RENDERING_VULKAN', have_vulkan)
@ -160,7 +161,7 @@ gdk_deps = [
gobject_dep,
epoxy_dep,
fontconfig_dep,
giounix_dep,
platform_gio_dep,
pangocairo_dep,
vulkan_lib
]

View File

@ -243,7 +243,6 @@ gtk_public_sources = files([
'gtkpopover.c',
'gtkpopovermenu.c',
'gtkprintcontext.c',
'gtkprintoperation-portal.c',
'gtkprintoperation.c',
'gtkprintoperationpreview.c',
'gtkprintsettings.c',
@ -812,10 +811,9 @@ gtk_sources += [
gtk_deps = [
gmodule_dep,
giounix_dep,
glib_dep,
gobject_dep,
atkbridge_dep,
platform_gio_dep,
pangocairo_dep,
pango_dep,
cairogobj_dep,
@ -840,6 +838,19 @@ if wayland_enabled
gtk_sources += gtk_wayland_sources
endif
if win32_enabled
gtk_cargs += ['-DGTK_PRINT_BACKENDS="file,lpr"']
gtk_deps += [ giowin32_dep ]
gtk_deps += [cc.find_library('advapi32'),
cc.find_library('comctl32'),
cc.find_library('dwmapi'),
cc.find_library('imm32'),
cc.find_library('setupapi'),
cc.find_library('winmm')]
else
gtk_deps += [ atkbridge_dep, ]
endif
# So we don't add these twice
if x11_enabled or wayland_enabled
gtk_sources += gtk_use_wayland_or_x11_c_sources
@ -1012,10 +1023,13 @@ gtk_tools = [
['gtk4-builder-tool', ['gtk-builder-tool.c']],
['gtk4-update-icon-cache', ['updateiconcache.c']],
['gtk4-encode-symbolic-svg', ['encodesymbolic.c']],
['gtk4-launch', ['gtk-launch.c']],
['gtk4-query-immodules', ['queryimmodules.c', 'gtkutils.c']],
]
if os_unix
gtk_tools += ['gtk4-launch', ['gtk-launch.c']]
endif
foreach tool: gtk_tools
tool_name = tool.get(0)
tool_srcs = tool.get(1)

View File

@ -104,8 +104,11 @@ os_darwin = false
if host_machine.system().contains('darwin')
os_darwin = true
elif host_machine.system().contains('mingw')
elif host_machine.system() == 'windows'
os_win32 = true
win32_enabled = true
x11_enabled = false
wayland_enabled = false
elif host_machine.system().contains('linux')
os_linux = true
endif
@ -208,25 +211,9 @@ endif
if cc.get_id() == 'msvc'
# Compiler options taken from msvc_recommended_pragmas.h
# in GLib, based on _Win32_Programming_ by Rector and Newcomer
test_cflags = [
'-we4002', # too many actual parameters for macro
'-we4003', # not enough actual parameters for macro
'-w14010', # single-line comment contains line-continuation character
'-we4013', # 'function' undefined; assuming extern returning int
'-w14016', # no function return type; using int as default
'-we4020', # too many actual parameters
'-we4021', # too few actual parameters
'-we4027', # function declared without formal parameter list
'-we4029', # declared formal parameter list different from definition
'-we4033', # 'function' must return a value
'-we4035', # 'function' : no return value
'-we4045', # array bounds overflow
'-we4047', # different levels of indirection
'-we4049', # terminating line number emission
'-we4053', # an expression of type void was used as an operand
'-we4071', # no function prototype given
'-we4819', # the file contains a character that cannot be represented in the current code page
]
test_cflags = []
add_project_arguments('-FImsvc_recommended_pragmas.h', language: 'c')
add_project_arguments('-D_USE_MATH_DEFINES', language: 'c')
elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
test_cflags = [
'-fno-strict-aliasing',
@ -317,17 +304,27 @@ glib_dep = dependency('glib-2.0', version: glib_req,
fallback : ['glib', 'libglib_dep'])
gobject_dep = dependency('gobject-2.0', version: glib_req,
fallback : ['glib', 'libgobject_dep'])
giounix_dep = dependency('gio-unix-2.0', version: glib_req, required: false,
if host_machine.system() == 'windows'
giowin32_dep = dependency('gio-windows-2.0', version: glib_req, required: win32_enabled,
fallback : ['glib', 'libgio_dep'])
else
giounix_dep = dependency('gio-unix-2.0', version: glib_req, required: false,
fallback : ['glib', 'libgio_dep'])
endif
gmodule_dep = dependency('gmodule-2.0', version: glib_req,
fallback : ['glib', 'libgmodule_dep'])
cairo_dep = dependency('cairo', version: cairo_req, required : cc.get_id() != 'msvc')
cairogobj_dep = dependency('cairo-gobject', version: cairo_req, required : cc.get_id() != 'msvc')
pango_dep = dependency('pango', version: pango_req,
fallback : ['pango', 'libpango_dep'])
pangoft_dep = dependency('pangoft2', required: wayland_enabled or x11_enabled,
fallback : ['pango', 'libpangoft2_dep'])
pangocairo_dep = dependency('pangocairo', version: pango_req,
if wayland_enabled or x11_enabled
pangoft_dep = dependency('pangoft2', fallback : ['pango', 'libpangoft2_dep'])
else
pangoft_dep = dependency('pangoft2', required: false)
endif
pangocairo_dep = dependency('pangocairo', version: cairo_req,
fallback : ['pango', 'libpangocairo_dep'])
pixbuf_dep = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
fallback : ['gdk-pixbuf', 'gdkpixbuf_dep'])
@ -335,13 +332,19 @@ epoxy_dep = dependency('epoxy', version: epoxy_req,
fallback: ['libepoxy', 'libepoxy_dep'])
atk_dep = dependency('atk', version: atk_req)
harfbuzz_dep = dependency('harfbuzz', version: '>= 0.9', required: false)
xkbdep = dependency('xkbcommon', version: xkbcommon_req)
xkbdep = dependency('xkbcommon', version: xkbcommon_req, required: wayland_enabled)
graphene_dep = dependency('graphene-gobject-1.0', version: graphene_req,
fallback: ['graphene', 'graphene_dep'])
fontconfig_dep = [] # only used in x11 backend
atkbridge_dep = [] # only used in x11 backend
if host_machine.system() == 'windows'
platform_gio_dep = giowin32_dep
else
platform_gio_dep = giounix_dep
endif
backend_immodules = []
pc_gdk_extra_libs = []
@ -529,9 +532,11 @@ if quartz_enabled
endif
if win32_enabled
pc_gdk_extra_libs += ['-lgdi32', '-limm32', '-lshell32', '-lole32',
'-Wl,-luuid', '-lwinmm', '-ldwmapi', '-lsetupapi',
'-lcfgmgr32']
pc_gdk_extra_libs += ['-lgdi32', '-limm32', '-lshell32', '-lole32']
if cc.get_id() != 'msvc'
pc_gdk_extra_libs += ['-Wl,-luuid']
endif
pc_gdk_extra_libs += ['-lwinmm', '-ldwmapi', '-lsetupapi', '-lcfgmgr32']
backend_immodules += ['ime']
endif
@ -543,7 +548,9 @@ if cc.has_function('bind_textdomain_codeset', dependencies: libintl_dep)
cdata.set('HAVE_BIND_TEXTDOMAIN_CODESET', 1)
endif
cdata.set('HAVE_GIO_UNIX', giounix_dep.found())
if host_machine.system() != 'windows'
cdata.set('HAVE_GIO_UNIX', giounix_dep.found())
endif
# Check for Vulkan support
# TODO: move to gsk subfolder maybe? Or will it be used elsewhere too?