[gtk/wip/fanc999/gtk-3-24-meson-msvc: 13/14] meson: Build the .rc files on Windows



commit d7244e196ba9a8c610cf39ae3a5ab30227e9598e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 13 14:01:13 2019 +0800

    meson: Build the .rc files on Windows
    
    This will ensure that the version info is easily visible from the
    GDK/GTK+ DLLs, and ensure that the print dialogs will have a more modern
    look and feel.

 gdk/meson.build          | 11 +++++++++++
 gdk/win32/rc/gdk.rc.in   |  2 +-
 gtk/gen-rc.py            | 21 +++++++++++++++++++++
 gtk/gtk-win32.rc.body.in |  2 +-
 gtk/meson.build          | 39 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 73 insertions(+), 2 deletions(-)
---
diff --git a/gdk/meson.build b/gdk/meson.build
index 8d296a6343..9bf99b81a2 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -177,6 +177,9 @@ gdkversion_cdata = configuration_data()
 gdkversion_cdata.set('GTK_MAJOR_VERSION', gtk_major_version)
 gdkversion_cdata.set('GTK_MINOR_VERSION', gtk_minor_version)
 gdkversion_cdata.set('GTK_MICRO_VERSION', gtk_micro_version)
+gdkversion_cdata.set('GTK_API_VERSION', gtk_api_version)
+gdkversion_cdata.set('GTK_BINARY_VERSION', gtk_binary_version)
+gdkversion_cdata.set('GTK_VERSION', meson.project_version())
 
 gdkversionmacros = configure_file(
   input  : 'gdkversionmacros.h.in',
@@ -212,6 +215,14 @@ if win32_enabled
                cc.find_library('imm32'),
                cc.find_library('setupapi'),
                cc.find_library('winmm')]
+
+  gdk_rc = configure_file(
+    input: 'win32/rc/gdk.rc.in',
+    output: 'gdk.rc',
+    configuration: gdkversion_cdata,
+  )
+  gdk_res = import('windows').compile_resources(gdk_rc, include_directories: include_directories('win32/rc'))
+  gdk_sources += gdk_res
 endif
 
 gdk_sources = [
diff --git a/gdk/win32/rc/gdk.rc.in b/gdk/win32/rc/gdk.rc.in
index 07ab1b4553..f9b57f5197 100644
--- a/gdk/win32/rc/gdk.rc.in
+++ b/gdk/win32/rc/gdk.rc.in
@@ -19,7 +19,7 @@ VS_VERSION_INFO VERSIONINFO
        VALUE "FileDescription", "GIMP Drawing Kit"
        VALUE "FileVersion", "@GTK_VERSION@.0"
        VALUE "InternalName", "libgdk-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 "LegalCopyright", "Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald. 
Modified by the GTK+ Team and others 1997-2011."
        VALUE "OriginalFilename", "libgdk-win32-@GTK_API_VERSION@-@LT_CURRENT_MINUS_AGE@.dll"
        VALUE "ProductName", "GTK+"
        VALUE "ProductVersion", "@GTK_VERSION@"
diff --git a/gtk/gen-rc.py b/gtk/gen-rc.py
new file mode 100644
index 0000000000..2c24fa5f6e
--- /dev/null
+++ b/gtk/gen-rc.py
@@ -0,0 +1,21 @@
+#! /usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import sys
+import os
+
+out_file = sys.argv[1]
+in_file = sys.argv[2]
+old_msvc = sys.argv[3]
+
+with open(out_file, 'w') as o:
+    if old_msvc is not None and old_msvc == "1":
+        o.write("#define ISOLATION_AWARE_ENABLED 1\n")
+    o.write('#include <winuser.h>\n')
+
+    with open(in_file, 'r') as f:
+        for line in f:
+            o.write(line)
+
+    o.write('\n')
+    o.write('ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST libgtk3.manifest')
\ No newline at end of file
diff --git a/gtk/gtk-win32.rc.body.in b/gtk/gtk-win32.rc.body.in
index 4a42d5a666..3834e16efc 100644
--- a/gtk/gtk-win32.rc.body.in
+++ b/gtk/gtk-win32.rc.body.in
@@ -17,7 +17,7 @@ VS_VERSION_INFO VERSIONINFO
        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 "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@-@LT_CURRENT_MINUS_AGE@.dll"
        VALUE "ProductName", "GTK+"
        VALUE "ProductVersion", "@GTK_VERSION@"
diff --git a/gtk/meson.build b/gtk/meson.build
index bd557f2403..6c16c324e8 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -784,6 +784,10 @@ 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_API_VERSION', gtk_api_version)
+gtkversion_cdata.set('GTK_BINARY_VERSION', gtk_binary_version)
+gtkversion_cdata.set('GTK_VERSION', meson.project_version())
+gtkversion_cdata.set('EXE_MANIFEST_ARCHITECTURE', '*')
 
 gtkversion = configure_file(input: 'gtkversion.h.in',
                             output: 'gtkversion.h',
@@ -840,6 +844,41 @@ if win32_enabled
   gtk_cargs += []
   gtk_sources += gtk_use_win32_sources
   gtk_deps += [ giowin32_dep, pangowin32_dep ]
+
+  gtk_rc_body = configure_file(
+    input: 'gtk-win32.rc.body.in',
+    output: 'gtk-win32.rc.body',
+       configuration: gtkversion_cdata,
+  )
+  gtk_rc_manifest = configure_file(
+    input: 'libgtk3.manifest.in',
+    output: 'libgtk3.manifest',
+    configuration: gtkversion_cdata,
+  )
+
+  # Unfortunately, an extra directive in the .rc file is required for earlier
+  # Visual Studio for embedding manifests via .rc files (2010 [v16] and earlier)
+  # using ISOLATIONAWARE_MANIFEST_RESOURCE_ID to really work.  Somehow for
+  # Visual Studio 2008 builds, this does not yet work.
+  old_msvc = false
+
+  if cc.get_id() != 'msvc' or cc.version().split('.')[0].to_int() < 17
+    old_msvc = true
+  endif
+
+  gtk_rc = custom_target(
+             'gtk.rc',
+             output: 'gtk.rc',
+             input: gtk_rc_body,
+             command: [find_program('gen-rc.py'),
+               '@OUTPUT@',
+               '@INPUT@',
+               old_msvc ? '1' : ''
+             ],
+             install: false,
+           )
+  gtk_res = import('windows').compile_resources(gtk_rc)
+  gtk_sources += gtk_res
 else
   gtk_deps += [ atkbridge_dep, ]
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]