diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-08-08 17:39:22 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2014-08-08 17:39:48 +0800 |
commit | 3d89041220a2a783b5706763b35778f9154c0883 (patch) | |
tree | 8535e7070cfe3663c60327c7d1288d14ffb880d2 | |
parent | 3e2735f4680b9f46548e7d039b0241cd24aee162 (diff) |
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.
-rw-r--r-- | build/win32/Makefile.am | 3 | ||||
-rw-r--r-- | build/win32/process_in_win32.py | 77 | ||||
-rw-r--r-- | build/win32/setup.py | 35 | ||||
-rw-r--r-- | build/win32/vs10/glib-gen-srcs.props | 4 | ||||
-rw-r--r-- | build/win32/vs10/glib-install.props | 2 | ||||
-rw-r--r-- | build/win32/vs10/glib-version-paths.props | 4 | ||||
-rw-r--r-- | build/win32/vs10/gobject.vcxproj.filtersin | 5 | ||||
-rw-r--r-- | build/win32/vs10/gobject.vcxprojin | 26 | ||||
-rw-r--r-- | build/win32/vs9/glib-gen-srcs.vsprops | 20 | ||||
-rw-r--r-- | build/win32/vs9/glib-install.vsprops | 1 | ||||
-rw-r--r-- | build/win32/vs9/glib-version-paths.vsprops | 4 | ||||
-rw-r--r-- | build/win32/vs9/gobject.vcprojin | 42 |
12 files changed, 167 insertions, 56 deletions
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 @@ <GenGLibConfigH>copy ..\..\..\glib\glibconfig.h.win32 ..\..\..\glib\glibconfig.h</GenGLibConfigH> <GenGModuleConfH>copy ..\..\..\gmodule\gmoduleconf.h.win32 ..\..\..\gmodule\gmoduleconf.h</GenGModuleConfH> <GenGNetworkingH>copy ..\..\..\gio\gnetworking.h.win32 ..\..\..\gio\gnetworking.h</GenGNetworkingH> + <GenGLibMKEnums>if exist $(PythonPath)\python.exe $(PythonPath)\python.exe ..\process_in_win32.py --glib-mkenums</GenGLibMKEnums> </PropertyGroup> <PropertyGroup> <_PropertySheetDisplayName>glibgensrcsprops</_PropertySheetDisplayName> @@ -25,5 +26,8 @@ <BuildMacro Include="GenGNetworkingH"> <Value>$(GenGNetworkingH)</Value> </BuildMacro> + <BuildMacro Include="GenGLibMKEnums"> + <Value>$(GenGLibMKEnums)</Value> + </BuildMacro> </ItemGroup> </Project>
\ 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 @@ <GlibSeparateVSDllSuffix>-2-vs$(VSVer)</GlibSeparateVSDllSuffix> <GlibDllPrefix>$(GlibSeparateVSDllPrefix)</GlibDllPrefix> <GlibDllSuffix>$(GlibSeparateVSDllSuffix)</GlibDllSuffix> + <PythonPath>c:\python27</PythonPath> </PropertyGroup> <PropertyGroup> <_PropertySheetDisplayName>glibversionpathsprops</_PropertySheetDisplayName> @@ -46,5 +47,8 @@ <BuildMacro Include="GlibDllSuffix"> <Value>$(GlibDllSuffix)</Value> </BuildMacro> + <BuildMacro Include="PythonPath"> + <Value>$(PythonPath)</Value> + </BuildMacro> </ItemGroup> </Project>
\ 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 @@ -18,8 +18,11 @@ #include "libgobject.vs10.sourcefiles.filters" </ItemGroup> <ItemGroup> + <CustomBuild Include="..\..\..\gobject\glib-mkenums.in"><Filter>Resource Files</Filter></CustomBuild> + </ItemGroup> + <ItemGroup> <ResourceCompile Include="..\..\..\gobject\gobject.rc"> <Filter>Resource Files</Filter> </ResourceCompile> </ItemGroup> -</Project>
\ No newline at end of file +</Project> 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 @@ </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="glib-build-defines.props" /> + <Import Project="glib-gen-srcs.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="glib-build-defines.props" /> + <Import Project="glib-gen-srcs.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="glib-build-defines.props" /> + <Import Project="glib-gen-srcs.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="glib-build-defines.props" /> + <Import Project="glib-gen-srcs.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> @@ -176,6 +176,22 @@ #include "libgobject.vs10.sourcefiles" </ItemGroup> <ItemGroup> + <CustomBuild Include="..\..\..\gobject\glib-mkenums.in"> + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Generating glib-mkenums...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(GenGLibMKEnums)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\..\..\gobject\glib-mkenums;%(Outputs)</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Generating glib-mkenums...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(GenGLibMKEnums)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\..\..\gobject\glib-mkenums;%(Outputs)</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Generating glib-mkenums...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(GenGLibMKEnums)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\..\..\gobject\glib-mkenums;%(Outputs)</Outputs> + <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Generating glib-mkenums...</Message> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(GenGLibMKEnums)</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\..\gobject\glib-mkenums;%(Outputs)</Outputs> + </CustomBuild> + </ItemGroup> + <ItemGroup> <ResourceCompile Include="..\..\..\gobject\gobject.rc" /> </ItemGroup> <ItemGroup> @@ -191,4 +207,4 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> -</Project>
\ No newline at end of file +</Project> 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 @@ > <UserMacro Name="GenConfigH" - Value=" -copy ..\..\..\config.h.win32 ..\..\..\config.h - " + Value="copy ..\..\..\config.h.win32 ..\..\..\config.h" /> <UserMacro Name="GenGLibConfigH" - Value=" -copy ..\..\..\glib\glibconfig.h.win32 ..\..\..\glib\glibconfig.h - " + Value="copy ..\..\..\glib\glibconfig.h.win32 ..\..\..\glib\glibconfig.h" /> <UserMacro Name="GenGModuleConfH" - Value=" -copy ..\..\..\gmodule\gmoduleconf.h.win32 ..\..\..\gmodule\gmoduleconf.h - " + Value="copy ..\..\..\gmodule\gmoduleconf.h.win32 ..\..\..\gmodule\gmoduleconf.h" /> <UserMacro Name="GenGNetworkingH" - Value=" -copy ..\..\..\gio\gnetworking.h.win32 ..\..\..\gio\gnetworking.h - " + Value="copy ..\..\..\gio\gnetworking.h.win32 ..\..\..\gio\gnetworking.h" + /> + <UserMacro + Name="GenGLibMKEnums" + Value="if exist $(PythonPath)\python.exe $(PythonPath)\python.exe ..\process_in_win32.py --glib-mkenums" /> </VisualStudioPropertySheet> 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)" /> + <UserMacro + Name="PythonPath" + Value="c:\python27" + /> </VisualStudioPropertySheet> 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 @@ <Configurations> <Configuration Name="Debug|Win32" - InheritedPropertySheets=".\glib-build-defines.vsprops" + InheritedPropertySheets=".\glib-gen-srcs.vsprops" ConfigurationType="2" CharacterSet="2" > @@ -51,7 +51,7 @@ </Configuration> <Configuration Name="Release|Win32" - InheritedPropertySheets=".\glib-build-defines.vsprops" + InheritedPropertySheets=".\glib-gen-srcs.vsprops" ConfigurationType="2" CharacterSet="2" WholeProgramOptimization="1" @@ -83,7 +83,7 @@ </Configuration> <Configuration Name="Debug|x64" - InheritedPropertySheets=".\glib-build-defines.vsprops" + InheritedPropertySheets=".\glib-gen-srcs.vsprops" ConfigurationType="2" CharacterSet="2" > @@ -113,7 +113,7 @@ </Configuration> <Configuration Name="Release|x64" - InheritedPropertySheets=".\glib-build-defines.vsprops" + InheritedPropertySheets=".\glib-gen-srcs.vsprops" ConfigurationType="2" CharacterSet="2" WholeProgramOptimization="1" @@ -165,6 +165,40 @@ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > + <File RelativePath="..\..\..\gobject\glib-mkenums.in"> + <FileConfiguration Name="Debug|Win32"> + <Tool + Name="VCCustomBuildTool" + Description="Generating glib-mkenums..." + CommandLine="$(GenGLibMKEnums)" + Outputs="..\..\..\gobject\glib-mkenums" + /> + </FileConfiguration> + <FileConfiguration Name="Release|Win32"> + <Tool + Name="VCCustomBuildTool" + Description="Generating glib-mkenums..." + CommandLine="$(GenGLibMKEnums)" + Outputs="..\..\..\gobject\glib-mkenums" + /> + </FileConfiguration> + <FileConfiguration Name="Debug|x64"> + <Tool + Name="VCCustomBuildTool" + Description="Generating glib-mkenums..." + CommandLine="$(GenGLibMKEnums)" + Outputs="..\..\..\gobject\glib-mkenums" + /> + </FileConfiguration> + <FileConfiguration Name="Release|x64"> + <Tool + Name="VCCustomBuildTool" + Description="Generating glib-mkenums..." + CommandLine="$(GenGLibMKEnums)" + Outputs="..\..\..\gobject\glib-mkenums" + /> + </FileConfiguration> + </File> <File RelativePath="..\..\..\gobject\gobject.rc" /> </Filter> </Files> |