diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index e235327f03..9fa15e824b 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -8,6 +8,6 @@ SUBDIRS = \
vs12 \
vs14
-EXTRA_DIST += process-in-win32.py
+EXTRA_DIST += replace.py
-include $(top_srcdir)/git.mk
diff --git a/build/win32/process-in-win32.py b/build/win32/process-in-win32.py
deleted file mode 100644
index 86be09a587..0000000000
--- a/build/win32/process-in-win32.py
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/usr/bin/python
-# vim: encoding=utf-8
-# expand Windows-specific *.in files
-# for Visual Studio Builds
-
-import os
-import sys
-import re
-import string
-import argparse
-
-
-def open_compat(src, mode):
- if (sys.version_info.major < 3):
- return open(src, mode)
- else:
- return open(src, mode, encoding='utf-8', errors='surrogateescape')
-
-def get_version(srcroot):
- ver = {}
- RE_VERSION = re.compile(r'^m4_define\(\[(gtk_\w+)\],\s*\[(\d+)\]\)')
- RE_FLOAT_VERSION = re.compile(r'^m4_define\(\[(gtk_\w+)\],\s*\[(\d+\.\d*)\]\)')
- with open(os.path.join(srcroot, 'configure.ac'), 'r') as ac:
- for i in ac:
- mo = RE_VERSION.search(i)
- if mo:
- ver[mo.group(1).upper()] = int(mo.group(2))
- mo = RE_FLOAT_VERSION.search(i)
- if mo:
- ver[mo.group(1).upper()] = float(mo.group(2))
-
- ver['GTK_BINARY_AGE'] = 100 * ver['GTK_MINOR_VERSION'] + ver['GTK_MICRO_VERSION']
- ver['GTK_VERSION'] = '%d.%d.%d' % (ver['GTK_MAJOR_VERSION'],
- ver['GTK_MINOR_VERSION'],
- ver['GTK_MICRO_VERSION'])
- ver['LT_RELEASE'] = '%d.%d' % (ver['GTK_MAJOR_VERSION'], ver['GTK_MINOR_VERSION'])
- ver['LT_CURRENT'] = 100 * \
- ver['GTK_MINOR_VERSION'] + \
- ver['GTK_MICRO_VERSION'] - \
- ver['GTK_INTERFACE_AGE']
- ver['LT_REVISION'] = ver['GTK_INTERFACE_AGE']
- ver['LT_AGE'] = ver['GTK_BINARY_AGE'] - ver['GTK_INTERFACE_AGE']
- ver['LT_CURRENT_MINUS_AGE'] = ver['LT_CURRENT'] - ver['LT_AGE']
- return ver
-
-def process_in(src, dest, vars):
- RE_VARS = re.compile(r'@(\w+?)@')
-
- with open_compat(src, 'r') as s:
- with open_compat(dest, 'w') as d:
- for i in s:
- i = RE_VARS.sub(lambda x: str(vars[x.group(1)]), i)
- d.write(i)
-
-def get_srcroot():
- if not os.path.isabs(__file__):
- path = os.path.abspath(__file__)
- else:
- path = __file__
- dirname = os.path.dirname(path)
- return os.path.abspath(os.path.join(dirname, '..', '..'))
-
-def main(argv):
- prog_desc = 'Create Various autogenerated Win32-specific Source Files'
- parser = argparse.ArgumentParser(description=prog_desc)
- parser.add_argument('--gtkwin32rc', dest='gtkwin32rc', action='store_const',
- const=1,
- help='Generate gtk-win32.rc')
-
- parser.add_argument('--gtk3manifest', dest='gtk3manifest', action='store_const',
- const=1,
- help='Generate libgtk3.manifest')
-
- args = parser.parse_args()
- no_args = True
-
- if args.gtkwin32rc is not None:
- srcroot = get_srcroot()
-
- ver = get_version(srcroot)
-
- target = os.path.join(srcroot, 'gtk', 'gtk-win32.rc')
- process_in(os.path.join(srcroot, 'gtk', 'gtk-win32.rc.in'),
- target + '.intermediate',
- ver)
- fp_r = open_compat(target + '.intermediate', 'r')
- lines = fp_r.readlines()
- fp_r.close()
- fp_w = open_compat(target, 'w')
- fp_w.writelines([item for item in lines[:-1]])
-
- fp_w.close()
- os.unlink(target + '.intermediate')
-
- no_args = False
-
- if args.gtk3manifest is not None:
- manifest = {}
- manifest['EXE_MANIFEST_ARCHITECTURE'] = '*'
- process_in(os.path.join(srcroot, 'gtk', 'libgtk3.manifest.in'),
- os.path.join(srcroot, 'gtk', 'libgtk3.manifest'),
- manifest)
- no_args = False
-
- if no_args is True:
- raise SystemExit('Action argument required. Please see %s --help for details.' % __file__)
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv))
diff --git a/build/win32/replace.py b/build/win32/replace.py
new file mode 100644
index 0000000000..69ef417a29
--- /dev/null
+++ b/build/win32/replace.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+#
+# Simple utility script to manipulate
+# certain types of strings in a file
+
+# This can be used in various projects where
+# there is the need to replace strings in files,
+# and is copied from GLib's $(srcroot)/build/win32
+
+# Author: Fan, Chun-wei
+# Date: September 03, 2014
+
+import os
+import sys
+import re
+import string
+import argparse
+
+valid_actions = ['remove-prefix',
+ 'replace-var',
+ 'replace-str',
+ 'remove-str']
+
+def replace(src, dest, instring, outstring):
+ with open(src, 'r') as s:
+ with open(dest, 'w') as d:
+ for line in s:
+ i = line.replace(instring, outstring)
+ d.write(i)
+
+def check_required_args(args, params):
+ for param in params:
+ if getattr(args, param, None) is None:
+ raise SystemExit('%s: error: --%s argument is required' % (__file__, param))
+
+def warn_ignored_args(args, params):
+ for param in params:
+ if getattr(args, param, None) is not None:
+ print('%s: warning: --%s argument is ignored' % (__file__, param))
+
+def main(argv):
+
+ parser = argparse.ArgumentParser(description='Process strings in a file.')
+ parser.add_argument('-a',
+ '--action',
+ help='Action to carry out. Can be one of:\n'
+ 'remove-prefix\n'
+ 'replace-var\n'
+ 'replace-str\n'
+ 'remove-str',
+ choices=valid_actions)
+ parser.add_argument('-i', '--input', help='Input file')
+ parser.add_argument('-o', '--output', help='Output file')
+ parser.add_argument('--instring', help='String to replace or remove')
+ parser.add_argument('--var', help='Autotools variable name to replace')
+ parser.add_argument('--outstring',
+ help='New String to replace specified string or variable')
+ parser.add_argument('--removeprefix', help='Prefix of string to remove')
+
+ args = parser.parse_args()
+
+ input_string = ''
+ output_string = ''
+
+ # We must have action, input, output for all operations
+ check_required_args(args, ['action','input','output'])
+
+ # Build the arguments by the operation that is to be done,
+ # to be fed into replace()
+
+ # Get rid of prefixes from a string
+ if args.action == 'remove-prefix':
+ check_required_args(args, ['instring','removeprefix'])
+ warn_ignored_args(args, ['outstring','var'])
+ input_string = args.removeprefix + args.instring
+ output_string = args.instring
+
+ # Replace an m4-style variable (those surrounded by @...@)
+ if args.action == 'replace-var':
+ check_required_args(args, ['var','outstring'])
+ warn_ignored_args(args, ['instring','removeprefix'])
+ input_string = '@' + args.var + '@'
+ output_string = args.outstring
+
+ # Replace a string
+ if args.action == 'replace-str':
+ check_required_args(args, ['instring','outstring'])
+ warn_ignored_args(args, ['var','removeprefix'])
+ input_string = args.instring
+ output_string = args.outstring
+
+ # Remove a string
+ if args.action == 'remove-str':
+ check_required_args(args, ['instring'])
+ warn_ignored_args(args, ['var','outstring','removeprefix'])
+ input_string = args.instring
+ output_string = ''
+
+ replace(args.input, args.output, input_string, output_string)
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/build/win32/vs10/gtk-3.vcxproj.filtersin b/build/win32/vs10/gtk-3.vcxproj.filtersin
index aefeb4531b..319d20ab01 100644
--- a/build/win32/vs10/gtk-3.vcxproj.filtersin
+++ b/build/win32/vs10/gtk-3.vcxproj.filtersin
@@ -19,7 +19,8 @@
Resource Files
- Resource Files
+ Resource Files
+ Resource Files
#include "gtk-3.vs10.sourcefiles.filters"
diff --git a/build/win32/vs10/gtk-3.vcxprojin b/build/win32/vs10/gtk-3.vcxprojin
index b8031d6fc6..f159c5e841 100644
--- a/build/win32/vs10/gtk-3.vcxprojin
+++ b/build/win32/vs10/gtk-3.vcxprojin
@@ -177,19 +177,33 @@
$(GenerateGtkDbusBuiltSources)
..\..\..\gtk\gtkdbusgenerated.c;..\..\..\gtk\gtkdbusgenerated.h;%(Outputs)
-
- Generating GTK+ Win32 Version Resource...
- $(GenerateGtkWin32RC)
- ..\..\..\gtk\gtk-win32.rc;..\..\..\gtk\libgtk3.manifest;%(Outputs)
- Generating GTK+ Win32 Version Resource...
- $(GenerateGtkWin32RC)
- ..\..\..\gtk\gtk-win32.rc;..\..\..\gtk\libgtk3.manifest;%(Outputs)
- Generating GTK+ Win32 Version Resource...
- $(GenerateGtkWin32RC)
- ..\..\..\gtk\gtk-win32.rc;..\..\..\gtk\libgtk3.manifest;%(Outputs)
- Generating GTK+ Win32 Version Resource...
- $(GenerateGtkWin32RC)
- ..\..\..\gtk\gtk-win32.rc;..\..\..\gtk\libgtk3.manifest;%(Outputs)
+
+ Copying GTK+ Win32 Version Resource...
+ $(CopyGtkWin32RC)
+ ..\..\..\gtk\gtk-win32.rc;%(Outputs)
+ Copying GTK+ Win32 Version Resource...
+ $(CopyGtkWin32RC)
+ ..\..\..\gtk\gtk-win32.rc;%(Outputs)
+ Copying GTK+ Win32 Version Resource...
+ $(CopyGtkWin32RC)
+ ..\..\..\gtk\gtk-win32.rc;%(Outputs)
+ Copying GTK+ Win32 Version Resource...
+ $(CopyGtkWin32RC)
+ ..\..\..\gtk\gtk-win32.rc;%(Outputs)
+
+
+ Generating GTK+ Win32 Manifest...
+ $(GenerateGtkWin32Manifest)
+ ..\..\..\gtk\libgtk3.manifest;%(Outputs)
+ Generating GTK+ Win32 Manifest...
+ $(GenerateGtkWin32Manifest)
+ ..\..\..\gtk\libgtk3.manifest;%(Outputs)
+ Generating GTK+ Win32 Manifest...
+ $(GenerateGtkWin32Manifest)
+ ..\..\..\gtk\libgtk3.manifest;%(Outputs)
+ Generating GTK+ Win32 Manifest...
+ $(GenerateGtkWin32Manifest)
+ ..\..\..\gtk\libgtk3.manifest;%(Outputs)
diff --git a/build/win32/vs10/gtk3-gen-srcs.props b/build/win32/vs10/gtk3-gen-srcs.props
index 41c68eb03c..b9440c83b6 100644
--- a/build/win32/vs10/gtk3-gen-srcs.props
+++ b/build/win32/vs10/gtk3-gen-srcs.props
@@ -64,7 +64,8 @@ $(PythonPath)\python $(GlibEtcInstallRoot)\bin\gdbus-codegen --interface-prefix
cd $(SolutionDir)
- $(PythonPath)\python ..\process-in-win32.py --gtkwin32rc --gtk3manifest
+ copy ..\..\..\gtk\gtk-win32.rc.body ..\..\..\gtk\gtk-win32.rc
+ $(PythonPath)\python ..\replace.py --action=replace-var --input=..\..\..\gtk\libgtk3.manifest.in --output=..\..\..\gtk\libgtk3.manifest --var=EXE_MANIFEST_ARCHITECTURE --outstring=*
copy ..\..\..\demos\gtk-demo\demos.h.win32 ..\..\..\demos\gtk-demo\demos.h
@@ -83,8 +84,11 @@ cd $(SolutionDir)
$(GenerateGtkDbusBuiltSources)
-
- $(GenerateGtkWin32RC)
+
+ $(CopyGtkWin32RC)
+
+
+ $(GenerateGtkWin32Manifest)
$(CopyDemosH)
diff --git a/build/win32/vs10/gtk3-gen-srcs.vsprops b/build/win32/vs10/gtk3-gen-srcs.vsprops
new file mode 100644
index 0000000000..88bb9826f2
--- /dev/null
+++ b/build/win32/vs10/gtk3-gen-srcs.vsprops
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/build/win32/vs9/gtk-3.vcprojin b/build/win32/vs9/gtk-3.vcprojin
index 24b4fe4be0..b2dd357b6d 100644
--- a/build/win32/vs9/gtk-3.vcprojin
+++ b/build/win32/vs9/gtk-3.vcprojin
@@ -192,33 +192,63 @@
/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/configure.ac b/configure.ac
index ae139e860b..e97cb25671 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1943,7 +1943,7 @@ gdk/gdkversionmacros.h
gtk/Makefile
gtk/makefile.msc
gtk/gtkversion.h
-gtk/gtk-win32.rc
+gtk/gtk-win32.rc.body
gtk/libgtk3.manifest
libgail-util/Makefile
modules/Makefile
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 08062464db..45f862a761 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -35,6 +35,11 @@ gtk_win32_res_ldflag = -Wl,gtk-win32-res.o
gtk-win32-res.o : gtk-win32.rc libgtk3.manifest
$(WINDRES) gtk-win32.rc $@
+gtk-win32.rc: gtk-win32.rc.body
+ echo "#include " >>$@
+ cat $< >>$@
+ echo "ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST libgtk3.manifest" >>$@
+
gtk.def: libgtk-3.la
echo "LIBRARY libgtk-$(GTK_MAJOR_VERSION)-@LT_CURRENT_MINUS_AGE@" >$@
echo "EXPORTS" >>$@
@@ -1124,6 +1129,10 @@ MAINTAINERCLEANFILES = \
DISTCLEANFILES =
+if OS_WIN32
+DISTCLEANFILES += gtk-win32.rc
+endif
+
EXTRA_DIST += $(gtk_all_private_h_sources) $(gtk_extra_sources)
EXTRA_DIST += $(gtk_built_sources)
@@ -1587,7 +1596,8 @@ EXTRA_DIST += \
deprecated/Makefile.inc \
inspector/Makefile.inc \
libgtk3.manifest.in \
- gtk-win32.rc.in \
+ gtk-win32.rc.body.in \
+ gtk-win32.rc.body \
gtkwin32embed.h \
gtkwin32embedwidget.h \
gtkwin32embedwidget.c \
diff --git a/gtk/gtk-win32.rc.in b/gtk/gtk-win32.rc.body.in
similarity index 92%
rename from gtk/gtk-win32.rc.in
rename to gtk/gtk-win32.rc.body.in
index e58d55aa7e..4a42d5a666 100644
--- a/gtk/gtk-win32.rc.in
+++ b/gtk/gtk-win32.rc.body.in
@@ -1,5 +1,4 @@
#include
-#include
VS_VERSION_INFO VERSIONINFO
FILEVERSION @GTK_MAJOR_VERSION@,@GTK_MINOR_VERSION@,@GTK_MICRO_VERSION@,0
@@ -29,4 +28,3 @@ VS_VERSION_INFO VERSIONINFO
VALUE "Translation", 0x409, 1200
END
END
-ISOLATIONAWARE_MANIFEST_RESOURCE_ID RT_MANIFEST libgtk3.manifest