From ed65ab1ba9d2911ae86f668c765c7adda8cd5167 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 7 Aug 2017 19:10:18 +0800 Subject: [PATCH 1/3] meson: Build .rc files for Windows Build the .rc files for Windows so that one can track the version info more easily for Windows, as well as giving GTK+ apps a default icon. Also, move back the manifest embedding for the themed Windows print dialog back into gtk-win32.rc.body.in, so that we just have one way of embedding this manifest file, making things easier for ourselves, as this is supported in the later Visual Studio compilers as well, which is 2013 and later. --- gdk/meson.build | 1 + gtk/gtk-win32.rc.body.in | 9 ++++++--- gtk/meson.build | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/gdk/meson.build b/gdk/meson.build index d68307392b..2ed2585f0f 100644 --- a/gdk/meson.build +++ b/gdk/meson.build @@ -160,6 +160,7 @@ gdkx11_inc = include_directories('x11') gdkwayland_inc = include_directories('wayland') wlinc = include_directories('.') +win32rcinc = include_directories('win32/rc') gdk_gen_headers = [gdkenum_h, gdkmarshal_h, gdkconfig, gdkversionmacros] diff --git a/gtk/gtk-win32.rc.body.in b/gtk/gtk-win32.rc.body.in index 251128fe48..b876a6ddf5 100644 --- a/gtk/gtk-win32.rc.body.in +++ b/gtk/gtk-win32.rc.body.in @@ -1,3 +1,4 @@ +#include #include GTK_ICON ICON "gtk.ico" @@ -18,9 +19,9 @@ VS_VERSION_INFO VERSIONINFO VALUE "CompanyName", "The GTK developer community" VALUE "FileDescription", "GIMP Toolkit" VALUE "FileVersion", "@GTK_VERSION@.0" - VALUE "InternalName", "libgtk-win32-@GTK_API_VERSION@-@LT_CURRENT_MINUS_AGE@" - VALUE "LegalCopyright", "Copyright © 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald. Modified by the GTK+ Team and others 1997-2011." - VALUE "OriginalFilename", "libgtk-win32-@GTK_API_VERSION@-@LT_CURRENT_MINUS_AGE@.dll" + VALUE "InternalName", "libgtk-win32-@GTK_API_VERSION@" + VALUE "LegalCopyright", "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald. Modified by the GTK+ Team and others 1997-2011." + VALUE "OriginalFilename", "libgtk-win32-@GTK_API_VERSION@.dll" VALUE "ProductName", "GTK+" VALUE "ProductVersion", "@GTK_VERSION@" END @@ -30,3 +31,5 @@ VS_VERSION_INFO VERSIONINFO VALUE "Translation", 0x409, 1200 END END + +ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST libgtk4.manifest \ No newline at end of file diff --git a/gtk/meson.build b/gtk/meson.build index 8559ed0f7c..abc66cbc90 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -841,6 +841,12 @@ gtkversion_cdata.set('GTK_MINOR_VERSION', gtk_minor_version) gtkversion_cdata.set('GTK_MICRO_VERSION', gtk_micro_version) gtkversion_cdata.set('GTK_BINARY_AGE', gtk_binary_age) gtkversion_cdata.set('GTK_INTERFACE_AGE', gtk_interface_age) +gtkversion_cdata.set('GTK_VERSION', gtk_version) +gtkversion_cdata.set('GTK_API_VERSION', gtk_api_version) + +if host_machine.system() == 'windows' + gtkversion_cdata.set('EXE_MANIFEST_ARCHITECTURE', '*') +endif gtkversion = configure_file(input: 'gtkversion.h.in', output: 'gtkversion.h', @@ -916,6 +922,17 @@ if win32_enabled cc.find_library('imm32'), cc.find_library('setupapi'), cc.find_library('winmm')] + + gtkwin32rc = configure_file(input: 'gtk-win32.rc.body.in', + output: 'gtk-win32.rc.body', + configuration: gtkversion_cdata) + + win32_manifest = configure_file(input: 'libgtk4.manifest.in', + output: 'libgtk4.manifest', + configuration: gtkversion_cdata) + + win32res = import('windows').compile_resources(gtkwin32rc, include_directories : win32rcinc) + gtk_sources += win32res else gtk_deps += [ atkbridge_dep, ] endif From 5383d11bb40c333b3b3a7830ec21d5bbcb98be11 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Sat, 23 Jun 2018 01:53:32 +0800 Subject: [PATCH 2/3] modules/media/meson.build: Export needed symbols on MSVC We need to override _GLIB_EXTERN to export the required symbols for the GIO module on Visual Studio, so that the media modules can be successfully loaded. --- modules/media/meson.build | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/media/meson.build b/modules/media/meson.build index 860fe467e9..8a05ccb565 100644 --- a/modules/media/meson.build +++ b/modules/media/meson.build @@ -23,6 +23,13 @@ endif media_subdir = 'gtk-4.0/@0@/media'.format(gtk_binary_version) media_install_dir = join_paths(get_option('libdir'), media_subdir) +extra_c_args = ['-DGTK_COMPILATION'] + +# Detect and set symbol visibility +if cc.get_id() == 'msvc' + extra_c_args += ['-D_GLIB_EXTERN=__declspec (dllexport) extern'] +endif + if media_backends.contains('ffmpeg') libavfilter_dep = dependency('libavfilter', version: '>= 6.47.100', required: true) libavformat_dep = dependency('libavformat', version: '>= 57.41.100', required: true) @@ -34,9 +41,7 @@ if media_backends.contains('ffmpeg') shared_module('media-ffmpeg', 'gtkffmediafile.c', - c_args: [ - '-DGTK_COMPILATION' - ], + c_args: extra_c_args, dependencies: [ libgtk_dep, ffmpeg_deps ], install_dir: media_install_dir, install : true) @@ -50,9 +55,7 @@ if media_backends.contains('gstreamer') 'gtkgstmediafile.c', 'gtkgstpaintable.c', 'gtkgstsink.c', - c_args: [ - '-DGTK_COMPILATION' - ], + c_args: extra_c_args, dependencies: [ libgtk_dep, gstplayer_dep ], install_dir: media_install_dir, install : true) From 3fa28ffd92ea77da5e20842fbc621bd0a9fec557 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 8 Jun 2018 18:04:30 +0800 Subject: [PATCH 3/3] build: Make post-install script a Python script The existing post-install shell script will most likely not work on Visual Studio builds as there is normally no shell interpreter installed on the system where the build is done, but the build is normally done in a standard Windows cmd.exe console. Instead, use a Python script so that it will work on the platforms that Python supports. --- build-aux/meson/post-install.py | 33 +++++++++++++++++++++++++++++++++ build-aux/meson/post-install.sh | 26 -------------------------- meson.build | 2 +- 3 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 build-aux/meson/post-install.py delete mode 100755 build-aux/meson/post-install.sh diff --git a/build-aux/meson/post-install.py b/build-aux/meson/post-install.py new file mode 100644 index 0000000000..f84b1971f5 --- /dev/null +++ b/build-aux/meson/post-install.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import os +import sys +import subprocess + +if 'DESTDIR' not in os.environ: + gtk_api_version = sys.argv[1] + gtk_abi_version = sys.argv[2] + gtk_libdir = sys.argv[3].replace('/', os.sep) + gtk_datadir = sys.argv[4].replace('/', os.sep) + + gtk_moduledir = os.path.join(gtk_libdir, 'gtk-' + gtk_api_version, gtk_abi_version) + gtk_printmodule_dir = os.path.join(gtk_moduledir, 'printbackends') + gtk_immodule_dir = os.path.join(gtk_moduledir, 'immodules') + + print('Compiling GSettings schemas...') + subprocess.call(['glib-compile-schemas', + os.path.join(gtk_datadir, 'glib-2.0', 'schemas')]) + + print('Updating icon cache...') + subprocess.call(['gtk-update-icon-cache', '-q', '-t' ,'-f', + os.path.join(gtk_datadir, 'icons', 'hicolor')]) + + print('Updating module cache for print backends...') + if not os.path.isdir(gtk_printmodule_dir): + os.mkdir(gtk_printmodule_dir) + subprocess.call(['gio-querymodules', gtk_printmodule_dir]) + + print('Updating module cache for input methods...') + if not os.path.isdir(gtk_immodule_dir): + os.mkdir(gtk_immodule_dir) + subprocess.call(['gio-querymodules', gtk_immodule_dir]) diff --git a/build-aux/meson/post-install.sh b/build-aux/meson/post-install.sh deleted file mode 100755 index 0d18b13d76..0000000000 --- a/build-aux/meson/post-install.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -gtk_api_version=$1 -gtk_abi_version=$2 -gtk_libdir=$3 -gtk_datadir=$4 - -# Package managers set this so we don't need to run -if [ -z "$DESTDIR" ]; then - echo Compiling GSettings schemas... - glib-compile-schemas ${gtk_datadir}/glib-2.0/schemas - - echo Updating desktop database... - update-desktop-database -q ${gtk_datadir}/applications - - echo Updating icon cache... - gtk-update-icon-cache -q -t -f ${gtk_datadir}/icons/hicolor - - echo Updating module cache for print backends... - mkdir -p ${gtk_libdir}/gtk-4.0/4.0.0/printbackends - gio-querymodules ${gtk_libdir}/gtk-4.0/4.0.0/printbackends - - echo Updating module cache for input methods... - mkdir -p ${gtk_libdir}/gtk-4.0/4.0.0/immodules - gio-querymodules ${gtk_libdir}/gtk-4.0/4.0.0/immodules -fi diff --git a/meson.build b/meson.build index 53504f9279..923e13e635 100644 --- a/meson.build +++ b/meson.build @@ -897,7 +897,7 @@ if get_option('documentation') endif # Keep this in sync with post-install.sh expected arguments -meson.add_install_script('build-aux/meson/post-install.sh', +meson.add_install_script('build-aux/meson/post-install.py', gtk_api_version, gtk_binary_version, gtk_libdir,