[Cogl] [PATCH] Visual Studio Builds: Support building introspection files

Fan Chun-wei fanc999 at yahoo.com.tw
Wed Mar 6 19:53:00 PST 2013


Add Windows .bat and Python script to call g-ir-scanner to build
introspection files for Visual Studio builds. This will read from the
autotools files using Python REGEX functionality to determine the headers
and sources for g-ir-scanner to process, so the autotools files will not
need to be updated except to distribute the necessary files.

Thils will also enable one to build introspection files on Windows
without using a BASH-style shell such as MSYS.

Also add an utility Visual Studio project to call the Windows .bat to
build the introspection files for Cogl/Cogl-Pango, for convenience.
---
build/win32/Makefile.am | 4 +-
build/win32/gen-file-list-cogl.py | 124 
+++++++++++++++++++++++++++++++++++++
build/win32/vs10/Makefile.am | 1 +
build/win32/vs10/gengir.vcxproj | 108 ++++++++++++++++++++++++++++++++
build/win32/vs9/Makefile.am | 1 +
build/win32/vs9/gengir.vcproj | 77 +++++++++++++++++++++++
6 files changed, 314 insertions(+), 1 deletions(-)
create mode 100644 build/win32/gen-file-list-cogl.py
create mode 100644 build/win32/vs10/gengir.vcxproj
create mode 100644 build/win32/vs9/gengir.vcproj

diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index b764e59..f30ee9a 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -1,3 +1,5 @@
SUBDIRS = vs9 vs10

-EXTRA_DIST = *.bat
+EXTRA_DIST = \
+ *.bat \
+ gen-file-list-cogl.py
diff --git a/build/win32/gen-file-list-cogl.py 
b/build/win32/gen-file-list-cogl.py
new file mode 100644
index 0000000..f8285e4
--- /dev/null
+++ b/build/win32/gen-file-list-cogl.py
@@ -0,0 +1,124 @@
+#!/usr/bin/python
+# vim: encoding=utf-8
+# Generate the file lists for processing with g-ir-scanner
+import os
+import sys
+import re
+import string
+import subprocess
+import optparse
+
+def gen_cogl_filelist(srcroot, subdir, dest):
+ vars = read_vars_from_AM(os.path.join(srcroot, subdir, 'Makefile.am'),
+ vars = {'srcdir':'.'},
+ conds = {'HAVE_INTROSPECTION':True},
+ filters = ['Cogl_1_0_gir_FILES'])
+
+ files = vars['Cogl_1_0_gir_FILES'].split()
+
+ with open(dest, 'w') as d:
+ for i in files:
+ if (i.startswith('./')):
+ i = i.replace('./','')
+ d.write(srcroot + '\\' + subdir + '\\' + i.replace('/', '\\') + '\n')
+
+def gen_coglpango_filelist(srcroot, subdir, dest):
+ vars = read_vars_from_AM(os.path.join(srcroot, subdir, 'Makefile.am'),
+ vars = {'srcdir':'.'},
+ conds = {'HAVE_INTROSPECTION':True},
+ filters = ['CoglPango_1_0_gir_FILES'])
+
+ files = vars['CoglPango_1_0_gir_FILES'].split()
+
+ with open(dest, 'w') as d:
+ for i in files:
+ d.write(srcroot + '\\' + subdir + '\\' + i.replace('/', '\\') + '\n')
+
+def read_vars_from_AM(path, vars = {}, conds = {}, filters = None):
+ '''
+ path: path to the Makefile.am
+ vars: predefined variables
+ conds: condition variables for Makefile
+ filters: if None, all variables defined are returned,
+ otherwise, it is a list contains that variables should be returned
+ '''
+ cur_vars = vars.copy()
+ RE_AM_VAR_REF = re.compile(r'\$\((\w+?)\)')
+ RE_AM_VAR = re.compile(r'^\s*(\w+)\s*=(.*)$')
+ RE_AM_INCLUDE = re.compile(r'^\s*include\s+(\w+)')
+ RE_AM_CONTINUING = re.compile(r'\\\s*$')
+ RE_AM_IF = re.compile(r'^\s*if\s+(\w+)')
+ RE_AM_ELSE = re.compile(r'^\s*else')
+ RE_AM_ENDIF = re.compile(r'^\s*endif')
+ def am_eval(cont):
+ return RE_AM_VAR_REF.sub(lambda x: cur_vars.get(x.group(1), ''), cont)
+ with open(path, 'r') as f:
+ contents = f.readlines()
+ #combine continuing lines
+ i = 0
+ ncont = []
+ while i < len(contents):
+ line = contents[i]
+ if RE_AM_CONTINUING.search(line):
+ line = RE_AM_CONTINUING.sub('', line)
+ j = i + 1
+ while j < len(contents) and RE_AM_CONTINUING.search(contents[j]):
+ line += RE_AM_CONTINUING.sub('', contents[j])
+ j += 1
+ else:
+ if j < len(contents):
+ line += contents[j]
+ i = j
+ else:
+ i += 1
+ ncont.append(line)
+
+ #include, var define, var evaluation
+ i = -1
+ skip = False
+ oldskip = []
+ while i < len(ncont) - 1:
+ i += 1
+ line = ncont[i]
+ mo = RE_AM_IF.search(line)
+ if mo:
+ oldskip.append(skip)
+ skip = False if mo.group(1) in conds and conds[mo.group(1)] \
+ else True
+ continue
+ mo = RE_AM_ELSE.search(line)
+ if mo:
+ skip = not skip
+ continue
+ mo = RE_AM_ENDIF.search(line)
+ if mo:
+ if oldskip:
+ skip = oldskip.pop()
+ continue
+ if not skip:
+ mo = RE_AM_INCLUDE.search(line)
+ if mo:
+ cur_vars.update(read_vars_from_AM(am_eval(mo.group(1)), cur_vars, 
conds, None))
+ continue
+ mo = RE_AM_VAR.search(line)
+ if mo:
+ cur_vars[mo.group(1)] = am_eval(mo.group(2).strip())
+ continue
+
+ #filter:
+ if filters != None:
+ ret = {}
+ for i in filters:
+ ret[i] = cur_vars.get(i, '')
+ return ret
+ else:
+ return cur_vars
+
+def main(argv):
+ srcroot = '..\\..'
+ gen_cogl_filelist(srcroot, 'cogl', 'cogl_list')
+ gen_coglpango_filelist(srcroot, 'cogl-pango', 'coglpango_list')
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/build/win32/vs10/Makefile.am b/build/win32/vs10/Makefile.am
index bfc0d66..f333e2a 100644
--- a/build/win32/vs10/Makefile.am
+++ b/build/win32/vs10/Makefile.am
@@ -26,4 +26,5 @@ EXTRA_DIST = \
test-conformance-cogl.vcxproj.filtersin \
install.vcxproj \
install-sdl.vcxproj \
+ gengir.vcxproj \
README.txt
diff --git a/build/win32/vs10/gengir.vcxproj 
b/build/win32/vs10/gengir.vcxproj
new file mode 100644
index 0000000..bb07f27
--- /dev/null
+++ b/build/win32/vs10/gengir.vcxproj
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" 
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{2093D218-190E-4194-9421-3BA7CBF33B15}</ProjectGuid>
+ <RootNamespace>gengir</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" 
Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" 
Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 
Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" 
Label="Configuration">
+ <ConfigurationType>Utility</ConfigurationType>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" 
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" 
/>
+ <Import Project="cogl.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" 
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" 
/>
+ <Import Project="cogl.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" 
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" 
/>
+ <Import Project="cogl.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" 
Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" 
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" 
/>
+ <Import Project="cogl.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <OutDir 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(GlibEtcInstallRoot)\</OutDir>
+ <ExtensionsToDeleteOnClean 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <OutDir 
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(GlibEtcInstallRoot)\</OutDir>
+ <ExtensionsToDeleteOnClean 
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <OutDir 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(GlibEtcInstallRoot)\</OutDir>
+ <ExtensionsToDeleteOnClean 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <OutDir 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(GlibEtcInstallRoot)\</OutDir>
+ <ExtensionsToDeleteOnClean 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PreBuildEvent>
+ <Command>$(DoGenGir)</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <PreBuildEvent>
+ <Command>$(DoGenGir)</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PreBuildEvent>
+ <Command>$(DoGenGir)</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup 
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <PreBuildEvent>
+ <Command>$(DoGenGir)</Command>
+ </PreBuildEvent>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ProjectReference Include="cogl.vcxproj">
+ <Project>{f3a80987-5411-43db-a23b-06f2076e1206}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ <ProjectReference Include="cogl-pango.vcxproj">
+ <Project>{fe5abd0f-91e8-4aa5-9c1c-408427d5f768}</Project>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file
diff --git a/build/win32/vs9/Makefile.am b/build/win32/vs9/Makefile.am
index 96b0a06..868e079 100644
--- a/build/win32/vs9/Makefile.am
+++ b/build/win32/vs9/Makefile.am
@@ -15,4 +15,5 @@ EXTRA_DIST = \
cogl-info.vcproj \
install.vcproj \
install_sdl.vcproj \
+ gengir.vcproj \
README.txt
diff --git a/build/win32/vs9/gengir.vcproj b/build/win32/vs9/gengir.vcproj
new file mode 100644
index 0000000..1eb1c79
--- /dev/null
+++ b/build/win32/vs9/gengir.vcproj
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="gengir"
+ ProjectGUID="{2093D218-190E-4194-9421-3BA7CBF33B15}"
+ RootNamespace="gengir"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ InheritedPropertySheets=".\cogl.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ InheritedPropertySheets=".\cogl.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ InheritedPropertySheets=".\cogl.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ InheritedPropertySheets=".\cogl.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioProject>
-- 
1.7.7.1.msysgit.0




More information about the Cogl mailing list