[atk] Enable the building of introspection files for Visual C++ builds
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [atk] Enable the building of introspection files for Visual C++ builds
- Date: Wed, 6 Mar 2013 04:17:28 +0000 (UTC)
commit eae9d1da36bc432b6396faac01d9dc86aba68aa3
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Feb 20 18:13:11 2013 +0800
Enable the building of introspection files for Visual C++ builds
This adds the utility Python/.bat scripts to the distribution for building
the introspection files for ATK, and adds utility projects to build those
files when needed.
This makes use of Python Regex functionality so that we can read directly
from the autotools files to create the file list that is necessary to
build the introspection files, without needing to modify the autotools
files to create the file list.
build/win32/Makefile.am | 4 ++
build/win32/gen-file-list-atk.py | 112 ++++++++++++++++++++++++++++++++++++++
build/win32/gengir.bat | 6 ++-
build/win32/vs10/Makefile.am | 3 +-
build/win32/vs10/gengir.vcxproj | 104 +++++++++++++++++++++++++++++++++++
build/win32/vs9/Makefile.am | 3 +-
build/win32/vs9/gengir.vcproj | 77 ++++++++++++++++++++++++++
7 files changed, 306 insertions(+), 3 deletions(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index e013d16..4eff83d 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -1,3 +1,7 @@
SUBDIRS = \
vs9 \
vs10
+
+EXTRA_DIST = \
+ gengir.bat \
+ gen-file-list-atk.py
diff --git a/build/win32/gen-file-list-atk.py b/build/win32/gen-file-list-atk.py
new file mode 100644
index 0000000..8729c90
--- /dev/null
+++ b/build/win32/gen-file-list-atk.py
@@ -0,0 +1,112 @@
+#!/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_atk_filelist(srcroot, subdir, dest):
+ vars = read_vars_from_AM(os.path.join(srcroot, subdir, 'Makefile.am'),
+ vars = {'top_builddir':'.'},
+ conds = {'HAVE_INTROSPECTION':True},
+ filters = ['introspection_sources', 'introspection_generated_sources'])
+
+ files = vars['introspection_sources'].split() + \
+ vars['introspection_generated_sources'].split()
+
+ with open(dest, 'w') as d:
+ for i in files:
+ if (i.startswith('./atk/')):
+ i = i.replace('./atk/','')
+ 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:
+ 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 = '..\\..'
+ subdir = 'atk'
+ gen_atk_filelist(srcroot, subdir, 'atk_list')
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
diff --git a/build/win32/gengir.bat b/build/win32/gengir.bat
index f85adc6..b843415 100644
--- a/build/win32/gengir.bat
+++ b/build/win32/gengir.bat
@@ -46,6 +46,9 @@ set LIB=%BINDIR%;%BASEDIR%\lib;%LIB%
set PATH=%BINDIR%;%BASEDIR%\bin;%PATH%;%MINGWDIR%\bin
set PYTHONPATH=%BASEDIR%\lib\gobject-introspection;%BINDIR%
+echo Create filelist for generating ATK .gir's...
+call python gen-file-list-atk.py
+
echo Setup .bat for generating ATK .gir's...
rem =================================================================================================
@@ -81,8 +84,9 @@ rem Now generate the .gir's
rem =======================
CALL atk_gir.bat
-rem Clean up the .bat for generating the .gir files...
+rem Clean up the .bat/filelist for generating the .gir files...
del atk_gir.bat
+del atk_list
rem Now compile the generated .gir files
%BASEDIR%\bin\g-ir-compiler --includedir=. --debug --verbose Atk-1.0.gir -o Atk-1.0.typelib
diff --git a/build/win32/vs10/Makefile.am b/build/win32/vs10/Makefile.am
index 217d7d2..ef3f2b4 100644
--- a/build/win32/vs10/Makefile.am
+++ b/build/win32/vs10/Makefile.am
@@ -6,4 +6,5 @@ EXTRA_DIST = \
atk.vcxprojin \
atk.vcxproj.filters \
atk.vcxproj.filtersin \
- install.vcxproj
+ install.vcxproj \
+ gengir.vcxproj
diff --git a/build/win32/vs10/gengir.vcxproj b/build/win32/vs10/gengir.vcxproj
new file mode 100644
index 0000000..b0692fd
--- /dev/null
+++ b/build/win32/vs10/gengir.vcxproj
@@ -0,0 +1,104 @@
+<?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="atk.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="atk.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="atk.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="atk.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="atk.vcxproj">
+ <Project>{86eacd59-f69f-4aad-854b-aa03d5447360}</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 f215e4b..b707f2c 100644
--- a/build/win32/vs9/Makefile.am
+++ b/build/win32/vs9/Makefile.am
@@ -4,4 +4,5 @@ EXTRA_DIST = \
atk.vsprops \
atk.vcproj \
atk.vcprojin \
- install.vcproj
+ install.vcproj \
+ gengir.vcproj
diff --git a/build/win32/vs9/gengir.vcproj b/build/win32/vs9/gengir.vcproj
new file mode 100644
index 0000000..5534388
--- /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=".\atk.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ InheritedPropertySheets=".\atk.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ InheritedPropertySheets=".\atk.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ InheritedPropertySheets=".\atk.vsprops"
+ OutputDirectory="$(GlibEtcInstallRoot)"
+ ConfigurationType="10"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ DeleteExtensionsOnClean=""
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine="$(DoGenGir)"
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioProject>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]