libIDL r590 - in trunk: . include/libIDL
- From: tml svn gnome org
- To: svn-commits-list gnome org
- Subject: libIDL r590 - in trunk: . include/libIDL
- Date: Tue, 20 May 2008 07:53:53 +0000 (UTC)
Author: tml
Date: Tue May 20 07:53:53 2008
New Revision: 590
URL: http://svn.gnome.org/viewvc/libIDL?rev=590&view=rev
Log:
2008-05-19 Tor Lillqvist <tml novell com>
Bug 522697 - Patch: make libIDL work with Microsoft's compilers
Patch by Marcelo Vanzin, applied with modifications.
* configure.in: Define Automake confitional OS_WIN32.
* Makefile.am: Use --export-symbols libIDL.def on Windows.
* Makefile.msc.in: Significant changes. Build a DLL with the same
name as libtool does. Use pkg-config.
* util.c: Make it work also in the !HAVE_CPP_STDIN && !HAVE_SYMLINK case.
* util.h: Make __IDL_tmp_filename const.
* include/libIDL/IDL.h.in: Rework the dllimport logic. Use
LIBIDL_VAR to decorate imported variables, similar to
GLIB_VAR. Unlike Marcelo's patch, I decided not to decorate
functions. Maybe later I can be convinced it would be a good idea,
but for now just use the .def file to export them and let them be
imported automatically.
* README.win32
* libIDL.def: Update.
Modified:
trunk/ChangeLog
trunk/Makefile.am
trunk/Makefile.msc.in
trunk/README.win32
trunk/configure.in
trunk/include/libIDL/IDL.h.in
trunk/libIDL.def
trunk/util.c
trunk/util.h
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Tue May 20 07:53:53 2008
@@ -2,6 +2,11 @@
#
# libIDL Makefile.am
#
+if OS_WIN32
+libIDL_def = libIDL.def
+export_symbols = -export-symbols libIDL.def
+endif
+
SUBDIRS = include
INCLUDES = \
-DYYDEBUG=1 \
@@ -44,7 +49,9 @@
libIDL_2_la_SOURCES = parser.c parser.h lexer.c \
ns.c util.c util.h rename.h
-libIDL_2_la_LDFLAGS = -version-info $(LT_VERSION) $(LIBIDL_LIBS) -no-undefined
+libIDL_2_la_CFLAGS = -DLIBIDL_COMPILATION
+libIDL_2_la_LDFLAGS = -version-info $(LT_VERSION) $(LIBIDL_LIBS) -no-undefined $(export_symbols)
+libIDL_2_la_DEPENDENCIES = $(libIDL_def)
tstidl_SOURCES = tstidl.c
tstidl_LDADD = libIDL-2.la $(LIBIDL_LIBS)
Modified: trunk/Makefile.msc.in
==============================================================================
--- trunk/Makefile.msc.in (original)
+++ trunk/Makefile.msc.in Tue May 20 07:53:53 2008
@@ -1,65 +1,73 @@
## -*- mode: makefile -*-
## Makefile for building the libIDL dll with Microsoft C
-## Use: nmake -f Makefile.msc install
+## Use: nmake -f Makefile.msc
-# Change this to wherever you want to install the DLLs. This directory
-# should be in your PATH.
-BIN = C:\Bin
+# As far as I can see a MSVC-built libIDL DLL is binary compatible
+# with a gcc-built one, except for the IDL_tree_to_IDL() function
+# which has a FILE* parameter. (FILE structs are meaningless in a
+# module that uses a different C runtime.) That function is not used
+# by ORBit2 at least, though. Thus use the same name for the DLL. Keep
+# this in sync with current and age in LT_VERSION (@LT_VERSION@).
+CURRENT_MINUS_AGE = 0
-# GLib location
-GLIB_INCLUDES = -I/Devel/Port/glib
-GLIB_LIBPATH = c:\Devel\Port\glib
-GLIB_LIB = glib-1.2.lib
+IDL_DLL = libIDL-2-$(CURRENT_MINUS_AGE).dll
-# libIDL dll version
-LIBIDL_REALVER = @LIBIDL_VERSION@
-LIBIDL_LIBVER = @LIBIDL_MAJOR_VERSION @LIBIDL_MINOR_VERSION@
+all: __glib_cflags.mk $(IDL_DLL) tstidl.exe
-# Debug build
-LDOPT = /debug:full /debugtype:cv
-CCOPT = -Ox
-#CCOPT = -Zi # Debug build
+LDOPT = -debug
+CCOPT =
+CC = cl -GF $(CCOPT) -MD -W3 -nologo
-################################################################
-CC = cl -G5 -GF $(CCOPT) -W3 -D_DLL -nologo
-LDFLAGS = /link /nodefaultlib:libc msvcrt.lib /libpath:$(GLIB_LIBPATH) $(LDOPT)
-INSTALL = copy
-TOUCH = copy Makefile.msc+nul
+MT = mt
-CFLAGS = -I. $(GLIB_INCLUDES)
+LDFLAGS = -link -incremental:no -libpath:c:/opt/proxy-libintl/lib $(LDOPT)
-all: libIDL-$(LIBIDL_LIBVER).dll tstidl.exe
+# Indirect file with GLib cflags
+__glib_cflags.mk:
+ pkg-config --msvc-syntax --cflags glib-2.0 >$@
-install: all
- $(INSTALL) libIDL-$(LIBIDL_LIBVER).dll $(BIN)
+# And libs
+__glib_libs.mk:
+ for /F "delims==" %i in ('pkg-config --msvc-syntax --libs glib-2.0') \
+ do echo $(LDFLAGS) %i >$@
-libIDL_OBJECTS = \
- parser.obj \
- lexer.obj \
- ns.obj \
+CFLAGS = -Iinclude -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS @__glib_cflags.mk
+
+# All .c files go into the DLL except tstidl.c, so we can use _DLIBIDL_COMPILATION
+# in general, correspondingly then build tstidl.exe directly from tstidl.c
+DEFS = -DLIBIDL_VERSION=\"@LIBIDL_VERSION \" \
+ -DCPP_PROGRAM="\"cl.exe /E /nologo\"" -DCPP_NOSTDINC=\"\" \
+ -DSTDC_HEADERS -DHAVE_POPEN -DHAVE_STDDEF_H -DHAVE_WCHAR_H \
+ -DYYTEXT_POINTER -DYYDEBUG \
+ -DG_LOG_DOMAIN=\"libIDL\" \
+ -DLIBIDL_COMPILATION
+
+libIDL_OBJECTS = \
+ parser.obj \
+ lexer.obj \
+ ns.obj \
util.obj
-libIDL-$(LIBIDL_LIBVER).dll: $(libIDL_OBJECTS)
- $(CC) $(CFLAGS) -MD -LD -FelibIDL-$(LIBIDL_LIBVER).dll $(libIDL_OBJECTS) $(GLIB_LIB) user32.lib advapi32.lib $(LDFLAGS) /def:libIDL.def
+$(IDL_DLL): $(libIDL_OBJECTS) libIDL.def __glib_libs.mk
+ $(CC) $(CFLAGS) -LD -Fe$@ $(libIDL_OBJECTS) libIDL.def @__glib_libs.mk -link -implib:libIDL-2.lib
+ $(MT) -manifest $ manifest -outputresource:$@;2
.c.obj:
- $(CC) $(CFLAGS) -GD -c -DPACKAGE=\"libIDL\" -DLIBIDL_VERSION=\"$(LIBIDL_REALVER)\" -DHAVE_CPP_PIPE_STDIN=1 -DCPP_PROGRAM="\"notsupported\"" -DYYTEXT_POINTER=1 -DSTDC_HEADERS=1 -DHAVE_STDDEF_H=1 -DHAVE_WCHAR_H=1 -DYYDEBUG=1 -DIDL_LIBRARY -DG_LOG_DOMAIN=\"libIDL\" $<
+ $(CC) $(CFLAGS) $(DEFS) -c $<
-tstidl.exe: libIDL-$(LIBIDL_LIBVER).dll tstidl.obj
- $(CC) $(CFLAGS) -MD -Fetstidl.exe tstidl.obj libIDL-$(LIBIDL_LIBVER).lib $(GLIB_LIB) $(LDFLAGS) /map
+tstidl.exe: $(IDL_DLL) tstidl.c
+ $(CC) $(CFLAGS) -Fe$@ tstidl.c libIDL-2.lib @__glib_libs.mk
+ $(MT) -manifest $ manifest -outputresource:$@;1
clean:
- del config.h
del *.exe
del *.obj
del *.dll
del *.lib
del *.err
del *.map
- del *.sym
del *.exp
- del *.lk1
- del *.mk1
del *.pdb
- del *.ilk
+ del *.manifest
+ del __*.mk
Modified: trunk/README.win32
==============================================================================
--- trunk/README.win32 (original)
+++ trunk/README.win32 Tue May 20 07:53:53 2008
@@ -3,23 +3,42 @@
Win32 libIDL support is mostly here, but currently requires the use of
IDL_parse_filename_with_input, since there is no C preprocessor
-generally available under Windows. To compile this, you will also
-need to obtain glib for Win32, which you should be able to obtain from
-http://www.gimp.org/~tml/gimp/win32/.
+generally available under Windows. To compile this, you will also need
+to obtain GLib and pkg-config for Windows, which you should be able to
+obtain from http://www.gtk.org/download-windows.html
Building
~~~~~~~~
-Edit Makefile.msc and edit the locations of the glib includes, library
-name, and library path. Only Microsoft C is supported at the moment,
-but it shouldn't be difficult to port to other compilers.
+You can build either with the GNU toolchain (mingw) or one of
+Microsoft's compiler (any recent version should work). With mingw you
+use the normal configure script and make. pkg-config is used in the
+normal way to find out the compiler command-line options.
+
+With Microsoft's compiler you run nmake -f Makefile.msc. Also the
+Makefile.msc uses pkg-config to find out the compiler flags. The
+commands to use pkg-config output in the Makefile.msc are somewhat
+convoluted, but nothing simpler seems to work, given the lack of
+backticks in cmd.exe or something similar in nmake. If you use an
+older Microsoft compiler you will have to edit out the
+manifest-related commands from Makefile.msc.
+
+When built with gcc libIDL will also use gcc as a preprocessor (it
+will run "gcc -E -P"), and when built with Microsoft's compiler it
+will correspondingly use the Microsoft compiler as preprocessort (it
+will run "cl -EP"). Thus users of libIDL, especially users of the
+ORBit2 IDL compiler orbit-idl-2, need to make sure that they have the
+necessary folders in PATH so that gcc or cl are found when orbit-idl-2
+is run.
Using the Library
~~~~~~~~~~~~~~~~~
-After building, all you need are the files IDL.h and libIDL-x.x.dll
-and libIDL-x.x.lib. Place the include file in a place where it can be
-found with libIDL/IDL.h.
+After building, all you need are the files IDL.h and the DLL and
+related import library. Place the header in a place where it can be
+found with libIDL/IDL.h, the DLL somewhere in PATH, and the import
+library somewhere where your compiler will find it.
--
Andrew T. Veliath <andrewtv usa net>
+Tor Lillqvist <tml iki fi>
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue May 20 07:53:53 2008
@@ -77,6 +77,19 @@
AM_PROG_LIBTOOL
AM_MAINTAINER_MODE
+AC_MSG_CHECKING([for Win32])
+case "$host" in
+ *-*-mingw*)
+ os_win32=yes
+ ;;
+ *)
+ os_win32=no
+
+ ;;
+esac
+AC_MSG_RESULT([$os_win32])
+AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
+
dnl Checks for libraries.
PKG_CHECK_MODULES(LIBIDL, glib-2.0 >= 2.4.0)
Modified: trunk/include/libIDL/IDL.h.in
==============================================================================
--- trunk/include/libIDL/IDL.h.in (original)
+++ trunk/include/libIDL/IDL.h.in Tue May 20 07:53:53 2008
@@ -86,16 +86,18 @@
#define IDLF_OUTPUT_CODEFRAGS (1UL << 3)
#ifdef G_PLATFORM_WIN32
-# define IDL_EXPORT /* assume auto-export */
-# define IDL_IMPORT __declspec (dllimport)
+# ifdef LIBIDL_COMPILATION
+# define LIBIDL_VAR extern /* exported from .def file */
+# else
+# define LIBIDL_VAR extern __declspec(dllimport)
+# endif
#else
-# define IDL_EXPORT /* empty */
-# define IDL_IMPORT extern
+# define LIBIDL_VAR extern /* empty */
#endif
/* type casting checks */
#define IDL_check_cast_enable(boolean) do { \
- IDL_IMPORT int __IDL_check_type_casts; \
+ LIBIDL_VAR int __IDL_check_type_casts; \
__IDL_check_type_casts = (boolean); \
} while (0)
#define IDL_CHECK_CAST(tree, thetype, name) \
@@ -539,7 +541,8 @@
IDLN_LAST
} IDL_tree_type;
-IDL_IMPORT const char * IDL_tree_type_names[];
+
+LIBIDL_VAR const char * IDL_tree_type_names[];
struct _IDL_tree_node {
IDL_tree_type _type;
Modified: trunk/libIDL.def
==============================================================================
--- trunk/libIDL.def (original)
+++ trunk/libIDL.def Tue May 20 07:53:53 2008
@@ -1,96 +1,102 @@
EXPORTS
- IDL_check_type_cast
- IDL_list_new
- IDL_list_concat
- IDL_list_remove
- IDL_list_length
- IDL_list_nth
- IDL_gentree_new
- IDL_gentree_new_sibling
- IDL_gentree_chain_sibling
- IDL_gentree_chain_child
- IDL_integer_new
- IDL_string_new
- IDL_wide_string_new
+ IDL_attr_dcl_new
+ IDL_binop_new
+ IDL_boolean_new
+ IDL_case_stmt_new
IDL_char_new
- IDL_wide_char_new
+ IDL_check_type_cast
+ IDL_codefrag_new
+ IDL_const_dcl_new
+ IDL_do_escapes
+ IDL_except_dcl_new
+ IDL_file_get
+ IDL_file_set
IDL_fixed_new
IDL_float_new
- IDL_boolean_new
+ IDL_forward_dcl_new
+ IDL_gentree_chain_child
+ IDL_gentree_chain_sibling
+ IDL_gentree_new
+ IDL_gentree_new_sibling
+ IDL_get_IDLver_string
+ IDL_get_libver_string
+ IDL_get_parent_node
IDL_ident_new
- IDL_queue_new_ident_comment
- IDL_type_float_new
- IDL_type_fixed_new
- IDL_type_integer_new
- IDL_type_char_new
- IDL_type_wide_char_new
- IDL_type_boolean_new
- IDL_type_octet_new
- IDL_type_any_new
- IDL_type_object_new
- IDL_type_typecode_new
- IDL_type_string_new
- IDL_type_wide_string_new
- IDL_type_enum_new
- IDL_type_array_new
- IDL_type_sequence_new
- IDL_type_struct_new
- IDL_type_union_new
+ IDL_inhibit_get
+ IDL_inhibit_pop
+ IDL_inhibit_push
+ IDL_integer_new
+ IDL_interface_new
+ IDL_list_concat
+ IDL_list_length
+ IDL_list_new
+ IDL_list_nth
+ IDL_list_remove
IDL_member_new
+ IDL_module_new
IDL_native_new
- IDL_type_dcl_new
- IDL_const_dcl_new
- IDL_except_dcl_new
- IDL_attr_dcl_new
+ IDL_ns_ID
+ IDL_ns_free
+ IDL_ns_ident_make_repo_id
+ IDL_ns_ident_to_qstring
+ IDL_ns_lookup_cur_scope
+ IDL_ns_lookup_this_scope
+ IDL_ns_new
+ IDL_ns_place_new
+ IDL_ns_pop_scope
+ IDL_ns_prefix
+ IDL_ns_push_scope
+ IDL_ns_qualified_ident_new
+ IDL_ns_resolve_ident
+ IDL_ns_resolve_this_scope_ident
+ IDL_ns_scope_levels_from_here
+ IDL_ns_version
IDL_op_dcl_new
IDL_param_dcl_new
- IDL_case_stmt_new
- IDL_interface_new
- IDL_forward_dcl_new
- IDL_module_new
- IDL_binop_new
- IDL_unaryop_new
- IDL_codefrag_new
- IDL_check_type_cast
- IDL_get_libver_string
- IDL_get_IDLver_string
IDL_parse_filename
IDL_parse_filename_with_input
- IDL_ns_prefix
- IDL_ns_ID
- IDL_ns_version
- IDL_inhibit_get
- IDL_inhibit_push
- IDL_inhibit_pop
- IDL_file_set
- IDL_file_get
- IDL_get_parent_node
- IDL_tree_get_scope
- IDL_tree_get_node_info
+ IDL_queue_new_ident_comment
+ IDL_resolve_const_exp
+ IDL_srcfile_new
+ IDL_string_new
+ IDL_tree_contains_node
IDL_tree_error
- IDL_tree_warning
+ IDL_tree_free
+ IDL_tree_get_node_info
+ IDL_tree_get_scope
+ IDL_tree_is_recursive
+ IDL_tree_properties_copy
IDL_tree_property_get
- IDL_tree_property_set
IDL_tree_property_remove
- IDL_tree_properties_copy
- IDL_tree_type_names
+ IDL_tree_property_set
IDL_tree_remove_inhibits
+ IDL_tree_to_IDL
+ IDL_tree_to_IDL_string
+ IDL_tree_type_names DATA
IDL_tree_walk
+ IDL_tree_walk2
IDL_tree_walk_in_order
- IDL_tree_free
- IDL_tree_to_IDL
- IDL_do_escapes
- IDL_resolve_const_exp
- IDL_ns_new
- IDL_ns_free
- IDL_ns_resolve_this_scope_ident
- IDL_ns_resolve_ident
- IDL_ns_lookup_this_scope
- IDL_ns_lookup_cur_scope
- IDL_ns_place_new
- IDL_ns_push_scope
- IDL_ns_pop_scope
- IDL_ns_qualified_ident_new
- IDL_ns_ident_to_qstring
- IDL_ns_scope_levels_from_here
- IDL_ns_ident_make_repo_id
+ IDL_tree_warning
+ IDL_type_any_new
+ IDL_type_array_new
+ IDL_type_boolean_new
+ IDL_type_char_new
+ IDL_type_dcl_new
+ IDL_type_enum_new
+ IDL_type_fixed_new
+ IDL_type_float_new
+ IDL_type_integer_new
+ IDL_type_object_new
+ IDL_type_octet_new
+ IDL_type_sequence_new
+ IDL_type_string_new
+ IDL_type_struct_new
+ IDL_type_typecode_new
+ IDL_type_union_new
+ IDL_type_wide_char_new
+ IDL_type_wide_string_new
+ IDL_unaryop_new
+ IDL_wide_char_new
+ IDL_wide_string_new
+ __IDL_check_type_casts DATA
+ __IDL_debug DATA
Modified: trunk/util.c
==============================================================================
--- trunk/util.c (original)
+++ trunk/util.c Tue May 20 07:53:53 2008
@@ -37,9 +37,12 @@
#ifdef G_OS_WIN32
#include <fcntl.h>
+#include <direct.h>
+#define popen _popen
+#define pclose _pclose
#endif
-IDL_EXPORT const char *IDL_tree_type_names[] = {
+const char *IDL_tree_type_names[] = {
"IDLN_NONE",
"IDLN_ANY",
"IDLN_LIST",
@@ -88,9 +91,9 @@
/* IDLN_LAST */
};
-IDL_EXPORT int __IDL_check_type_casts = FALSE;
+int __IDL_check_type_casts = FALSE;
#ifndef HAVE_CPP_PIPE_STDIN
-char * __IDL_tmp_filename = NULL;
+const char * __IDL_tmp_filename = NULL;
#endif
const char * __IDL_real_filename = NULL;
char * __IDL_cur_filename = NULL;
@@ -228,9 +231,13 @@
char *wd;
#else
char *fmt = CPP_PROGRAM " " CPP_NOSTDINC " -I- -I%s %s \"%s\" %s";
- char *s, *tmpfilename;
char cwd[2048];
+#ifdef HAVE_SYMLINK
+ char *s, *tmpfilename;
gchar *linkto;
+#else
+ const char *tmpfilename;
+#endif
#endif
#ifndef G_OS_WIN32
@@ -267,11 +274,12 @@
g_free (wd);
#else
- s = tmpnam (NULL);
- if (s == NULL)
+ if (!getcwd (cwd, sizeof (cwd)))
return -1;
- if (!getcwd (cwd, sizeof (cwd)))
+#ifdef HAVE_SYMLINK
+ s = tmpnam (NULL);
+ if (s == NULL)
return -1;
if (g_path_is_absolute (filename)) {
@@ -281,16 +289,16 @@
}
tmpfilename = g_strconcat (s, ".c", NULL);
-#ifdef HAVE_SYMLINK
+
if (symlink (linkto, tmpfilename) < 0) {
g_free (linkto);
g_free (tmpfilename);
return -1;
}
+ g_free (linkto);
#else
-#error Must have symlink
+ tmpfilename = filename;
#endif
- g_free (linkto);
cmd = g_strdup_printf (fmt, cwd, cpp_args ? cpp_args : "",
tmpfilename, cpperrs);
@@ -301,7 +309,7 @@
putenv ("LC_ALL=C");
#ifdef HAVE_POPEN
-#ifdef G_OS_WIN32
+#if defined (G_OS_WIN32) && !defined (_MSC_VER)
if (!(parse_flags & IDLF_SHOW_CPP_ERRORS)) {
int save_stderr = dup (2);
int null = open ("NUL:", O_WRONLY);
@@ -317,13 +325,12 @@
input = popen (cmd, "r");
#endif
#else
- /* Surely this doesn't make any sense? */
- input = fopen (cmd, "r");
+#error Must have popen
#endif
g_free (cmd);
if (input == NULL || ferror (input)) {
-#ifndef HAVE_CPP_PIPE_STDIN
+#if !defined (HAVE_CPP_PIPE_STDIN) && defined (HAVE_SYMLINK)
g_free (tmpfilename);
#endif
return IDL_ERROR;
@@ -356,7 +363,7 @@
#else
fclose (input);
#endif
-#ifndef HAVE_CPP_PIPE_STDIN
+#if !defined (HAVE_CPP_PIPE_STDIN) && defined (HAVE_SYMLINK)
unlink (tmpfilename);
g_free (tmpfilename);
#endif
Modified: trunk/util.h
==============================================================================
--- trunk/util.h (original)
+++ trunk/util.h Tue May 20 07:53:53 2008
@@ -87,7 +87,7 @@
#ifndef HAVE_CPP_PIPE_STDIN
-extern char * __IDL_tmp_filename;
+extern const char * __IDL_tmp_filename;
#endif
extern const char * __IDL_real_filename;
extern char * __IDL_cur_filename;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]