mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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.
This commit is contained in:
parent
3e2735f468
commit
3d89041220
@ -7,4 +7,5 @@ SUBDIRS = \
|
||||
|
||||
EXTRA_DIST = \
|
||||
make.msc \
|
||||
module.defs
|
||||
module.defs \
|
||||
process_in_win32.py
|
||||
|
77
build/win32/process_in_win32.py
Normal file
77
build/win32/process_in_win32.py
Normal file
@ -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))
|
@ -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
|
||||
|
@ -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>
|
@ -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
|
||||
|
||||
|
@ -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>
|
@ -17,9 +17,12 @@
|
||||
<ItemGroup>
|
||||
#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>
|
||||
</Project>
|
||||
|
@ -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>
|
||||
@ -175,6 +175,22 @@
|
||||
<ItemGroup>
|
||||
#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>
|
||||
@ -191,4 +207,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -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>
|
||||
|
@ -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

|
||||
|
@ -46,4 +46,8 @@
|
||||
Name="GlibDllSuffix"
|
||||
Value="$(GlibSeparateVSDllSuffix)"
|
||||
/>
|
||||
<UserMacro
|
||||
Name="PythonPath"
|
||||
Value="c:\python27"
|
||||
/>
|
||||
</VisualStudioPropertySheet>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user