[vala] Fix build for Windows



commit fd2b222a9ad7382bf0f802d50a9702d455195ef3
Author: Arnel A. Borja <kyoushuu yahoo com>
Date:   Sun Sep 30 18:33:56 2012 +0800

    Fix build for Windows
    
    - Replace POSIX calls for spawning process with functions from Windows
      API when compiling for Windows
    - Add EXEEXT to valac and vapigen paths
    - Remove EXEEXT from scripts
    
    Fixes bug 685180.

 Makefile.am                             |    2 +-
 gobject-introspection/scanner.c         |   21 ++++++++++++++++++++-
 tests/testrunner.sh                     |    4 ++--
 vapi/Makefile.am                        |    2 +-
 vapigen/Makefile.am                     |    2 +-
 vapigen/vala-gen-introspect/Makefile.am |    2 +-
 6 files changed, 26 insertions(+), 7 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 3a8fc6c..12e50df 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,7 @@ libvala PACKAGE_SUFFIX@.pc: libvala.pc
 .PHONY: bootstrap
 bootstrap: all
 	find $(top_srcdir) -name "*.vala.stamp" | xargs rm -f
-	$(MAKE) $(AM_MAKEFLAGS) all VALAC=$(abs_top_builddir)/compiler/valac V=$V
+	$(MAKE) $(AM_MAKEFLAGS) all VALAC=$(abs_top_builddir)/compiler/valac$(EXEEXT) V=$V
 
 .PHONY: test
 test:
diff --git a/gobject-introspection/scanner.c b/gobject-introspection/scanner.c
index dcaa01c..ced13f4 100644
--- a/gobject-introspection/scanner.c
+++ b/gobject-introspection/scanner.c
@@ -31,7 +31,6 @@
 #include <glib/gstdio.h>
 #include <glib-object.h>
 #include <signal.h>
-#include <sys/wait.h> /* waitpid */
 #include <gmodule.h>
 #include "scanner.h"
 #include "gidlparser.h"
@@ -40,6 +39,10 @@
 #include "gidlwriter.h"
 #include "grealpath.h"
 
+#ifndef _WIN32
+#include <sys/wait.h> /* waitpid */
+#endif
+
 
 typedef GType (*TypeFunction) (void);
 
@@ -1600,12 +1603,28 @@ g_igenerator_start_preprocessor (GIGenerator *igenerator,
 
   close (cpp_out);
 
+#ifndef _WIN32
   if (waitpid (pid, &status, 0) > 0)
+#else
+  /* We don't want to include <windows.h> as it clashes horribly
+   * with token names from scannerparser.h. So just declare
+   * WaitForSingleObject, GetExitCodeProcess and INFINITE here.
+   */
+  extern unsigned long __stdcall WaitForSingleObject(void*, int);
+  extern int __stdcall GetExitCodeProcess(void*, int*);
+#define INFINITE 0xffffffff
+
+  WaitForSingleObject (pid, INFINITE);
+
+  if (GetExitCodeProcess (pid, &status))
+#endif
     {
       if (status != 0)
 	{
 	  g_spawn_close_pid (pid);
+#ifndef _WIN32
 	  kill (pid, SIGKILL);
+#endif
 
 	  g_error ("cpp returned error code: %d\n", status);
 	  unlink (tmpname);
diff --git a/tests/testrunner.sh b/tests/testrunner.sh
index 02948c1..8d47808 100755
--- a/tests/testrunner.sh
+++ b/tests/testrunner.sh
@@ -28,9 +28,9 @@ vapidir=$topsrcdir/vapi
 
 export G_DEBUG=fatal_warnings
 
-VALAC=$topbuilddir/compiler/valac
+VALAC=$topbuilddir/compiler/valac$EXEEXT
 VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -g -X -O0 -X -pipe -X -lm -X -Werror=return-type -X -Werror=init-self -X -Werror=implicit -X -Werror=sequence-point -X -Werror=return-type -X -Werror=uninitialized -X -Werror=pointer-arith -X -Werror=int-to-pointer-cast -X -Werror=pointer-to-int-cast"
-VAPIGEN=$topbuilddir/vapigen/vapigen
+VAPIGEN=$topbuilddir/vapigen/vapigen$EXEEXT
 VAPIGENFLAGS="--vapidir $vapidir"
 
 # Incorporate the user's CFLAGS. Matters if the user decided to insert
diff --git a/vapi/Makefile.am b/vapi/Makefile.am
index 8c09365..d474ac3 100644
--- a/vapi/Makefile.am
+++ b/vapi/Makefile.am
@@ -394,7 +394,7 @@ GIR_BINDINGS = \
 
 BINDINGS = $(GIR_BINDINGS) $(GIDL_BINDINGS)
 
-VAPIGEN = $(top_builddir)/vapigen/vapigen
+VAPIGEN = $(top_builddir)/vapigen/vapigen$(EXEEXT)
 VAPIGENFLAGS = --vapidir $(srcdir)
 GENVAPI = $(VAPIGEN) $(VAPIGENFLAGS)
 METADATADIR = $(srcdir)/metadata
diff --git a/vapigen/Makefile.am b/vapigen/Makefile.am
index 8460a5e..bc8539a 100644
--- a/vapigen/Makefile.am
+++ b/vapigen/Makefile.am
@@ -1,6 +1,6 @@
 NULL =
 
-VALAC = $(top_builddir)/compiler/valac
+VALAC = $(top_builddir)/compiler/valac$(EXEEXT)
 
 SUBDIRS = \
 	vala-gen-introspect \
diff --git a/vapigen/vala-gen-introspect/Makefile.am b/vapigen/vala-gen-introspect/Makefile.am
index 4f0c471..854cb9d 100644
--- a/vapigen/vala-gen-introspect/Makefile.am
+++ b/vapigen/vala-gen-introspect/Makefile.am
@@ -10,5 +10,5 @@ EXTRA_DIST = \
 
 if ENABLE_UNVERSIONED
 install-exec-hook:
-	cd $(DESTDIR)$(bindir) && $(LN_S) -f vala-gen-introspect PACKAGE_SUFFIX@$(EXEEXT) vala-gen-introspect$(EXEEXT)
+	cd $(DESTDIR)$(bindir) && $(LN_S) -f vala-gen-introspect PACKAGE_SUFFIX@ vala-gen-introspect
 endif



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