From 3d89041220a2a783b5706763b35778f9154c0883 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 8 Aug 2014 17:39:22 +0800 Subject: [PATCH] MSVC Builds: Generate glib-mkenums If Possible As glib-mkenums would likely be used in the building of the other components of the stack, such as Cogl, Clutter and gsettings-desktop-schemas, generate that using a Python script (if Python can be found) and "install" it. --- build/win32/Makefile.am | 3 +- build/win32/process_in_win32.py | 77 ++++++++++++++++++++++ build/win32/setup.py | 35 +--------- build/win32/vs10/glib-gen-srcs.props | 4 ++ build/win32/vs10/glib-install.props | 2 + build/win32/vs10/glib-version-paths.props | 4 ++ build/win32/vs10/gobject.vcxproj.filtersin | 5 +- build/win32/vs10/gobject.vcxprojin | 26 ++++++-- build/win32/vs9/glib-gen-srcs.vsprops | 20 +++--- build/win32/vs9/glib-install.vsprops | 1 + build/win32/vs9/glib-version-paths.vsprops | 4 ++ build/win32/vs9/gobject.vcprojin | 42 ++++++++++-- 12 files changed, 167 insertions(+), 56 deletions(-) create mode 100644 build/win32/process_in_win32.py diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am index 8a9a8b4b1..e7b1e63dc 100644 --- a/build/win32/Makefile.am +++ b/build/win32/Makefile.am @@ -7,4 +7,5 @@ SUBDIRS = \ EXTRA_DIST = \ make.msc \ - module.defs + module.defs \ + process_in_win32.py diff --git a/build/win32/process_in_win32.py b/build/win32/process_in_win32.py new file mode 100644 index 000000000..62a8e3a19 --- /dev/null +++ b/build/win32/process_in_win32.py @@ -0,0 +1,77 @@ +#!/usr/bin/python +# vim: encoding=utf-8 +#expand *.in scripts for MSVC Builds +import os +import sys +import re +import string +import argparse + +def get_version(srcroot): + ver = {} + RE_VERSION = re.compile(r'^m4_define\(\[(glib_\w+)\],\s*\[(\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)) + ver['GLIB_BINARY_AGE'] = 100 * ver['GLIB_MINOR_VERSION'] + ver['GLIB_MICRO_VERSION'] + ver['GLIB_VERSION'] = '%d.%d.%d' % (ver['GLIB_MAJOR_VERSION'], + ver['GLIB_MINOR_VERSION'], + ver['GLIB_MICRO_VERSION']) + ver['LT_RELEASE'] = '%d.%d' % (ver['GLIB_MAJOR_VERSION'], ver['GLIB_MINOR_VERSION']) + ver['LT_CURRENT'] = 100 * ver['GLIB_MINOR_VERSION'] + ver['GLIB_MICRO_VERSION'] - ver['GLIB_INTERFACE_AGE'] + ver['LT_REVISION'] = ver['GLIB_INTERFACE_AGE'] + ver['LT_AGE'] = ver['GLIB_BINARY_AGE'] - ver['GLIB_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(src, 'r') as s: + with open(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('--glib-mkenums', dest='mkenums', action='store_const', + const=1, + help='Generate glib-mkenums') + + parser.add_argument('--perl', dest='perl', metavar='PATH', + default='C:\\Perl\\bin\\perl.exe', + action='store', + help='path to the perl interpretor (default: C:\\Perl\\bin\\perl.exe)') + + args = parser.parse_args() + srcroot = get_srcroot() + ver = get_version(srcroot) + + no_args = True + + if args.mkenums is not None: + # Generate glib-mkenums script from glib-mkenums + ver.update({'PERL_PATH': args.perl}) + + target = os.path.join(srcroot, 'gobject', 'glib-mkenums') + process_in(target + '.in', + target, + ver) + 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/setup.py b/build/win32/setup.py index 7cdbd6790..ef732c6df 100644 --- a/build/win32/setup.py +++ b/build/win32/setup.py @@ -9,32 +9,7 @@ import string import subprocess import optparse -def get_version(srcroot): - ver = {} - RE_VERSION = re.compile(r'^m4_define\(\[(glib_\w+)\],\s*\[(\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)) - ver['GLIB_BINARY_AGE'] = 100 * ver['GLIB_MINOR_VERSION'] + ver['GLIB_MICRO_VERSION'] - ver['GLIB_VERSION'] = '%d.%d.%d' % (ver['GLIB_MAJOR_VERSION'], - ver['GLIB_MINOR_VERSION'], - ver['GLIB_MICRO_VERSION']) - ver['LT_RELEASE'] = '%d.%d' % (ver['GLIB_MAJOR_VERSION'], ver['GLIB_MINOR_VERSION']) - ver['LT_CURRENT'] = 100 * ver['GLIB_MINOR_VERSION'] + ver['GLIB_MICRO_VERSION'] - ver['GLIB_INTERFACE_AGE'] - ver['LT_REVISION'] = ver['GLIB_INTERFACE_AGE'] - ver['LT_AGE'] = ver['GLIB_BINARY_AGE'] - ver['GLIB_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(src, 'r') as s: - with open(dest, 'w') as d: - for i in s: - i = RE_VARS.sub(lambda x: str(vars[x.group(1)]), i) - d.write(i) +from process_in_win32 import get_version, process_in, get_srcroot def process_include(src, dest, includes): RE_INCLUDE = re.compile(r'^\s*#include\s+"(.*)"') @@ -233,13 +208,7 @@ def main(argv): parser = optparse.OptionParser() parser.add_option('-p', '--perl', dest='perl', metavar='PATH', default='C:\\Perl\\bin\\perl.exe', action='store', help='path to the perl interpretor (default: C:\\Perl\\bin\\perl.exe)') opt, args = parser.parse_args(argv) - def parent_dir(path): - if not os.path.isabs(path): - path = os.path.abspath(path) - if os.path.isfile(path): - path = os.path.dirname(path) - return os.path.split(path)[0] - srcroot = parent_dir(parent_dir(__file__)) + srcroot = get_srcroot() #print 'srcroot', srcroot ver = get_version(srcroot) #print 'ver', ver diff --git a/build/win32/vs10/glib-gen-srcs.props b/build/win32/vs10/glib-gen-srcs.props index c79b21503..7707e6762 100644 --- a/build/win32/vs10/glib-gen-srcs.props +++ b/build/win32/vs10/glib-gen-srcs.props @@ -8,6 +8,7 @@ copy ..\..\..\glib\glibconfig.h.win32 ..\..\..\glib\glibconfig.h copy ..\..\..\gmodule\gmoduleconf.h.win32 ..\..\..\gmodule\gmoduleconf.h copy ..\..\..\gio\gnetworking.h.win32 ..\..\..\gio\gnetworking.h + if exist $(PythonPath)\python.exe $(PythonPath)\python.exe ..\process_in_win32.py --glib-mkenums <_PropertySheetDisplayName>glibgensrcsprops @@ -25,5 +26,8 @@ $(GenGNetworkingH) + + $(GenGLibMKEnums) + \ No newline at end of file diff --git a/build/win32/vs10/glib-install.props b/build/win32/vs10/glib-install.props index 37b4c467f..f052159a7 100644 --- a/build/win32/vs10/glib-install.props +++ b/build/win32/vs10/glib-install.props @@ -34,6 +34,8 @@ copy $(BinDir)\gdbus.exe $(CopyDir)\bin copy ..\..\..\gio\gdbus-2.0\codegen\gdbus-codegen.in $(CopyDir)\bin\gdbus-codegen +if exist ..\..\..\gobject\glib-mkenums copy ..\..\..\gobject\glib-mkenums $(CopyDir)\bin + mkdir $(CopyDir)\include\glib-$(ApiVersion)\glib\deprecated diff --git a/build/win32/vs10/glib-version-paths.props b/build/win32/vs10/glib-version-paths.props index d81982846..4663a84a3 100644 --- a/build/win32/vs10/glib-version-paths.props +++ b/build/win32/vs10/glib-version-paths.props @@ -11,6 +11,7 @@ -2-vs$(VSVer) $(GlibSeparateVSDllPrefix) $(GlibSeparateVSDllSuffix) + c:\python27 <_PropertySheetDisplayName>glibversionpathsprops @@ -46,5 +47,8 @@ $(GlibDllSuffix) + + $(PythonPath) + \ No newline at end of file diff --git a/build/win32/vs10/gobject.vcxproj.filtersin b/build/win32/vs10/gobject.vcxproj.filtersin index 17db3ef4a..7c7350aa3 100644 --- a/build/win32/vs10/gobject.vcxproj.filtersin +++ b/build/win32/vs10/gobject.vcxproj.filtersin @@ -17,9 +17,12 @@ #include "libgobject.vs10.sourcefiles.filters" + + Resource Files + Resource Files - \ No newline at end of file + diff --git a/build/win32/vs10/gobject.vcxprojin b/build/win32/vs10/gobject.vcxprojin index 1a27529c4..d9b33e536 100644 --- a/build/win32/vs10/gobject.vcxprojin +++ b/build/win32/vs10/gobject.vcxprojin @@ -51,19 +51,19 @@ - + - + - + - + @@ -175,6 +175,22 @@ #include "libgobject.vs10.sourcefiles" + + + Generating glib-mkenums... + $(GenGLibMKEnums) + ..\..\..\gobject\glib-mkenums;%(Outputs) + Generating glib-mkenums... + $(GenGLibMKEnums) + ..\..\..\gobject\glib-mkenums;%(Outputs) + Generating glib-mkenums... + $(GenGLibMKEnums) + ..\..\..\gobject\glib-mkenums;%(Outputs) + Generating glib-mkenums... + $(GenGLibMKEnums) + ..\..\..\gobject\glib-mkenums;%(Outputs) + + @@ -191,4 +207,4 @@ - \ No newline at end of file + diff --git a/build/win32/vs9/glib-gen-srcs.vsprops b/build/win32/vs9/glib-gen-srcs.vsprops index 7df2d21b0..be94d2d2d 100644 --- a/build/win32/vs9/glib-gen-srcs.vsprops +++ b/build/win32/vs9/glib-gen-srcs.vsprops @@ -7,26 +7,22 @@ > + diff --git a/build/win32/vs9/glib-install.vsprops b/build/win32/vs9/glib-install.vsprops index 11fdeb907..4783f8b91 100644 --- a/build/win32/vs9/glib-install.vsprops +++ b/build/win32/vs9/glib-install.vsprops @@ -20,6 +20,7 @@ copy $(SolutionDir)$(ConfigurationName)\$(PlatformName)\bin\gresource.exe $(Copy copy $(SolutionDir)$(ConfigurationName)\$(PlatformName)\bin\gio-querymodules.exe $(CopyDir)\bin copy $(SolutionDir)$(ConfigurationName)\$(PlatformName)\bin\gdbus.exe $(CopyDir)\bin copy ..\..\..\gio\gdbus-2.0\codegen\gdbus-codegen.in $(CopyDir)\bin\gdbus-codegen +if exist ..\..\..\gobject\glib-mkenums copy ..\..\..\gobject\glib-mkenums $(CopyDir)\bin mkdir $(CopyDir)\include\glib-$(ApiVersion)\glib\deprecated mkdir $(CopyDir)\include\glib-$(ApiVersion)\gobject diff --git a/build/win32/vs9/glib-version-paths.vsprops b/build/win32/vs9/glib-version-paths.vsprops index e2eb5b7c4..33b276c00 100644 --- a/build/win32/vs9/glib-version-paths.vsprops +++ b/build/win32/vs9/glib-version-paths.vsprops @@ -46,4 +46,8 @@ Name="GlibDllSuffix" Value="$(GlibSeparateVSDllSuffix)" /> + diff --git a/build/win32/vs9/gobject.vcprojin b/build/win32/vs9/gobject.vcprojin index e02fe0dca..bf9149220 100644 --- a/build/win32/vs9/gobject.vcprojin +++ b/build/win32/vs9/gobject.vcprojin @@ -21,7 +21,7 @@ @@ -51,7 +51,7 @@ @@ -113,7 +113,7 @@ + + + + + + + + + + + + + +