[gobject-introspection] Visual Studio builds: Process cairo-1.0.gir.in



commit f196c61b1691bb063a27289438c6ecdf247af798
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Mar 12 17:36:37 2013 +0800

    Visual Studio builds: Process cairo-1.0.gir.in
    
    Use a simple Python script that uses Python REGEX abilities to create
    cairo-1.0.gir from cairo-1.0.gir.in with the correct values for Cairo, for
    use in the Visual Studio builds of g-i.  It can be later extended if
    needed.
    
    Also dist this, and call this script from gengir.bat so that cairo-1.0.gir
    and cairo-1.0.typelib can be built and "installed"
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692165

 build/win32/Makefile.am           |    1 +
 build/win32/create_nonglib_gir.py |   72 +++++++++++++++++++++++++++++++++++++
 build/win32/gengir.bat            |    2 +
 3 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index 499c5cf..f404aa1 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -5,6 +5,7 @@ EXTRA_DIST = \
        everything.def  \
        foo.def \
        gengir.bat      \
+       create_nonglib_gir.py   \
        gettype.def     \
        gimarshallingtests.def  \
        gtkfrob.def     \
diff --git a/build/win32/create_nonglib_gir.py b/build/win32/create_nonglib_gir.py
new file mode 100644
index 0000000..e3df714
--- /dev/null
+++ b/build/win32/create_nonglib_gir.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+#
+# Expand the bundled *.gir.in files
+# for use in Visual C++ builds of G-I
+#
+# Author: Fan, Chun-wei
+# Date: January 21, 2013
+#
+# (Adapted from setup.py in
+# $(glib_src_root)/build/win32/setup.py written by Shixin Zeng)
+
+import os
+import sys
+import re
+import string
+import subprocess
+import optparse
+
+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_vsver(vsver):
+    return {
+        '9': '9',
+        '10': '10',
+        '11': '11',
+        '2008': '9',
+        '2010': '10',
+        '2012': '11',
+        }.get(vsver, '0')
+
+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]
+
+def setup_vars_cairo(src, dest, vsver):
+    vars = {}
+    vars['CAIRO_GIR_PACKAGE'] = 'cairo-gobject'
+    vars['CAIRO_SHARED_LIBRARY'] = '%s-vs%s.dll' % (vars['CAIRO_GIR_PACKAGE'], vsver)
+    process_in (src, dest, vars)
+
+def main(argv):
+    parser = optparse.OptionParser()
+    parser.add_option('--vsver', dest='vsver', action='store', help='Version of Visual Studio used, 9 or 
2008 for VS 2008, 10 or 2010 for VS2010, 11 or 2012 for VS2012')
+    opt, args = parser.parse_args(argv)
+    if opt.vsver is None:
+        print ('vsver must be specified.  Please use %s -h to see the valid values' % 
os.path.basename(__file__))
+        sys.exit()
+    vsver = get_vsver(opt.vsver)
+    if vsver is '0':
+        print ('You must specify a valid vsver.  Please use %s -h to see the valid values' % 
os.path.basename(__file__))
+        sys.exit()
+
+    # Get the srcroot and the path where the bundled .gir files reside in the package
+    srcroot = parent_dir(parent_dir(__file__))
+    preset_gir_path = os.path.join(srcroot, 'gir')
+
+    # Set up variables in cairo-1.0.gir.in to produce cairo-1.0.gir
+    setup_vars_cairo(os.path.join(preset_gir_path, 'cairo-1.0.gir.in'),
+                     os.path.join(preset_gir_path, 'cairo-1.0.gir'),
+                     vsver)
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv))
diff --git a/build/win32/gengir.bat b/build/win32/gengir.bat
index 70c5b85..c5984cb 100644
--- a/build/win32/gengir.bat
+++ b/build/win32/gengir.bat
@@ -257,8 +257,10 @@ g-ir-compiler --includedir=. --debug --verbose Gio-2.0.gir -o Gio-2.0.typelib
 g-ir-compiler --includedir=. --debug --verbose GIRepository-2.0.gir -o GIRepository-2.0.typelib
 
 rem Now process the bundled .gir files
+python create_nonglib_gir.py --vsver=%VSVER%
 set CURRDIR=%CD%
 cd ..\..\gir
+g-ir-compiler --includedir=. --debug --verbose cairo-1.0.gir -o cairo-1.0.typelib
 g-ir-compiler --includedir=. --debug --verbose freetype2-2.0.gir -o freetype2-2.0.typelib
 g-ir-compiler --includedir=. --debug --verbose GL-1.0.gir -o GL-1.0.typelib
 g-ir-compiler --includedir=. --debug --verbose libxml2-2.0.gir -o libxml2-2.0.typelib


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