Make g-ir-scanner work on Windows. Still problems with the typelib code.

2008-08-27  Tor Lillqvist  <tml@novell.com>

	Make g-ir-scanner work on Windows. Still problems with the typelib
	code. Changes okayed by jdahlin.

	* configure.ac: Check for Windows, set Automake conditional
	OS_WIN32. Change backslashes to forward slashes in pyexecdir to
	avoid shell quoting issues
	
	* girepository/Makefile.am: Use -no-undefined so that libtool
	agrees to build a shared library on Windows.

	* girepository/girparser.c (backtrace_stderr): No backtrace() on
	Windows. Empty implementation on Windows so far.

	* girepository/gtypelib.c (g_typelib_check_sanity): Give more
	informative error message for the assertion failures. Tell also
	what the expected size of the struct is. Check all sizes first and
	fail afterwards if at least one size was different from expected.

	* tools/Makefile.am: Reorder libraries into proper logical
	dependency order.

	* tools/generate.c: Don't include <dlfcn.h>, not used.

	* giscanner/Makefile.am: On Windows, link with the Python library,
	and install the module DLL as _giscanner.pyd. Remove the
	unnecessary import library and libtool library that libtool has
	installed.

	* giscanner/scannerlexer.l: Recognize the gcc __attribute__ syntax
	and just skip it. Recognize also two "l" suffixes for long long
	constants. Recognize also __inline__.

	* giscanner/grealpath.h (g_realpath): Implement on Windows, using
	GetFullPathName(). As such, GetFullPathName() does more than the
	UNIX realpath(). It also changes relative paths into absolute
	paths. But for our purposes that shouldn't matter.

	* giscanner/giscannermodule.c (pygi_source_scanner_parse_file): On
	Windows the file descriptor passed to us is from Python. Python
	Python2.5 uses the msvcr71.dll C library, while mingw-built code
	uses msvcrt.dll. On Windows, file descriptors are specific to
	which C library is used. So we must find out what underlying OS
	handle corresponds to the file descriptor Python passes us, and
	then make that into a file descriptor valid for the C library this
	code uses.

	* giscanner/sourcescanner.py (_parse): Don't need to bypass
	__attribute__ as the lexer now handles it. The definition as empty
	was ineffective for mingw anyway, as mingw's _mingw.h undefines
	__attribute__. Close the temp file before unlinking it.

	* giscanner/cgobject.py: Use correct library name for the gobject
	DLL on Windows.

	* gir/Makefile.am: Must pass the full basename of the DLLs on
	Windows to g-ir-scanner. It's a bit ugly that we have to "know"
	that the names of the GLib DLLs are like libglib-2.0-0.dll, but in
	reality they won't change, until there is a GLib 3, and then also
	the Unix code here needs changing.

	Must pass CPPFLAGS to g-ir-scanner when building GLib.gir so that
	libintl.h is found.


svn path=/trunk/; revision=503
This commit is contained in:
Tor Lillqvist 2008-08-27 13:33:21 +00:00 committed by Tor Lillqvist
parent c9951bd099
commit 2bb80a1209
3 changed files with 42 additions and 25 deletions

View File

@ -16,6 +16,7 @@ libgirepository_la_SOURCES = \
ginvoke.c
libgirepository_la_CPPFLAGS = $(GIREPO_CFLAGS)
libgirepository_la_LIBADD = $(GIREPO_LIBS)
libgirepository_la_LDFLAGS = -no-undefined
libgirepository_parser_la_SOURCES = \
girmodule.c \

View File

@ -91,6 +91,7 @@ struct _ParseContext
static void
backtrace_stderr (void)
{
#ifndef _WIN32
void *array[50];
int size;
char **strings;
@ -107,6 +108,7 @@ backtrace_stderr (void)
fprintf (stderr, "--- END BACKTRACE ---\n", size);
free (strings);
#endif
}

View File

@ -141,31 +141,45 @@ void
g_typelib_check_sanity (void)
{
/* Check that struct layout is as we expect */
g_assert (sizeof (Header) == 100);
g_assert (sizeof (DirEntry) == 12);
g_assert (sizeof (SimpleTypeBlob) == 4);
g_assert (sizeof (ArgBlob) == 12);
g_assert (sizeof (SignatureBlob) == 8);
g_assert (sizeof (CommonBlob) == 8);
g_assert (sizeof (FunctionBlob) == 16);
g_assert (sizeof (InterfaceTypeBlob) == 4);
g_assert (sizeof (ArrayTypeBlob) == 8);
g_assert (sizeof (ParamTypeBlob) == 4);
g_assert (sizeof (ErrorTypeBlob) == 4);
g_assert (sizeof (ErrorDomainBlob) == 16);
g_assert (sizeof (ValueBlob) == 12);
g_assert (sizeof (FieldBlob) == 12);
g_assert (sizeof (RegisteredTypeBlob) == 16);
g_assert (sizeof (StructBlob) == 20);
g_assert (sizeof (EnumBlob) == 20);
g_assert (sizeof (PropertyBlob) == 12);
g_assert (sizeof (SignalBlob) == 12);
g_assert (sizeof (VFuncBlob) == 16);
g_assert (sizeof (ObjectBlob) == 32);
g_assert (sizeof (InterfaceBlob) == 28);
g_assert (sizeof (ConstantBlob) == 20);
g_assert (sizeof (AnnotationBlob) == 12);
g_assert (sizeof (UnionBlob) == 28);
gboolean size_check_ok = TRUE;
#define CHECK_SIZE(s,n) \
if (sizeof(s) != n) \
{ \
g_printerr ("sizeof("#s") is expected to be %d but is %"G_GSIZE_FORMAT".\n", \
n, sizeof (s)); \
size_check_ok = FALSE; \
}
CHECK_SIZE (Header, 100);
CHECK_SIZE (DirEntry, 12);
CHECK_SIZE (SimpleTypeBlob, 4);
CHECK_SIZE (ArgBlob, 12);
CHECK_SIZE (SignatureBlob, 8);
CHECK_SIZE (CommonBlob, 8);
CHECK_SIZE (FunctionBlob, 16);
CHECK_SIZE (InterfaceTypeBlob, 4);
CHECK_SIZE (ArrayTypeBlob, 8);
CHECK_SIZE (ParamTypeBlob, 4);
CHECK_SIZE (ErrorTypeBlob, 4);
CHECK_SIZE (ErrorDomainBlob, 16);
CHECK_SIZE (ValueBlob, 12);
CHECK_SIZE (FieldBlob, 12);
CHECK_SIZE (RegisteredTypeBlob, 16);
CHECK_SIZE (StructBlob, 20);
CHECK_SIZE (EnumBlob, 20);
CHECK_SIZE (PropertyBlob, 12);
CHECK_SIZE (SignalBlob, 12);
CHECK_SIZE (VFuncBlob, 16);
CHECK_SIZE (ObjectBlob, 32);
CHECK_SIZE (InterfaceBlob, 28);
CHECK_SIZE (ConstantBlob, 20);
CHECK_SIZE (AnnotationBlob, 12);
CHECK_SIZE (UnionBlob, 28);
#undef CHECK_SIZE
g_assert (size_check_ok);
}