Visual Studio 201x builds: Generate gtk/gtktypefuncs.c

We now need to generate gtktypefuncs.c by ourselves, so modify the
gentypefuncs.py script from master, and add a custom build step in the
projects to generate gtktypefuncs.c.  The custom build step for the 2008
projects will be added later.
This commit is contained in:
Chun-wei Fan 2018-05-12 01:12:23 +08:00
parent 7b3129ad4f
commit 1517acee55
5 changed files with 72 additions and 1 deletions

View File

@ -36,8 +36,9 @@ SUBDIRS = \
EXTRA_DIST += \
detectenv-msvc.mak \
introspection-msvc.mak \
gentypefuncs.py \
gtk-introspection-msvc.mak \
introspection-msvc.mak \
replace.py \
pc_base.py \
gtkpc.py \

View File

@ -0,0 +1,53 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import re
import os
debug = os.getenv('GTK_GENTYPEFUNCS_DEBUG') is not None
out_file = sys.argv[1]
in_file = sys.argv[2]
funcs = []
if debug: print ('Output file: ', out_file)
# if debug: print (len(in_files), 'input files')
def open_file(filename, mode):
if sys.version_info[0] < 3:
return open(filename, mode=mode)
else:
return open(filename, mode=mode, encoding='utf-8')
with open(in_file, 'r') as f:
for line in f:
line = line.rstrip('\n').rstrip('\r')
# print line
match = re.search(r'\bg[td]k_[a-zA-Z0-9_]*_get_type\b', line)
if match:
func = match.group(0)
if not func in funcs:
funcs.append(func)
if debug: print ('Found ', func)
file_output = 'G_GNUC_BEGIN_IGNORE_DEPRECATIONS\n'
funcs = sorted(funcs)
for f in funcs:
if f.startswith('gdk_x11') or f.startswith('gtk_socket') or f.startswith('gtk_plug'):
file_output += '#ifdef GDK_WINDOWING_X11\n'
file_output += '*tp++ = {0}();\n'.format(f)
file_output += '#endif\n'
else:
file_output += '*tp++ = {0}();\n'.format(f)
if debug: print (len(funcs), 'functions')
ofile = open(out_file, "w")
ofile.write(file_output)
ofile.close()

View File

@ -21,6 +21,7 @@
<CustomBuild Include="..\..\..\gtk\gtkdbusinterfaces.xml"><Filter>Resource Files</Filter></CustomBuild>
<CustomBuild Include="..\..\..\gtk\gtk-win32.rc.body"><Filter>Resource Files</Filter></CustomBuild>
<CustomBuild Include="..\..\..\gtk\libgtk3.manifest.in"><Filter>Resource Files</Filter></CustomBuild>
<CustomBuild Include="..\gentypefuncs.py"><Filter>Resource Files</Filter></CustomBuild>
</ItemGroup>
<ItemGroup>
#include "gtk-3.vs10.sourcefiles.filters"

View File

@ -205,6 +205,12 @@
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(GenerateGtkWin32Manifest)</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\..\gtk\libgtk3.manifest;%(Outputs)</Outputs>
</CustomBuild>
<CustomBuild Include="..\gentypefuncs.py">
<Message>Generating ..\..\..\gtk\gtktypefuncs.c</Message>
<Command Condition="'$(Platform)'=='Win32'">$(GenerateTypeFuncs)</Command>
<Command Condition="'$(Platform)'=='x64'">$(GenerateTypeFuncs)</Command>
<Outputs>..\..\..\gtk\gtktypefuncs.c</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\gtk\gtk-win32.rc" />

View File

@ -44,6 +44,13 @@ echo $(Configuration) &gt; ..\..\..\MSVC_$(Configuration)_Broadway
<CopyGtkWin32RC>copy ..\..\..\gtk\gtk-win32.rc.body ..\..\..\gtk\gtk-win32.rc</CopyGtkWin32RC>
<GenerateGtkWin32Manifest>$(PythonDir)\python ..\replace.py --action=replace-var --input=..\..\..\gtk\libgtk3.manifest.in --output=..\..\..\gtk\libgtk3.manifest --var=EXE_MANIFEST_ARCHITECTURE --outstring=*</GenerateGtkWin32Manifest>
<CopyDemosH>copy ..\..\..\demos\gtk-demo\demos.h.win32 ..\..\..\demos\gtk-demo\demos.h</CopyDemosH>
<GenerateTypeFuncs>
echo #undef GTK_COMPILATION &gt; ..\..\..\gtk\gtktypefuncs.preproc.c
echo #include "gtk.h" &gt;&gt; ..\..\..\gtk\gtktypefuncs.preproc.c
cl /EP /I..\..\..\gtk /I..\..\..\gdk /I..\..\..\gdk\win32 /I..\..\.. /I$(GlibEtcInstallRoot)\include\gdk-pixbuf-2.0 /I$(GlibEtcInstallRoot)\include\pango-1.0 /I$(GlibEtcInstallRoot)\include\atk-1.0 /I$(GlibEtcInstallRoot)\include\cairo /I$(GlibEtcInstallRoot)\include\gio-win32-2.0 /I$(GlibEtcInstallRoot)\include\glib-2.0 /I$(GlibEtcInstallRoot)\lib\glib-2.0\include /I$(GlibEtcInstallRoot)\include /DHAVE_CONFIG_H /DG_DISABLE_SINGLE_INCLUDES /DATK_DISABLE_SINGLE_INCLUDES /DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES /DGTK_DISABLE_SINGLE_INCLUDES /D_USE_MATH_DEFINES /DINCLUDE_IM_am_et /DINCLUDE_IM_cedilla /DINCLUDE_IM_cyrillic_translit /DINCLUDE_IM_ime /DINCLUDE_IM_inuktitut /DINCLUDE_IM_ipa /DINCLUDE_IM_multipress /DINCLUDE_IM_thai /DINCLUDE_IM_ti_er /DINCLUDE_IM_ti_et /DINCLUDE_IM_viqr /DGTK_COMPILATION /DG_LOG_DOMAIN=\"Gtk\" /DGTK_HOST=\"i686-pc-vs$(VSVer)\" /DGTK_PRINT_BACKENDS=\"file\" /DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED /D$(GtkIncludedImmodulesDefines) /DGTK_LIBDIR=\"$(GtkDummyPrefix)/lib\" /DGTK_DATADIR=\"$(GtkDummyPrefix)/share\" /DGTK_DATA_PREFIX=\"$(GtkDummyPrefix)\" /DGTK_SYSCONFDIR=\"$(GtkDummyPrefix)/etc\" /DMULTIPRESS_CONFDIR=\"$(GtkDummyPrefix)/etc/gtk-$(ApiVersion)\" /DMULTIPRESS_LOCALEDIR=\"$(GtkDummyPrefix)/share/locale\" /DGTK_VERSION=\"$(GtkVersion)\" /DGTK_BINARY_VERSION=\"$(GtkBinaryVersion)\" /DGDK_DISABLE_DEPRECATED /DISOLATION_AWARE_ENABLED ..\..\..\gtk\gtktypefuncs.preproc.c &gt; ..\..\..\gtk\gtktypefuncs.combined.c
$(PythonDir)\python ..\gentypefuncs.py ..\..\..\gtk\gtktypefuncs.c ..\..\..\gtk\gtktypefuncs.combined.c
del ..\..\..\gtk\gtktypefuncs.combined.c ..\..\..\gtk\gtktypefuncs.preproc.c
</GenerateTypeFuncs>
</PropertyGroup>
<PropertyGroup>
<_PropertySheetDisplayName>gtk3gensrcsprops</_PropertySheetDisplayName>
@ -76,5 +83,8 @@ echo $(Configuration) &gt; ..\..\..\MSVC_$(Configuration)_Broadway
<BuildMacro Include="CopyDemosH">
<Value>$(CopyDemosH)</Value>
</BuildMacro>
<BuildMacro Include="GenerateTypeFuncs">
<Value>$(GenerateTypeFuncs)</Value>
</BuildMacro>
</ItemGroup>
</Project>