[gtk/gtk-3-22] Visual Studio 201x builds: Generate gtk/gtktypefuncs.c



commit 1517acee557b0bed2e4efeb047faf4a2b1e15ef2
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Sat May 12 01:12:23 2018 +0800

    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.

 build/win32/Makefile.am                  |  3 +-
 build/win32/gentypefuncs.py              | 53 ++++++++++++++++++++++++++++++++
 build/win32/vs10/gtk-3.vcxproj.filtersin |  1 +
 build/win32/vs10/gtk-3.vcxprojin         |  6 ++++
 build/win32/vs10/gtk3-gen-srcs.props     | 10 ++++++
 5 files changed, 72 insertions(+), 1 deletion(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index 7ccefa0765..39fed6fe69 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -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                        \
diff --git a/build/win32/gentypefuncs.py b/build/win32/gentypefuncs.py
new file mode 100644
index 0000000000..fd0e8820c0
--- /dev/null
+++ b/build/win32/gentypefuncs.py
@@ -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()
diff --git a/build/win32/vs10/gtk-3.vcxproj.filtersin b/build/win32/vs10/gtk-3.vcxproj.filtersin
index 319d20ab01..71f72d8b65 100644
--- a/build/win32/vs10/gtk-3.vcxproj.filtersin
+++ b/build/win32/vs10/gtk-3.vcxproj.filtersin
@@ -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"
diff --git a/build/win32/vs10/gtk-3.vcxprojin b/build/win32/vs10/gtk-3.vcxprojin
index b6b104cc62..339de636e2 100644
--- a/build/win32/vs10/gtk-3.vcxprojin
+++ b/build/win32/vs10/gtk-3.vcxprojin
@@ -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" />
diff --git a/build/win32/vs10/gtk3-gen-srcs.props b/build/win32/vs10/gtk3-gen-srcs.props
index 74f7edcfc7..7cba9c07a6 100644
--- a/build/win32/vs10/gtk3-gen-srcs.props
+++ b/build/win32/vs10/gtk3-gen-srcs.props
@@ -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=\"$(GtkDummy
 Prefix)/
 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>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]