diff options
60 files changed, 3376 insertions, 1103 deletions
diff --git a/.gitignore b/.gitignore index a381ee5a67c..2baf43621b4 100644 --- a/.gitignore +++ b/.gitignore @@ -48,7 +48,6 @@ sgenerated *.suo *.xap core.* -cpp/src/Ice/EventLoggerMsg.res tmp_*.xml obj *.RES @@ -77,7 +76,6 @@ js/npm-debug.log .depend -cpp/src/Ice/EventLoggerMsg.h -cpp/src/Ice/EventLoggerMsg.rc +cpp/src/Ice/EventLoggerMsg.res *.bin diff --git a/config/Make.common.rules b/config/Make.common.rules index 21ac0122b1a..3e8ffdb7c82 100644 --- a/config/Make.common.rules +++ b/config/Make.common.rules @@ -40,6 +40,30 @@ ifeq ($(USE_BIN_DIST),yes) ice_bin_dist = 1 endif +ifeq ($(UNAME),Darwin) + usr_dir = /usr/local +else + usr_dir = /usr +endif + +# +# usr_dir_install means we want to install with a /usr style layout. +# +ifeq ($(prefix), /usr) + usr_dir_install = 1 +endif + +ifeq ($(prefix), /usr/local) + usr_dir_install = 1 +endif + +# +# A /usr style layout can be forced by setting USR_DIR_INSTALL=yes. +# +ifeq ($(USR_DIR_INSTALL),yes) + usr_dir_install = 1 +endif + ifeq ($(UNAME),SunOS) ifeq ($(MACHINE_TYPE),sun4u) lp64suffix = /64 @@ -65,14 +89,14 @@ ifeq ($(UNAME),Linux) # # Ubuntu. # - ifeq ($(shell test -d /usr/lib/x86_64-linux-gnu && echo 0),0) + ifeq ($(shell test -d $(usr_dir)/lib/x86_64-linux-gnu && echo 0),0) lp64suffix = /x86_64-linux-gnu endif # # Rhel/SLES # - ifeq ($(shell test -d /usr/lib64 && echo 0),0) + ifeq ($(shell test -d $(usr_dir)/lib64 && echo 0),0) lp64suffix = 64 endif @@ -80,12 +104,14 @@ ifeq ($(UNAME),Linux) LP64 = yes endif endif - ifneq ($(LP64),yes) - binsuffix = 32 - endif + ifneq ($(STATICLIBS),yes) + ifneq ($(LP64),yes) + binsuffix = 32 + endif + endif endif -ifeq ($(shell test -d /usr/lib/i386-linux-gnu && echo 0),0) +ifeq ($(shell test -d $(usr_dir)/lib/i386-linux-gnu && echo 0),0) lp32suffix = /i386-linux-gnu endif @@ -119,10 +145,8 @@ else # ifeq ($(MACHINE_TYPE),x86_64) ifeq ($(UNAME),Linux) - ifeq ($(shell test -d /usr/lib/x86_64-linux-gnu && echo 0),0) - ifeq ($(ice_dir),/usr) - lib64subdir = lib/x86_64-linux-gnu - endif + ifeq ($(shell test -d $(usr_dir)/lib/x86_64-linux-gnu && echo 0),0) + lib64subdir = lib/x86_64-linux-gnu else lib64subdir = lib$(lp64suffix) endif @@ -225,13 +249,13 @@ $(error Unable to find $(slice_translator) in $(ICE_HOME)/$(binsubdir), please v ifeq ($(shell test -f $(top_srcdir)/bin/$(slice_translator) && echo 0), 0) ice_dir = $(top_srcdir) else - ifeq ($(shell test -f /usr/bin/$(slice_translator) && echo 0), 0) - ice_dir = /usr + ifeq ($(shell test -f $(usr_dir)/bin/$(slice_translator) && echo 0), 0) + ice_dir = $(usr_dir) ifeq ($(shell test -f /opt/Ice-$(VERSION)/bin/$(slice_translator) && echo 0), 0) - $(warning Found $(slice_translator) in both /usr/bin and /opt/Ice-$(VERSION)/bin, /usr/bin/$(slice_translator) will be used!) + $(warning Found $(slice_translator) in both $(usr_dir)/bin and /opt/Ice-$(VERSION)/bin, $(usr_dir)/bin/$(slice_translator) will be used!) endif ifeq ($(shell test -f /Library/Developer/Ice-$(VERSION)/bin/$(slice_translator) && echo 0), 0) - $(warning Found $(slice_translator) in both /usr/bin and /Library/Developer/Ice-$(VERSION)/bin, /usr/bin/$(slice_translator) will be used!) + $(warning Found $(slice_translator) in both $(usr_dir)/bin and /Library/Developer/Ice-$(VERSION)/bin, $(usr_dir)/bin/$(slice_translator) will be used!) endif else ifeq ($(shell test -f /Library/Developer/Ice-$(VERSION)/$(binsubdir)/$(slice_translator) && echo 0), 0) @@ -269,29 +293,34 @@ endif # # Clear the embedded runpath prefix if building against RPM distribution. # -ifeq ($(ice_dir), /usr) +ifeq ($(ice_dir), $(usr_dir)) embedded_runpath_prefix = endif # # Set slicedir to the path of the directory containing the Slice files. # -ifeq ($(ice_dir), /usr) - slicedir = /usr/share/Ice-$(VERSION)/slice +ifeq ($(ice_dir), $(usr_dir)) + slicedir = $(usr_dir)/share/slice else slicedir = $(ice_dir)/slice endif -ifeq ($(prefix), /usr) - install_slicedir = /usr/share/Ice-$(VERSION)/slice +# +# Installation location for slice and doc files. +# +ifdef usr_dir_install + install_slicedir = $(prefix)/share/Ice-$(VERSION)/slice + install_docdir = $(prefix)/share/Ice-$(VERSION) else install_slicedir = $(prefix)/slice + install_docdir = $(prefix) endif # # Set environment variables for the Slice translator. # -ifneq ($(ice_dir), /usr) +ifneq ($(ice_dir), $(usr_dir)) ifdef ice_src_dist ice_lib_dir = $(ice_cpp_dir)/$(libsubdir) else @@ -425,16 +454,20 @@ else endif install-common:: - @if test ! -d $(prefix) ; \ + @if test ! -d $(DESTDIR)$(prefix) ; \ then \ echo "Creating $(prefix)..." ; \ - $(call mkdir,$(prefix), -p) ; \ + $(call mkdir,$(DESTDIR)$(prefix), -p) ; \ fi @if test ! -d $(DESTDIR)$(install_slicedir) ; \ then \ echo "Creating $(DESTDIR)$(install_slicedir)..." ; \ $(call mkdir, $(DESTDIR)$(install_slicedir), -p) ; \ + if test ! -z "$(usr_dir_install)" ; \ + then \ + ln -s Ice-$(VERSION)/slice $(DESTDIR)/$(prefix)/share/slice ; \ + fi ; \ cd $(top_srcdir)/../slice ; \ for subdir in * ; \ do \ @@ -443,17 +476,17 @@ install-common:: done ; \ fi - @if test ! -f $(DESTDIR)$(prefix)/ICE_LICENSE$(TEXT_EXTENSION) ; \ + @if test ! -f $(DESTDIR)$(install_docdir)/ICE_LICENSE$(TEXT_EXTENSION) ; \ then \ - $(call installdata,$(top_srcdir)/../ICE_LICENSE$(TEXT_EXTENSION),$(DESTDIR)$(prefix)) ; \ + $(call installdata,$(top_srcdir)/../ICE_LICENSE$(TEXT_EXTENSION),$(DESTDIR)$(install_docdir)) ; \ fi - @if test ! -f $(DESTDIR)$(prefix)/LICENSE$(TEXT_EXTENSION) ; \ + @if test ! -f $(DESTDIR)$(install_docdir)/LICENSE$(TEXT_EXTENSION) ; \ then \ - $(call installdata,$(top_srcdir)/../LICENSE$(TEXT_EXTENSION),$(DESTDIR)$(prefix)) ; \ + $(call installdata,$(top_srcdir)/../LICENSE$(TEXT_EXTENSION),$(DESTDIR)$(install_docdir)) ; \ fi - @if test ! -f $(DESTDIR)$(prefix)/CHANGES$(TEXT_EXTENSION) ; \ + @if test ! -f $(DESTDIR)$(install_docdir)/CHANGES$(TEXT_EXTENSION) ; \ then \ - $(call installdata,$(top_srcdir)/../CHANGES$(TEXT_EXTENSION),$(DESTDIR)$(prefix)) ; \ + $(call installdata,$(top_srcdir)/../CHANGES$(TEXT_EXTENSION),$(DESTDIR)$(install_docdir)) ; \ fi diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index bbd102a1dba..e3430d15bd0 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -204,14 +204,14 @@ endif include $(top_srcdir)/config/Make.rules.$(UNAME) install_includedir := $(prefix)/include -install_docdir := $(prefix)/doc install_bindir := $(prefix)/$(binsubdir)$(cpp11suffix) install_libdir := $(prefix)/$(libsubdir)$(cpp11suffix) -install_configdir := $(prefix)/config -ifneq ($(prefix),/usr) +ifndef usr_dir_install install_mandir := $(prefix)/man/man1 +install_configdir := $(prefix)/config else +install_configdir := $(prefix)/share/config install_mandir := $(prefix)/share/man/man1 endif @@ -229,7 +229,9 @@ ifeq ($(SSL_OS_LIBS),) SSL_OS_LIBS = $(OPENSSL_LIBS) endif -BZIP2_FLAGS = $(if $(BZIP2_HOME),-I$(BZIP2_HOME)/include) +ifneq ($(BZIP2_HOME),) + BZIP2_FLAGS = I$(BZIP2_HOME)/include) +endif ifeq ($(BZIP2_LIBS),) BZIP2_LIBS = $(if $(BZIP2_HOME),-L$(BZIP2_HOME)/$(libsubdir)) -lbz2 endif @@ -289,7 +291,7 @@ ICECPPFLAGS = -I$(slicedir) SLICE2CPPFLAGS = $(ICECPPFLAGS) -ifeq ($(ice_dir), /usr) +ifeq ($(ice_dir), $(usr_dir)) LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) ifeq ($(CPP11),yes) LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(ice_dir)/$(libsubdir)$(cpp11libdirsuffix) @@ -328,7 +330,11 @@ ifeq ($(mktest),) endif ifdef ice_src_dist +ifeq ($(STATICLIBS),yes) + SLICEPARSERLIB = +else SLICEPARSERLIB = $(libdir)/$(call mklibfilename,Slice,$(VERSION)) +endif SLICE2CPP = $(bindir)/slice2cpp SLICE2FREEZE = $(bindir)/slice2freeze else @@ -352,8 +358,8 @@ ifeq ($(ICESSL_LIBS),) ICESSL_LIBS = -lIceSSL endif -EVERYTHING = all clean install -EVERYTHING_EXCEPT_ALL = clean install +EVERYTHING = all clean install compile-slice +EVERYTHING_EXCEPT_ALL = clean install compile-slice .SUFFIXES: .SUFFIXES: .cpp .c .o @@ -396,7 +402,7 @@ $(HDIR)/%F.h: $(SDIR)/%F.ice $(SLICE2CPP) $(SLICEPARSERLIB) mv $(*F)F.h $(HDIR) @touch $(*F)F.cpp @mkdir -p .depend - @$(SLICE2CPP) $(SLICE2CPPFLAGS) --depend $< | $(ice_dir)/config/makedepend.py "\$$(HDIR)/" > .depend/$(*F)F.ice.d + @$(SLICE2CPP) $(SLICE2CPPFLAGS) --depend $< | sed 's/\(.*: \\\)/\$$(HDIR)\/\1/' > .depend/$(*F)F.ice.d $(HDIR)/%.h %.cpp: $(SDIR)/%.ice $(SLICE2CPP) $(SLICEPARSERLIB) rm -f $(HDIR)/$(*F).h $(*F).cpp @@ -404,9 +410,11 @@ $(HDIR)/%.h %.cpp: $(SDIR)/%.ice $(SLICE2CPP) $(SLICEPARSERLIB) mv $(*F).h $(HDIR) @touch $(*F).cpp @mkdir -p .depend - @$(SLICE2CPP) $(SLICE2CPPFLAGS) --depend $< | $(ice_dir)/config/makedepend.py "\$$(HDIR)/" > .depend/$(*F).ice.d + @$(SLICE2CPP) $(SLICE2CPPFLAGS) --depend $< | sed 's/\(.*: \\\)/\$$(HDIR)\/\1/' > .depend/$(*F).ice.d -%.h %.cpp: %.ice $(SLICE2CPP) $(SLICEPARSERLIB) +#%.h %.cpp: %.ice $(SLICE2CPP) $(SLICEPARSERLIB) + +%.h %.cpp: %.ice $(SLICE2CPP) rm -f $(*F).h $(*F).cpp $(SLICE2CPP) $(SLICE2CPPFLAGS) $(*F).ice @touch $(*F).cpp @@ -447,4 +455,10 @@ clean:: rm -f $(addprefix $(HDIR)/, $(addsuffix .h, $(basename $(SLICE_OBJS)))) endif +ifneq ($(SLICE_OBJS),) +compile-slice:: $(SLICE_OBJS:.o=.cpp) +else +compile-slice:: +endif + install:: diff --git a/cpp/config/Make.rules.Darwin b/cpp/config/Make.rules.Darwin index 2a8cae9aee5..cf8d8b7a8fa 100644 --- a/cpp/config/Make.rules.Darwin +++ b/cpp/config/Make.rules.Darwin @@ -74,7 +74,7 @@ ifeq ($(embedded_runpath),yes) # # Clear rpath setting when doing a system install # - ifeq ($(ice_dir),/usr) + ifeq ($(ice_dir), $(usr_dir)) RPATH_DIR = endif diff --git a/cpp/config/Make.rules.Linux b/cpp/config/Make.rules.Linux index bb6fa2dbd92..6de191f0702 100644 --- a/cpp/config/Make.rules.Linux +++ b/cpp/config/Make.rules.Linux @@ -121,7 +121,7 @@ ifeq ($(CXX),g++) # # Clear the rpath dir when doing a system install. # - ifeq ($(ice_dir), /usr) + ifeq ($(ice_dir), $(usr_dir)) RPATH_DIR = endif diff --git a/cpp/config/Make.rules.MINGW b/cpp/config/Make.rules.MINGW index 65210c65822..e1d71a5f41f 100644 --- a/cpp/config/Make.rules.MINGW +++ b/cpp/config/Make.rules.MINGW @@ -14,9 +14,7 @@ # # Default compiler is c++ (aka g++). # -ifeq ($(CXX),) - CXX = c++ -endif +CXX = c++ # ICE_WIN32_WINNT sets the minimum version of Windows supported by this build # 0x600 = Windows Vista / Windows Server 2008 @@ -24,8 +22,11 @@ endif # 0x602 = Windows 8 / Windows Server 2012 ICE_WIN32_WINNT := 0x601 -CXXFLAGS = $(CXXARCHFLAGS) -mthreads -fvisibility=hidden -Wall -Werror -D_WIN32_WINNT=$(ICE_WIN32_WINNT) -DWIN32_LEAN_AND_MEAN -LDFLAGS = -Wl,-no-undefined +CXXFLAGS = $(CXXARCHFLAGS) -mthreads -Wall -Werror -D_WIN32_WINNT=$(ICE_WIN32_WINNT) -DWIN32_LEAN_AND_MEAN -DICE_STATIC_LIBS +ifeq ($(STATICLIBS),yes) +CXXFLAGS += -DICE_STATIC_LIBS +endif +LDFLAGS = -Wl,-no-undefined -static-libgcc -static-libstdc++ ifeq ($(OPTIMIZE),yes) CXXFLAGS += -O2 -DNDEBUG @@ -36,18 +37,8 @@ endif COMPSUFFIX = _mingw mklibfilename = $(shell echo $(1) | tr A-Z a-z)$(SOVERSION)$(COMPSUFFIX).dll +mklibtargets = $(3) -ifeq ($(STATICLIBS),yes) - mklibtargets = $(3) -else - mklibtargets = $(1) -endif - -# -# Shared library linking command. We transform -lxxx parameters into -# -lxxx<ver>$(COMPSUFFIX).dll here to avoid having to fix all the Makefiles -# which need to link with the MinGW libraries. -# mkshlib = $(CXX) -shared $(LDFLAGS) -o $(1) $(3) \ $(subst cpp/lib,cpp/bin, \ $(subst -lIce,-lice$(SOVERSION)$(COMPSUFFIX), \ @@ -57,16 +48,15 @@ mkshlib = $(CXX) -shared $(LDFLAGS) -o $(1) $(3) \ mklib = ar cr $(1) $(2) -ifeq ($(LP64),yes) - libsubdir := bin$(lp64suffix) - binsubdir := bin$(lp64suffix) +ifeq ($(STATICLIBS),yes) +libsubdir := lib else - libsubdir := bin - binsubdir := bin +libsubdir := bin endif +binsubdir := bin libdir := $(top_srcdir)/$(libsubdir) -bindir := $(top_srcdir)/$(libsubdir) +bindir := $(top_srcdir)/$(binsubdir) installlib = $(INSTALL) $(2)/$(3) $(1); \ chmod a+rx $(1)/$(3) @@ -81,19 +71,26 @@ SSL_OS_LIBS = -lsecur32 -lcrypt32 -lws2_32 ICEWS_OS_LIBS = -lws2_32 -ifeq ($(LP64),yes) - MCPP_LIBS = -L"$(THIRDPARTY_HOME)/lib/mingw$(lp64suffix)" -lmcpp -else - MCPP_LIBS = -L"$(THIRDPARTY_HOME)/lib/mingw" -lmcpp -endif +MCPP_LIBS = -lmcpp -BZIP2_LIBS = -lbzip2$(COMPSUFFIX) +BZIP2_LIBS = -lbz2 -BASELIBS = -liceutil$(SOVERSION)$(COMPSUFFIX) +ifeq ($(STATICLIBS),yes) +BASELIBS = -liceutil $(ICEUTIL_OS_LIBS) +LIBS = -lice $(BASELIBS) +ICESSL_LIBS = -licessl +ICEWS_LIBS = -licews +SLICE_LIBS = -lslice $(BASELIBS) +else +BASELIBS = -liceutil$(SOVERSION)$(COMPSUFFIX) $(ICEUTIL_OS_LIBS) LIBS = -lice$(SOVERSION)$(COMPSUFFIX) $(BASELIBS) ICESSL_LIBS = -licessl$(SOVERSION)$(COMPSUFFIX) ICEWS_LIBS = -licews$(SOVERSION)$(COMPSUFFIX) SLICE_LIBS = -lslice$(SOVERSION)$(COMPSUFFIX) $(BASELIBS) +endif + +MCPP_RPATH_LINK = -lmcpp +BZIP2_FLAGS = -I../../../bzip2 ICEUTIL_OS_LIBS = -lrpcrt4 -ladvapi32 ICE_OS_LIBS = $(ICEUTIL_OS_LIBS) -lIphlpapi -lws2_32 diff --git a/cpp/config/Make.rules.mak b/cpp/config/Make.rules.mak index ffb2b9a9520..c0b2b14531e 100755 --- a/cpp/config/Make.rules.mak +++ b/cpp/config/Make.rules.mak @@ -120,7 +120,6 @@ includedir = $(ice_dir)\include install_bindir = $(prefix)\bin$(x64suffix) install_libdir = $(prefix)\lib$(x64suffix) install_includedir = $(prefix)\include -install_docdir = $(prefix)\doc install_configdir = $(prefix)\config SETARGV = setargv.obj diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h index c5ecce318c4..6acc0784de3 100644 --- a/cpp/include/Ice/Config.h +++ b/cpp/include/Ice/Config.h @@ -35,7 +35,7 @@ // // Automatically link Ice[D].lib with Visual C++ // -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT) # if defined(ICE_STATIC_LIBS) # pragma comment(lib, "Ice.lib") # elif !defined(ICE_API_EXPORTS) diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h index c5186c413cf..5a7e7ea86cc 100644 --- a/cpp/include/IceSSL/Plugin.h +++ b/cpp/include/IceSSL/Plugin.h @@ -21,10 +21,8 @@ // // Automatically link IceSSL[D].lib with Visual C++ // -#ifdef _MSC_VER -# if defined(ICE_STATIC_LIBS) -# error("IceSSL Plugin does not support static libraries") -# elif !defined(ICE_SSL_API_EXPORTS) +#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT) +# if !defined(ICE_STATIC_LIBS) && !defined(ICE_SSL_API_EXPORTS) # if defined(_DEBUG) # pragma comment(lib, "IceSSLD.lib") # else diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h index 33408be817d..2436f620f97 100644 --- a/cpp/include/IceUtil/Config.h +++ b/cpp/include/IceUtil/Config.h @@ -170,7 +170,7 @@ # include <errno.h> #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT) # if !defined(ICE_STATIC_LIBS) && (!defined(_DLL) || !defined(_MT)) # error "Only multi-threaded DLL libraries can be used with Ice!" # endif diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index 19199e58613..d416ca6f18c 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -23,7 +23,7 @@ // // Automatically link Slice[D].lib with Visual C++ // -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(ICE_NO_PRAGMA_COMMENT) # if defined(ICE_STATIC_LIBS) # pragma comment(lib, "Slice.lib") # elif !defined(SLICE_API_EXPORTS) diff --git a/cpp/include/Slice/PythonUtil.h b/cpp/include/Slice/PythonUtil.h index 8930bc42664..9d5db3c6c99 100644 --- a/cpp/include/Slice/PythonUtil.h +++ b/cpp/include/Slice/PythonUtil.h @@ -56,6 +56,8 @@ SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, const std::string& // SLICE_API void printHeader(IceUtilInternal::Output&); +SLICE_API int compile(int, char*[]); + } } diff --git a/cpp/include/Slice/RubyUtil.h b/cpp/include/Slice/RubyUtil.h index 0095d286c55..4cb97a8826f 100644 --- a/cpp/include/Slice/RubyUtil.h +++ b/cpp/include/Slice/RubyUtil.h @@ -46,6 +46,8 @@ SLICE_API std::string getAbsolute(const Slice::ContainedPtr&, IdentStyle, const // SLICE_API void printHeader(IceUtilInternal::Output&); +SLICE_API int compile(int, char*[]); + } } diff --git a/cpp/src/Glacier2/Makefile b/cpp/src/Glacier2/Makefile index e9ffdb50abc..0b73adca2a7 100644 --- a/cpp/src/Glacier2/Makefile +++ b/cpp/src/Glacier2/Makefile @@ -33,12 +33,12 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I.. $(CPPFLAGS) $(OPENSSL_FLAGS) +CPPFLAGS := -I.. $(CPPFLAGS) SLICE2CPPFLAGS := --include-dir Glacier2 $(SLICE2CPPFLAGS) $(ROUTER): $(OBJS) rm -f $@ - $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(OBJS) -lGlacier2 $(LIBS) -lIceSSL $(OPENSSL_LIBS) + $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(OBJS) -lGlacier2 $(LIBS) -lIceSSL $(OPENSSL_RPATH_LINK) install:: all $(call installprogram,$(ROUTER),$(DESTDIR)$(install_bindir)) diff --git a/cpp/src/Ice/EventLoggerMsg.h b/cpp/src/Ice/EventLoggerMsg.h new file mode 100644 index 00000000000..add0bdde9e0 --- /dev/null +++ b/cpp/src/Ice/EventLoggerMsg.h @@ -0,0 +1,53 @@ + // ********************************************************************** + // + // Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. + // + // This copy of Ice is licensed to you under the terms described in the + // ICE_LICENSE file included in this distribution. + // + // ********************************************************************** +// +// Values are 32 bit values laid out as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---+-+-+-----------------------+-------------------------------+ +// |Sev|C|R| Facility | Code | +// +---+-+-+-----------------------+-------------------------------+ +// +// where +// +// Sev - is the severity code +// +// 00 - Success +// 01 - Informational +// 10 - Warning +// 11 - Error +// +// C - is the Customer code flag +// +// R - is a reserved bit +// +// Facility - is the facility code +// +// Code - is the facility's status code +// +// +// Define the facility codes +// + + +// +// Define the severity codes +// + + +// +// MessageId: EVENT_LOGGER_MSG +// +// MessageText: +// +// %1 +// +#define EVENT_LOGGER_MSG 0x00000000L + diff --git a/cpp/src/Ice/EventLoggerMsg.rc b/cpp/src/Ice/EventLoggerMsg.rc new file mode 100644 index 00000000000..0abcb0fa2c5 --- /dev/null +++ b/cpp/src/Ice/EventLoggerMsg.rc @@ -0,0 +1,2 @@ +LANGUAGE 0x9,0x1 +1 11 "MSG00001.bin" diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp index 4f17d4e8b81..d83e553308d 100644 --- a/cpp/src/Ice/WSTransceiver.cpp +++ b/cpp/src/Ice/WSTransceiver.cpp @@ -23,7 +23,13 @@ #include <IceUtil/DisableWarnings.h> +// Python 2.7 under Windows. +#if _MSC_VER == 1500 +typedef unsigned short uint16_t; +#else #include <stdint.h> +#endif + #include <climits> using namespace std; diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile index cc587d7107f..90292dcb1c1 100644 --- a/cpp/src/IceGrid/Makefile +++ b/cpp/src/IceGrid/Makefile @@ -101,7 +101,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := $(CPPFLAGS) -I.. $(OPENSSL_FLAGS) $(READLINE_FLAGS) +CPPFLAGS := $(CPPFLAGS) -I.. $(READLINE_FLAGS) ICECPPFLAGS := $(ICECPPFLAGS) -I.. SLICE2CPPFLAGS := --checksum --ice --include-dir IceGrid $(SLICE2CPPFLAGS) SLICE2FREEZECMD := $(SLICE2FREEZE) --ice --include-dir IceGrid $(ICECPPFLAGS) @@ -114,12 +114,12 @@ $(ADMIN): $(ADMIN_OBJS) $(LIBTARGETS) $(REGISTRY_SERVER): $(REGISTRY_SVR_OBJS) $(LIBTARGETS) rm -f $@ $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(REGISTRY_SVR_OBJS) -lIceGrid -lIceStorm -lIceStormService -lGlacier2 -lIcePatch2 \ - -lFreeze -lIceBox $(EXPAT_RPATH_LINK) -lIceXML -lIceSSL $(OPENSSL_LIBS) $(LIBS) + -lFreeze -lIceBox $(EXPAT_RPATH_LINK) -lIceXML -lIceSSL $(OPENSSL_RPATH_LINK) $(LIBS) $(NODE_SERVER): $(NODE_SVR_OBJS) $(LIBTARGETS) rm -f $@ $(CXX) $(LDFLAGS) $(LDEXEFLAGS) -o $@ $(NODE_SVR_OBJS) -lIceGrid -lIceStorm -lIceStormService -lIceBox -lGlacier2 \ - -lFreeze -lIcePatch2 $(EXPAT_RPATH_LINK) -lIceXML -lIceSSL $(OPENSSL_LIBS) $(LIBS) + -lFreeze -lIcePatch2 $(EXPAT_RPATH_LINK) -lIceXML -lIceSSL $(OPENSSL_RPATH_LINK) $(LIBS) ../IceGrid/IceLocatorDiscovery.h IceLocatorDiscovery.cpp: \ $(slicedir)/IceLocatorDiscovery/IceLocatorDiscovery.ice $(SLICE2CPP) $(SLICEPARSERLIB) diff --git a/cpp/src/IceGridLib/Makefile b/cpp/src/IceGridLib/Makefile index 8fce12114df..05410c99580 100644 --- a/cpp/src/IceGridLib/Makefile +++ b/cpp/src/IceGridLib/Makefile @@ -42,6 +42,12 @@ ICECPPFLAGS := $(ICECPPFLAGS) -I.. SLICE2CPPFLAGS := --checksum --ice --include-dir IceGrid --dll-export ICE_GRID_API $(SLICE2CPPFLAGS) LINKWITH := -lGlacier2 $(BZIP2_RPATH_LINK) -lIce -lIceUtil +ifeq ($(STATICLIBS),yes) +$(libdir)/$(LIBNAME): $(OBJS) + @mkdir -p $(dir $@) + rm -f $@ + $(call mklib,$@,$(OBJS)) +else $(libdir)/$(LIBFILENAME): $(OBJS) @mkdir -p $(dir $@) rm -f $@ @@ -55,6 +61,7 @@ $(libdir)$(cpp11libdirsuffix)/$(LIBNAME): $(libdir)/$(SONAME) @mkdir -p $(libdir)$(cpp11libdirsuffix) rm -f $@ ln -s $(cpp11sonamedir)$(SONAME) $@ +endif install:: all $(call installlib,$(DESTDIR)$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) diff --git a/cpp/src/IceLocatorDiscovery/PluginI.cpp b/cpp/src/IceLocatorDiscovery/PluginI.cpp index 57f27179510..798ad323974 100644 --- a/cpp/src/IceLocatorDiscovery/PluginI.cpp +++ b/cpp/src/IceLocatorDiscovery/PluginI.cpp @@ -121,6 +121,13 @@ private: const LocatorIPtr _locator; }; +const ::std::string IceGrid_Locator_ids[3] = +{ + "::Ice::Locator", + "::Ice::Object", + "::IceGrid::Locator" +}; + // // The void locator implementation below is used when no locator is found. // diff --git a/cpp/src/IcePatch2/Makefile b/cpp/src/IcePatch2/Makefile index bbc39622404..dfc5fa2fb8a 100644 --- a/cpp/src/IcePatch2/Makefile +++ b/cpp/src/IcePatch2/Makefile @@ -30,7 +30,7 @@ RPATH_DIR = $(LOADER_PATH)/../$(libsubdir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. -I.. $(CPPFLAGS) $(OPENSSL_FLAGS) $(BZIP2_FLAGS) +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(BZIP2_FLAGS) $(SERVER): $(SOBJS) $(LIBTARGETS) rm -f $@ diff --git a/cpp/src/IcePatch2Lib/Makefile b/cpp/src/IcePatch2Lib/Makefile index 80a59f38bfb..3a192a29f3c 100644 --- a/cpp/src/IcePatch2Lib/Makefile +++ b/cpp/src/IcePatch2Lib/Makefile @@ -27,9 +27,9 @@ SDIR = $(slicedir)/IcePatch2 include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I. -I.. $(CPPFLAGS) $(OPENSSL_FLAGS) $(BZIP2_FLAGS) -Wno-deprecated-declarations +CPPFLAGS := -I. -I.. $(CPPFLAGS) $(BZIP2_FLAGS) -Wno-deprecated-declarations SLICE2CPPFLAGS := --ice --include-dir IcePatch2 --dll-export ICE_PATCH2_API $(SLICE2CPPFLAGS) -LINKWITH := $(BZIP2_RPATH_LINK) -lIce -lIceUtil $(OPENSSL_LIBS) $(BZIP2_LIBS) +LINKWITH := $(BZIP2_RPATH_LINK) -lIce -lIceUtil $(BZIP2_LIBS) $(libdir)/$(LIBFILENAME): $(OBJS) @mkdir -p $(dir $@) diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index 237d6f0d686..5f04ffd7361 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -27,7 +27,9 @@ OBJS = Checksum.o \ PHPUtil.o \ Preprocessor.o \ PythonUtil.o \ + Python.o \ RubyUtil.o \ + Ruby.o \ Scanner.o \ Util.o \ ../Slice/Grammar.o diff --git a/cpp/src/Slice/Makefile.mak b/cpp/src/Slice/Makefile.mak index 1d932539f7d..35418099782 100644 --- a/cpp/src/Slice/Makefile.mak +++ b/cpp/src/Slice/Makefile.mak @@ -29,8 +29,12 @@ OBJS = .\Checksum.obj \ .\PHPUtil.obj \ .\Preprocessor.obj \ .\PythonUtil.obj \ + .\Python.obj \ .\RubyUtil.obj \ .\Util.obj \ + .\Ruby.obj \ + .\Scanner.obj \ + .\Util.obj $(BISON_FLEX_OBJS) !include $(top_srcdir)/config/Make.rules.mak diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp new file mode 100644 index 00000000000..a14dcd4a5a2 --- /dev/null +++ b/cpp/src/Slice/Python.cpp @@ -0,0 +1,675 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceUtil/DisableWarnings.h> +#include <IceUtil/IceUtil.h> +#include <IceUtil/Options.h> +#include <IceUtil/StringUtil.h> +#include <IceUtil/CtrlCHandler.h> +#include <IceUtil/Mutex.h> +#include <IceUtil/MutexPtrLock.h> +#include <Slice/Preprocessor.h> +#include <Slice/FileTracker.h> +#include <Slice/PythonUtil.h> +#include <Slice/Util.h> +#include <cstring> + +#include <fstream> + +#include <sys/types.h> +#include <sys/stat.h> + +#ifdef _WIN32 +#include <direct.h> +#endif + +#ifndef _WIN32 +#include <unistd.h> +#endif + +using namespace std; +using namespace Slice; +using namespace Slice::Python; + +namespace +{ + +IceUtil::Mutex* globalMutex = 0; +bool interrupted = false; + +class Init +{ +public: + + Init() + { + globalMutex = new IceUtil::Mutex; + } + + ~Init() + { + delete globalMutex; + globalMutex = 0; + } +}; + +Init init; + +void +interruptedCallback(int /*signal*/) +{ + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); + + interrupted = true; +} + + +// +// For each Slice file Foo.ice we generate Foo_ice.py containing the Python +// mappings. Furthermore, for each Slice module M in Foo.ice, we create a +// Python package of the same name. This package is simply a subdirectory +// containing the special file "__init__.py" that is executed when a Python +// script executes the statement "import M". +// +// Inside __init__.py we add an import statement for Foo_ice, causing +// Foo_ice to be imported implicitly when M is imported. +// +// Of course, another Slice file Bar.ice may contain definitions for the +// same Slice module M, in which case the __init__.py file for M is modified +// to contain an additional import statement for Bar_ice. Therefore a +// Python script executing "import M" implicitly imports the definitions +// from both Foo_ice and Bar_ice. +// +// The __init__.py file also contains import statements for submodules, +// so that importing the top-level module automatically imports all of +// its submodules. +// +// The PackageVisitor class creates the directory hierarchy to mirror the +// Slice module hierarchy, and updates the __init__.py files as necessary. +// +class PackageVisitor : public ParserVisitor +{ +public: + + static void createModules(const UnitPtr&, const string&, const string&); + + virtual void visitModuleEnd(const ModulePtr&); + +private: + + PackageVisitor(StringList&); + + enum ReadState { PreModules, InModules, InSubmodules }; + + static const char* _moduleTag; + static const char* _submoduleTag; + + static void createDirectory(const string&); + + static void addModule(const string&, const string&, const string&); + static void addSubmodule(const string&, const string&, const string&); + + static void readInit(const string&, StringList&, StringList&); + static void writeInit(const string&, const string&, const StringList&, const StringList&); + + StringList& _modules; +}; + +const char* PackageVisitor::_moduleTag = "# Modules:"; +const char* PackageVisitor::_submoduleTag = "# Submodules:"; + +PackageVisitor::PackageVisitor(StringList& modules) : + _modules(modules) +{ +} + +void +PackageVisitor::createModules(const UnitPtr& unit, const string& module, const string& dir) +{ + StringList modules; + PackageVisitor v(modules); + unit->visit(&v, false); + + for(StringList::iterator p = modules.begin(); p != modules.end(); ++p) + { + vector<string> v; + if(!IceUtilInternal::splitString(*p, ".", v)) + { + assert(false); + } + string currentModule; + string path = dir.empty() ? "." : dir; + for(vector<string>::iterator q = v.begin(); q != v.end(); ++q) + { + if(q != v.begin()) + { + addSubmodule(path, currentModule, *q); + currentModule += "."; + } + + currentModule += *q; + path += "/" + *q; + createDirectory(path); + + addModule(path, currentModule, module); + } + } +} + +void +PackageVisitor::visitModuleEnd(const ModulePtr& p) +{ + // + // Collect the most deeply-nested modules. For example, if we have a + // module named M.N.O, then we don't need to keep M or M.N in the list. + // + string abs = getAbsolute(p); + if(find(_modules.begin(), _modules.end(), abs) == _modules.end()) + { + _modules.push_back(abs); + } + string::size_type pos = abs.rfind('.'); + if(pos != string::npos) + { + string parent = abs.substr(0, pos); + _modules.remove(parent); + } +} + +void +PackageVisitor::createDirectory(const string& dir) +{ + struct stat st; + int result; + result = stat(dir.c_str(), &st); + if(result == 0) + { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create package directory `" << dir + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } + return; + } +#ifdef _WIN32 + result = _mkdir(dir.c_str()); +#else + result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); +#endif + + if(result != 0) + { + ostringstream os; + os << "cannot create directory `" << dir << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + + FileTracker::instance()->addDirectory(dir); +} + +void +PackageVisitor::addModule(const string& dir, const string& module, const string& name) +{ + // + // Add a module to the set of imported modules in __init__.py. + // + StringList modules, submodules; + readInit(dir, modules, submodules); + StringList::iterator p = find(modules.begin(), modules.end(), name); + if(p == modules.end()) + { + modules.push_back(name); + writeInit(dir, module, modules, submodules); + } +} + +void +PackageVisitor::addSubmodule(const string& dir, const string& module, const string& name) +{ + // + // Add a submodule to the set of imported modules in __init__.py. + // + StringList modules, submodules; + readInit(dir, modules, submodules); + StringList::iterator p = find(submodules.begin(), submodules.end(), name); + if(p == submodules.end()) + { + submodules.push_back(name); + writeInit(dir, module, modules, submodules); + } +} + +void +PackageVisitor::readInit(const string& dir, StringList& modules, StringList& submodules) +{ + string initPath = dir + "/__init__.py"; + + struct stat st; + if(stat(initPath.c_str(), &st) == 0) + { + ifstream in(initPath.c_str()); + if(!in) + { + ostringstream os; + os << "cannot open file `" << initPath << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + + ReadState state = PreModules; + char line[1024]; + while(in.getline(line, 1024)) + { + string s = line; + if(s.find(_moduleTag) == 0) + { + if(state != PreModules) + { + break; + } + state = InModules; + } + else if(s.find(_submoduleTag) == 0) + { + if(state != InModules) + { + break; + } + state = InSubmodules; + } + else if(s.find("import") == 0) + { + if(state == PreModules) + { + continue; + } + + if(s.size() < 8) + { + ostringstream os; + os << "invalid line `" << s << "' in `" << initPath << "'"; + throw os.str(); + } + + string name = s.substr(7); + if(state == InModules) + { + modules.push_back(name); + } + else + { + // + // This case occurs in old (Ice <= 3.5.1) code that used implicit + // relative imports, such as: + // + // File: outer/__init__.py + // + // import inner + // + // These aren't supported in Python 3. We'll translate these into + // explicit relative imports: + // + // from . import inner + // + submodules.push_back(name); + } + } + else if(s.find("from . import") == 0) + { + if(state != InSubmodules) + { + ostringstream os; + os << "invalid line `" << s << "' in `" << initPath << "'"; + throw os.str(); + } + + if(s.size() < 15) + { + ostringstream os; + os << "invalid line `" << s << "' in `" << initPath << "'"; + throw os.str(); + } + + submodules.push_back(s.substr(14)); + } + } + + if(state != InSubmodules) + { + ostringstream os; + os << "invalid format in `" << initPath << "'" << endl; + throw os.str(); + } + } +} + +void +PackageVisitor::writeInit(const string& dir, const string& name, const StringList& modules, + const StringList& submodules) +{ + string initPath = dir + "/__init__.py"; + + ofstream os(initPath.c_str()); + if(!os) + { + ostringstream os; + os << "cannot open file `" << initPath << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(initPath); + + os << "# Generated by slice2py - DO NOT EDIT!" << endl + << "#" << endl; + os << endl + << "import Ice" << endl + << "Ice.updateModule(\"" << name << "\")" << endl + << endl; + os << _moduleTag << endl; + for(StringList::const_iterator p = modules.begin(); p != modules.end(); ++p) + { + os << "import " << *p << endl; + } + + os << endl; + os << _submoduleTag << endl; + for(StringList::const_iterator p = submodules.begin(); p != submodules.end(); ++p) + { + os << "from . import " << *p << endl; + } +} + +void +usage(const char* n) +{ + getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; + getErrorStream() << + "Options:\n" + "-h, --help Show this message.\n" + "-v, --version Display the Ice version.\n" + "-DNAME Define NAME as 1.\n" + "-DNAME=DEF Define NAME as DEF.\n" + "-UNAME Remove any definition for NAME.\n" + "-IDIR Put DIR in the include file search path.\n" + "-E Print preprocessor output on stdout.\n" + "--output-dir DIR Create files in the directory DIR.\n" + "--depend Generate Makefile dependencies.\n" + "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only).\n" + "--underscore Permit underscores in Slice identifiers.\n" + "--all Generate code for Slice definitions in included files.\n" + "--checksum Generate checksums for Slice definitions.\n" + "--prefix PREFIX Prepend filenames of Python modules with PREFIX.\n" + ; +} + +} + +int +Slice::Python::compile(int argc, char* argv[]) +{ + IceUtilInternal::Options opts; + opts.addOpt("h", "help"); + opts.addOpt("v", "version"); + opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); + opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); + opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); + opts.addOpt("E"); + opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg); + opts.addOpt("", "depend"); + opts.addOpt("d", "debug"); + opts.addOpt("", "ice"); + opts.addOpt("", "underscore"); + opts.addOpt("", "all"); + opts.addOpt("", "no-package"); + opts.addOpt("", "checksum"); + opts.addOpt("", "prefix", IceUtilInternal::Options::NeedArg); + + vector<string> args; + try + { + args = opts.parse(argc, const_cast<const char**>(argv)); + } + catch(const IceUtilInternal::BadOptException& e) + { + getErrorStream() << argv[0] << ": error: " << e.reason << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + if(opts.isSet("help")) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + + if(opts.isSet("version")) + { + getErrorStream() << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; + } + + vector<string> cppArgs; + vector<string> optargs = opts.argVec("D"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs.push_back("-D" + *i); + } + + optargs = opts.argVec("U"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs.push_back("-U" + *i); + } + + vector<string> includePaths = opts.argVec("I"); + for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) + { + cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i)); + } + + bool preprocess = opts.isSet("E"); + + string output = opts.optArg("output-dir"); + + bool depend = opts.isSet("depend"); + + bool debug = opts.isSet("debug"); + + bool ice = opts.isSet("ice"); + + bool underscore = opts.isSet("underscore"); + + bool all = opts.isSet("all"); + + bool noPackage = opts.isSet("no-package"); + + bool checksum = opts.isSet("checksum"); + + string prefix = opts.optArg("prefix"); + + if(args.empty()) + { + getErrorStream() << argv[0] << ": error: no input file" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + int status = EXIT_SUCCESS; + + IceUtil::CtrlCHandler ctrlCHandler; + ctrlCHandler.setCallback(interruptedCallback); + + bool keepComments = true; + + for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i) + { + // + // Ignore duplicates. + // + vector<string>::iterator p = find(args.begin(), args.end(), *i); + if(p != i) + { + continue; + } + + if(depend) + { + PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); + FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2PY__"); + + if(cppHandle == 0) + { + return EXIT_FAILURE; + } + + UnitPtr u = Unit::createUnit(false, false, ice, underscore); + int parseStatus = u->parse(*i, cppHandle, debug); + u->destroy(); + + if(parseStatus == EXIT_FAILURE) + { + return EXIT_FAILURE; + } + + if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths, + "-D__SLICE2PY__", "", prefix)) + { + return EXIT_FAILURE; + } + + if(!icecpp->close()) + { + return EXIT_FAILURE; + } + } + else + { + PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); + FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__"); + + if(cppHandle == 0) + { + return EXIT_FAILURE; + } + + if(preprocess) + { + char buf[4096]; + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) + { + if(fputs(buf, stdout) == EOF) + { + return EXIT_FAILURE; + } + } + if(!icecpp->close()) + { + return EXIT_FAILURE; + } + } + else + { + UnitPtr u = Unit::createUnit(false, all, ice, underscore); + int parseStatus = u->parse(*i, cppHandle, debug); + + if(!icecpp->close()) + { + u->destroy(); + return EXIT_FAILURE; + } + + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + else + { + string base = icecpp->getBaseName(); + string::size_type pos = base.find_last_of("/\\"); + if(pos != string::npos) + { + base.erase(0, pos + 1); + } + + // + // Append the suffix "_ice" to the filename in order to avoid any conflicts + // with Slice module names. For example, if the file Test.ice defines a + // Slice module named "Test", then we couldn't create a Python package named + // "Test" and also call the generated file "Test.py". + // + string file = prefix + base + "_ice.py"; + if(!output.empty()) + { + file = output + '/' + file; + } + + try + { + IceUtilInternal::Output out; + out.open(file.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open`" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(file); + + printHeader(out); + printGeneratedHeader(out, base + ".ice", "#"); + // + // Generate the Python mapping. + // + generate(u, all, checksum, includePaths, out); + + out.close(); + + // + // Create or update the Python package hierarchy. + // + if(!noPackage) + { + PackageVisitor::createModules(u, prefix + base + "_ice", output); + } + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + getErrorStream() << argv[0] << ": error: " << ex.reason() << endl; + return EXIT_FAILURE; + } + catch(const string& err) + { + FileTracker::instance()->cleanup(); + getErrorStream() << argv[0] << ": error: " << err << endl; + status = EXIT_FAILURE; + } + } + + u->destroy(); + } + } + + { + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); + + if(interrupted) + { + FileTracker::instance()->cleanup(); + return EXIT_FAILURE; + } + } + } + + return status; +} diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp new file mode 100644 index 00000000000..c623bfc8696 --- /dev/null +++ b/cpp/src/Slice/Ruby.cpp @@ -0,0 +1,317 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceUtil/DisableWarnings.h> +#include <IceUtil/Options.h> +#include <IceUtil/CtrlCHandler.h> +#include <IceUtil/Mutex.h> +#include <IceUtil/MutexPtrLock.h> +#include <Slice/Preprocessor.h> +#include <Slice/FileTracker.h> +#include <Slice/RubyUtil.h> +#include <Slice/Util.h> + +#include <string.h> + +using namespace std; +using namespace Slice; +using namespace Slice::Ruby; + +namespace +{ + +IceUtil::Mutex* globalMutex = 0; +bool interrupted = false; + +class Init +{ +public: + + Init() + { + globalMutex = new IceUtil::Mutex; + } + + ~Init() + { + delete globalMutex; + globalMutex = 0; + } +}; + +Init init; + +void +interruptedCallback(int /*signal*/) +{ + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); + + interrupted = true; +} + +void +usage(const char* n) +{ + getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; + getErrorStream() << + "Options:\n" + "-h, --help Show this message.\n" + "-v, --version Display the Ice version.\n" + "-DNAME Define NAME as 1.\n" + "-DNAME=DEF Define NAME as DEF.\n" + "-UNAME Remove any definition for NAME.\n" + "-IDIR Put DIR in the include file search path.\n" + "-E Print preprocessor output on stdout.\n" + "--output-dir DIR Create files in the directory DIR.\n" + "--depend Generate Makefile dependencies.\n" + "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only).\n" + "--underscore Permit underscores in Slice identifiers.\n" + "--all Generate code for Slice definitions in included files.\n" + "--checksum Generate checksums for Slice definitions.\n" + ; +} + +} + +int +Slice::Ruby::compile(int argc, char* argv[]) +{ + IceUtilInternal::Options opts; + opts.addOpt("h", "help"); + opts.addOpt("v", "version"); + opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); + opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); + opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); + opts.addOpt("E"); + opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg); + opts.addOpt("", "depend"); + opts.addOpt("d", "debug"); + opts.addOpt("", "ice"); + opts.addOpt("", "underscore"); + opts.addOpt("", "all"); + opts.addOpt("", "checksum"); + + vector<string> args; + try + { + args = opts.parse(argc, const_cast<const char**>(argv)); + } + catch(const IceUtilInternal::BadOptException& e) + { + getErrorStream() << argv[0] << ": error: " << e.reason << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + if(opts.isSet("help")) + { + usage(argv[0]); + return EXIT_SUCCESS; + } + + if(opts.isSet("version")) + { + getErrorStream() << ICE_STRING_VERSION << endl; + return EXIT_SUCCESS; + } + + vector<string> cppArgs; + vector<string> optargs = opts.argVec("D"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs.push_back("-D" + *i); + } + + optargs = opts.argVec("U"); + for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) + { + cppArgs.push_back("-U" + *i); + } + + vector<string> includePaths = opts.argVec("I"); + for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) + { + cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i)); + } + + bool preprocess = opts.isSet("E"); + + string output = opts.optArg("output-dir"); + + bool depend = opts.isSet("depend"); + + bool debug = opts.isSet("debug"); + + bool ice = opts.isSet("ice"); + + bool underscore = opts.isSet("underscore"); + + bool all = opts.isSet("all"); + + bool checksum = opts.isSet("checksum"); + + if(args.empty()) + { + getErrorStream() << argv[0] << ": error: no input file" << endl; + usage(argv[0]); + return EXIT_FAILURE; + } + + int status = EXIT_SUCCESS; + + IceUtil::CtrlCHandler ctrlCHandler; + ctrlCHandler.setCallback(interruptedCallback); + + for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i) + { + // + // Ignore duplicates. + // + vector<string>::iterator p = find(args.begin(), args.end(), *i); + if(p != i) + { + continue; + } + + if(depend) + { + PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); + FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2RB__"); + + if(cppHandle == 0) + { + return EXIT_FAILURE; + } + + UnitPtr u = Unit::createUnit(false, false, ice, underscore); + int parseStatus = u->parse(*i, cppHandle, debug); + u->destroy(); + + if(parseStatus == EXIT_FAILURE) + { + return EXIT_FAILURE; + } + + if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths, + "-D__SLICE2RB__")) + { + return EXIT_FAILURE; + } + + if(!icecpp->close()) + { + return EXIT_FAILURE; + } + } + else + { + PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); + FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2RB__"); + + if(cppHandle == 0) + { + return EXIT_FAILURE; + } + + if(preprocess) + { + char buf[4096]; + while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) + { + if(fputs(buf, stdout) == EOF) + { + return EXIT_FAILURE; + } + } + if(!icecpp->close()) + { + return EXIT_FAILURE; + } + } + else + { + UnitPtr u = Unit::createUnit(false, all, ice, underscore); + int parseStatus = u->parse(*i, cppHandle, debug); + + if(!icecpp->close()) + { + u->destroy(); + return EXIT_FAILURE; + } + + if(parseStatus == EXIT_FAILURE) + { + status = EXIT_FAILURE; + } + else + { + string base = icecpp->getBaseName(); + string::size_type pos = base.find_last_of("/\\"); + if(pos != string::npos) + { + base.erase(0, pos + 1); + } + + string file = base + ".rb"; + if(!output.empty()) + { + file = output + '/' + file; + } + + try + { + IceUtilInternal::Output out; + out.open(file.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open`" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(file); + + printHeader(out); + printGeneratedHeader(out, base + ".ice", "#"); + + // + // Generate the Ruby mapping. + // + generate(u, all, checksum, includePaths, out); + + out.close(); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup + // any created files. + FileTracker::instance()->cleanup(); + u->destroy(); + getErrorStream() << argv[0] << ": error: " << ex.reason() << endl; + return EXIT_FAILURE; + } + } + + u->destroy(); + } + } + + { + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); + + if(interrupted) + { + FileTracker::instance()->cleanup(); + return EXIT_FAILURE; + } + } + } + + return status; +} diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 3e9a634ac46..749749ff1bd 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -7,678 +7,19 @@ // // ********************************************************************** -#include <IceUtil/DisableWarnings.h> -#include <IceUtil/IceUtil.h> -#include <IceUtil/Options.h> -#include <IceUtil/StringUtil.h> -#include <IceUtil/CtrlCHandler.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/MutexPtrLock.h> -#include <Slice/Preprocessor.h> -#include <Slice/FileTracker.h> #include <Slice/PythonUtil.h> #include <Slice/Util.h> -#include <cstring> - -#include <fstream> - -#include <sys/types.h> -#include <sys/stat.h> - -#ifdef _WIN32 -#include <direct.h> -#endif - -#ifndef _WIN32 -#include <unistd.h> -#endif using namespace std; using namespace Slice; using namespace Slice::Python; -namespace -{ - -IceUtil::Mutex* globalMutex = 0; -bool interrupted = false; - -class Init -{ -public: - - Init() - { - globalMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete globalMutex; - globalMutex = 0; - } -}; - -Init init; - -} - -void -interruptedCallback(int /*signal*/) -{ - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); - - interrupted = true; -} - -// -// For each Slice file Foo.ice we generate Foo_ice.py containing the Python -// mappings. Furthermore, for each Slice module M in Foo.ice, we create a -// Python package of the same name. This package is simply a subdirectory -// containing the special file "__init__.py" that is executed when a Python -// script executes the statement "import M". -// -// Inside __init__.py we add an import statement for Foo_ice, causing -// Foo_ice to be imported implicitly when M is imported. -// -// Of course, another Slice file Bar.ice may contain definitions for the -// same Slice module M, in which case the __init__.py file for M is modified -// to contain an additional import statement for Bar_ice. Therefore a -// Python script executing "import M" implicitly imports the definitions -// from both Foo_ice and Bar_ice. -// -// The __init__.py file also contains import statements for submodules, -// so that importing the top-level module automatically imports all of -// its submodules. -// -// The PackageVisitor class creates the directory hierarchy to mirror the -// Slice module hierarchy, and updates the __init__.py files as necessary. -// -class PackageVisitor : public ParserVisitor -{ -public: - - static void createModules(const UnitPtr&, const string&, const string&); - - virtual void visitModuleEnd(const ModulePtr&); - -private: - - PackageVisitor(StringList&); - - enum ReadState { PreModules, InModules, InSubmodules }; - - static const char* _moduleTag; - static const char* _submoduleTag; - - static void createDirectory(const string&); - - static void addModule(const string&, const string&, const string&); - static void addSubmodule(const string&, const string&, const string&); - - static void readInit(const string&, StringList&, StringList&); - static void writeInit(const string&, const string&, const StringList&, const StringList&); - - StringList& _modules; -}; - -const char* PackageVisitor::_moduleTag = "# Modules:"; -const char* PackageVisitor::_submoduleTag = "# Submodules:"; - -PackageVisitor::PackageVisitor(StringList& modules) : - _modules(modules) -{ -} - -void -PackageVisitor::createModules(const UnitPtr& unit, const string& module, const string& dir) -{ - StringList modules; - PackageVisitor v(modules); - unit->visit(&v, false); - - for(StringList::iterator p = modules.begin(); p != modules.end(); ++p) - { - vector<string> v; - if(!IceUtilInternal::splitString(*p, ".", v)) - { - assert(false); - } - string currentModule; - string path = dir.empty() ? "." : dir; - for(vector<string>::iterator q = v.begin(); q != v.end(); ++q) - { - if(q != v.begin()) - { - addSubmodule(path, currentModule, *q); - currentModule += "."; - } - - currentModule += *q; - path += "/" + *q; - createDirectory(path); - - addModule(path, currentModule, module); - } - } -} - -void -PackageVisitor::visitModuleEnd(const ModulePtr& p) -{ - // - // Collect the most deeply-nested modules. For example, if we have a - // module named M.N.O, then we don't need to keep M or M.N in the list. - // - string abs = getAbsolute(p); - if(find(_modules.begin(), _modules.end(), abs) == _modules.end()) - { - _modules.push_back(abs); - } - string::size_type pos = abs.rfind('.'); - if(pos != string::npos) - { - string parent = abs.substr(0, pos); - _modules.remove(parent); - } -} - -void -PackageVisitor::createDirectory(const string& dir) -{ - struct stat st; - int result; - result = stat(dir.c_str(), &st); - if(result == 0) - { - if(!(st.st_mode & S_IFDIR)) - { - ostringstream os; - os << "failed to create package directory `" << dir - << "': file already exists and is not a directory"; - throw FileException(__FILE__, __LINE__, os.str()); - } - return; - } -#ifdef _WIN32 - result = _mkdir(dir.c_str()); -#else - result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); -#endif - - if(result != 0) - { - ostringstream os; - os << "cannot create directory `" << dir << "': " << strerror(errno); - throw FileException(__FILE__, __LINE__, os.str()); - } - - FileTracker::instance()->addDirectory(dir); -} - -void -PackageVisitor::addModule(const string& dir, const string& module, const string& name) -{ - // - // Add a module to the set of imported modules in __init__.py. - // - StringList modules, submodules; - readInit(dir, modules, submodules); - StringList::iterator p = find(modules.begin(), modules.end(), name); - if(p == modules.end()) - { - modules.push_back(name); - writeInit(dir, module, modules, submodules); - } -} - -void -PackageVisitor::addSubmodule(const string& dir, const string& module, const string& name) -{ - // - // Add a submodule to the set of imported modules in __init__.py. - // - StringList modules, submodules; - readInit(dir, modules, submodules); - StringList::iterator p = find(submodules.begin(), submodules.end(), name); - if(p == submodules.end()) - { - submodules.push_back(name); - writeInit(dir, module, modules, submodules); - } -} - -void -PackageVisitor::readInit(const string& dir, StringList& modules, StringList& submodules) -{ - string initPath = dir + "/__init__.py"; - - struct stat st; - if(stat(initPath.c_str(), &st) == 0) - { - ifstream in(initPath.c_str()); - if(!in) - { - ostringstream os; - os << "cannot open file `" << initPath << "': " << strerror(errno); - throw FileException(__FILE__, __LINE__, os.str()); - } - - ReadState state = PreModules; - char line[1024]; - while(in.getline(line, 1024)) - { - string s = line; - if(s.find(_moduleTag) == 0) - { - if(state != PreModules) - { - break; - } - state = InModules; - } - else if(s.find(_submoduleTag) == 0) - { - if(state != InModules) - { - break; - } - state = InSubmodules; - } - else if(s.find("import") == 0) - { - if(state == PreModules) - { - continue; - } - - if(s.size() < 8) - { - ostringstream os; - os << "invalid line `" << s << "' in `" << initPath << "'"; - throw os.str(); - } - - string name = s.substr(7); - if(state == InModules) - { - modules.push_back(name); - } - else - { - // - // This case occurs in old (Ice <= 3.5.1) code that used implicit - // relative imports, such as: - // - // File: outer/__init__.py - // - // import inner - // - // These aren't supported in Python 3. We'll translate these into - // explicit relative imports: - // - // from . import inner - // - submodules.push_back(name); - } - } - else if(s.find("from . import") == 0) - { - if(state != InSubmodules) - { - ostringstream os; - os << "invalid line `" << s << "' in `" << initPath << "'"; - throw os.str(); - } - - if(s.size() < 15) - { - ostringstream os; - os << "invalid line `" << s << "' in `" << initPath << "'"; - throw os.str(); - } - - submodules.push_back(s.substr(14)); - } - } - - if(state != InSubmodules) - { - ostringstream os; - os << "invalid format in `" << initPath << "'" << endl; - throw os.str(); - } - } -} - -void -PackageVisitor::writeInit(const string& dir, const string& name, const StringList& modules, - const StringList& submodules) -{ - string initPath = dir + "/__init__.py"; - - ofstream os(initPath.c_str()); - if(!os) - { - ostringstream os; - os << "cannot open file `" << initPath << "': " << strerror(errno); - throw FileException(__FILE__, __LINE__, os.str()); - } - FileTracker::instance()->addFile(initPath); - - os << "# Generated by slice2py - DO NOT EDIT!" << endl - << "#" << endl; - os << endl - << "import Ice" << endl - << "Ice.updateModule(\"" << name << "\")" << endl - << endl; - os << _moduleTag << endl; - for(StringList::const_iterator p = modules.begin(); p != modules.end(); ++p) - { - os << "import " << *p << endl; - } - - os << endl; - os << _submoduleTag << endl; - for(StringList::const_iterator p = submodules.begin(); p != submodules.end(); ++p) - { - os << "from . import " << *p << endl; - } -} - -void -usage(const char* n) -{ - getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; - getErrorStream() << - "Options:\n" - "-h, --help Show this message.\n" - "-v, --version Display the Ice version.\n" - "-DNAME Define NAME as 1.\n" - "-DNAME=DEF Define NAME as DEF.\n" - "-UNAME Remove any definition for NAME.\n" - "-IDIR Put DIR in the include file search path.\n" - "-E Print preprocessor output on stdout.\n" - "--output-dir DIR Create files in the directory DIR.\n" - "--depend Generate Makefile dependencies.\n" - "-d, --debug Print debug messages.\n" - "--ice Permit `Ice' prefix (for building Ice source code only).\n" - "--underscore Permit underscores in Slice identifiers.\n" - "--all Generate code for Slice definitions in included files.\n" - "--checksum Generate checksums for Slice definitions.\n" - "--prefix PREFIX Prepend filenames of Python modules with PREFIX.\n" - ; -} - -int -compile(int argc, char* argv[]) -{ - IceUtilInternal::Options opts; - opts.addOpt("h", "help"); - opts.addOpt("v", "version"); - opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("E"); - opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "depend"); - opts.addOpt("d", "debug"); - opts.addOpt("", "ice"); - opts.addOpt("", "underscore"); - opts.addOpt("", "all"); - opts.addOpt("", "no-package"); - opts.addOpt("", "checksum"); - opts.addOpt("", "prefix", IceUtilInternal::Options::NeedArg); - - vector<string> args; - try - { - args = opts.parse(argc, const_cast<const char**>(argv)); - } - catch(const IceUtilInternal::BadOptException& e) - { - getErrorStream() << argv[0] << ": error: " << e.reason << endl; - usage(argv[0]); - return EXIT_FAILURE; - } - - if(opts.isSet("help")) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - - if(opts.isSet("version")) - { - getErrorStream() << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - - vector<string> cppArgs; - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-D" + *i); - } - - optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-U" + *i); - } - - vector<string> includePaths = opts.argVec("I"); - for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) - { - cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i)); - } - - bool preprocess = opts.isSet("E"); - - string output = opts.optArg("output-dir"); - - bool depend = opts.isSet("depend"); - - bool debug = opts.isSet("debug"); - - bool ice = opts.isSet("ice"); - - bool underscore = opts.isSet("underscore"); - - bool all = opts.isSet("all"); - - bool noPackage = opts.isSet("no-package"); - - bool checksum = opts.isSet("checksum"); - - string prefix = opts.optArg("prefix"); - - if(args.empty()) - { - getErrorStream() << argv[0] << ": error: no input file" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } - - int status = EXIT_SUCCESS; - - IceUtil::CtrlCHandler ctrlCHandler; - ctrlCHandler.setCallback(interruptedCallback); - - bool keepComments = true; - - for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i) - { - // - // Ignore duplicates. - // - vector<string>::iterator p = find(args.begin(), args.end(), *i); - if(p != i) - { - continue; - } - - if(depend) - { - PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2PY__"); - - if(cppHandle == 0) - { - return EXIT_FAILURE; - } - - UnitPtr u = Unit::createUnit(false, false, ice, underscore); - int parseStatus = u->parse(*i, cppHandle, debug); - u->destroy(); - - if(parseStatus == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths, - "-D__SLICE2PY__", "", prefix)) - { - return EXIT_FAILURE; - } - - if(!icecpp->close()) - { - return EXIT_FAILURE; - } - } - else - { - PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__"); - - if(cppHandle == 0) - { - return EXIT_FAILURE; - } - - if(preprocess) - { - char buf[4096]; - while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) - { - if(fputs(buf, stdout) == EOF) - { - return EXIT_FAILURE; - } - } - if(!icecpp->close()) - { - return EXIT_FAILURE; - } - } - else - { - UnitPtr u = Unit::createUnit(false, all, ice, underscore); - int parseStatus = u->parse(*i, cppHandle, debug); - - if(!icecpp->close()) - { - u->destroy(); - return EXIT_FAILURE; - } - - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - else - { - string base = icecpp->getBaseName(); - string::size_type pos = base.find_last_of("/\\"); - if(pos != string::npos) - { - base.erase(0, pos + 1); - } - - // - // Append the suffix "_ice" to the filename in order to avoid any conflicts - // with Slice module names. For example, if the file Test.ice defines a - // Slice module named "Test", then we couldn't create a Python package named - // "Test" and also call the generated file "Test.py". - // - string file = prefix + base + "_ice.py"; - if(!output.empty()) - { - file = output + '/' + file; - } - - try - { - IceUtilInternal::Output out; - out.open(file.c_str()); - if(!out) - { - ostringstream os; - os << "cannot open`" << file << "': " << strerror(errno); - throw FileException(__FILE__, __LINE__, os.str()); - } - FileTracker::instance()->addFile(file); - - printHeader(out); - printGeneratedHeader(out, base + ".ice", "#"); - // - // Generate the Python mapping. - // - generate(u, all, checksum, includePaths, out); - - out.close(); - - // - // Create or update the Python package hierarchy. - // - if(!noPackage) - { - PackageVisitor::createModules(u, prefix + base + "_ice", output); - } - } - catch(const Slice::FileException& ex) - { - // If a file could not be created, then cleanup any - // created files. - FileTracker::instance()->cleanup(); - u->destroy(); - getErrorStream() << argv[0] << ": error: " << ex.reason() << endl; - return EXIT_FAILURE; - } - catch(const string& err) - { - FileTracker::instance()->cleanup(); - getErrorStream() << argv[0] << ": error: " << err << endl; - status = EXIT_FAILURE; - } - } - - u->destroy(); - } - } - - { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); - - if(interrupted) - { - FileTracker::instance()->cleanup(); - return EXIT_FAILURE; - } - } - } - - return status; -} - int main(int argc, char* argv[]) { try { - return compile(argc, argv); + return Slice::Python::compile(argc, argv); } catch(const std::exception& ex) { diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 11714d2263e..337e01044c2 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -7,332 +7,19 @@ // // ********************************************************************** -#include <IceUtil/DisableWarnings.h> -#include <IceUtil/Options.h> -#include <IceUtil/CtrlCHandler.h> -#include <IceUtil/Mutex.h> -#include <IceUtil/MutexPtrLock.h> -#include <Slice/Preprocessor.h> -#include <Slice/FileTracker.h> #include <Slice/RubyUtil.h> #include <Slice/Util.h> -#include <fstream> - -#include <sys/types.h> -#include <sys/stat.h> - -#ifdef _WIN32 -# include <direct.h> -#else -# include <unistd.h> -#endif - -#include <string.h> - using namespace std; using namespace Slice; using namespace Slice::Ruby; -namespace -{ - -IceUtil::Mutex* globalMutex = 0; -bool interrupted = false; - -class Init -{ -public: - - Init() - { - globalMutex = new IceUtil::Mutex; - } - - ~Init() - { - delete globalMutex; - globalMutex = 0; - } -}; - -Init init; - -} - -void -interruptedCallback(int /*signal*/) -{ - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); - - interrupted = true; -} - -void -usage(const char* n) -{ - getErrorStream() << "Usage: " << n << " [options] slice-files...\n"; - getErrorStream() << - "Options:\n" - "-h, --help Show this message.\n" - "-v, --version Display the Ice version.\n" - "-DNAME Define NAME as 1.\n" - "-DNAME=DEF Define NAME as DEF.\n" - "-UNAME Remove any definition for NAME.\n" - "-IDIR Put DIR in the include file search path.\n" - "-E Print preprocessor output on stdout.\n" - "--output-dir DIR Create files in the directory DIR.\n" - "--depend Generate Makefile dependencies.\n" - "-d, --debug Print debug messages.\n" - "--ice Permit `Ice' prefix (for building Ice source code only).\n" - "--underscore Permit underscores in Slice identifiers.\n" - "--all Generate code for Slice definitions in included files.\n" - "--checksum Generate checksums for Slice definitions.\n" - ; -} - -int -compile(int argc, char* argv[]) -{ - IceUtilInternal::Options opts; - opts.addOpt("h", "help"); - opts.addOpt("v", "version"); - opts.addOpt("D", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("U", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "", IceUtilInternal::Options::Repeat); - opts.addOpt("E"); - opts.addOpt("", "output-dir", IceUtilInternal::Options::NeedArg); - opts.addOpt("", "depend"); - opts.addOpt("d", "debug"); - opts.addOpt("", "ice"); - opts.addOpt("", "underscore"); - opts.addOpt("", "all"); - opts.addOpt("", "checksum"); - - vector<string> args; - try - { - args = opts.parse(argc, const_cast<const char**>(argv)); - } - catch(const IceUtilInternal::BadOptException& e) - { - getErrorStream() << argv[0] << ": error: " << e.reason << endl; - usage(argv[0]); - return EXIT_FAILURE; - } - - if(opts.isSet("help")) - { - usage(argv[0]); - return EXIT_SUCCESS; - } - - if(opts.isSet("version")) - { - getErrorStream() << ICE_STRING_VERSION << endl; - return EXIT_SUCCESS; - } - - vector<string> cppArgs; - vector<string> optargs = opts.argVec("D"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-D" + *i); - } - - optargs = opts.argVec("U"); - for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i) - { - cppArgs.push_back("-U" + *i); - } - - vector<string> includePaths = opts.argVec("I"); - for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i) - { - cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i)); - } - - bool preprocess = opts.isSet("E"); - - string output = opts.optArg("output-dir"); - - bool depend = opts.isSet("depend"); - - bool debug = opts.isSet("debug"); - - bool ice = opts.isSet("ice"); - - bool underscore = opts.isSet("underscore"); - - bool all = opts.isSet("all"); - - bool checksum = opts.isSet("checksum"); - - if(args.empty()) - { - getErrorStream() << argv[0] << ": error: no input file" << endl; - usage(argv[0]); - return EXIT_FAILURE; - } - - int status = EXIT_SUCCESS; - - IceUtil::CtrlCHandler ctrlCHandler; - ctrlCHandler.setCallback(interruptedCallback); - - for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i) - { - // - // Ignore duplicates. - // - vector<string>::iterator p = find(args.begin(), args.end(), *i); - if(p != i) - { - continue; - } - - if(depend) - { - PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2RB__"); - - if(cppHandle == 0) - { - return EXIT_FAILURE; - } - - UnitPtr u = Unit::createUnit(false, false, ice, underscore); - int parseStatus = u->parse(*i, cppHandle, debug); - u->destroy(); - - if(parseStatus == EXIT_FAILURE) - { - return EXIT_FAILURE; - } - - if(!icecpp->printMakefileDependencies(Preprocessor::Ruby, includePaths, - "-D__SLICE2RB__")) - { - return EXIT_FAILURE; - } - - if(!icecpp->close()) - { - return EXIT_FAILURE; - } - } - else - { - PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs); - FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2RB__"); - - if(cppHandle == 0) - { - return EXIT_FAILURE; - } - - if(preprocess) - { - char buf[4096]; - while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL) - { - if(fputs(buf, stdout) == EOF) - { - return EXIT_FAILURE; - } - } - if(!icecpp->close()) - { - return EXIT_FAILURE; - } - } - else - { - UnitPtr u = Unit::createUnit(false, all, ice, underscore); - int parseStatus = u->parse(*i, cppHandle, debug); - - if(!icecpp->close()) - { - u->destroy(); - return EXIT_FAILURE; - } - - if(parseStatus == EXIT_FAILURE) - { - status = EXIT_FAILURE; - } - else - { - string base = icecpp->getBaseName(); - string::size_type pos = base.find_last_of("/\\"); - if(pos != string::npos) - { - base.erase(0, pos + 1); - } - - string file = base + ".rb"; - if(!output.empty()) - { - file = output + '/' + file; - } - - try - { - IceUtilInternal::Output out; - out.open(file.c_str()); - if(!out) - { - ostringstream os; - os << "cannot open`" << file << "': " << strerror(errno); - throw FileException(__FILE__, __LINE__, os.str()); - } - FileTracker::instance()->addFile(file); - - printHeader(out); - printGeneratedHeader(out, base + ".ice", "#"); - - // - // Generate the Ruby mapping. - // - generate(u, all, checksum, includePaths, out); - - out.close(); - } - catch(const Slice::FileException& ex) - { - // If a file could not be created, then cleanup - // any created files. - FileTracker::instance()->cleanup(); - u->destroy(); - getErrorStream() << argv[0] << ": error: " << ex.reason() << endl; - return EXIT_FAILURE; - } - } - - u->destroy(); - } - } - - { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); - - if(interrupted) - { - FileTracker::instance()->cleanup(); - return EXIT_FAILURE; - } - } - } - - return status; -} - int main(int argc, char* argv[]) { try { - return compile(argc, argv); + return Slice::Ruby::compile(argc, argv); } catch(const std::exception& ex) { diff --git a/cs/config/Make.rules.cs b/cs/config/Make.rules.cs index 21c9c3df6fa..b90ed220591 100644 --- a/cs/config/Make.rules.cs +++ b/cs/config/Make.rules.cs @@ -100,7 +100,7 @@ endif install_libdir = $(prefix)/lib -ifneq ($(prefix),/usr) +ifndef usr_dir_install install_mandir := $(prefix)/man/man1 else install_mandir := $(prefix)/share/man/man1 @@ -108,7 +108,7 @@ endif install_pkgconfigdir = $(prefix)/lib/pkgconfig -ifeq ($(ice_dir),/usr) +ifeq ($(ice_dir), $(usr_dir)) ref = -pkg:$(1) else ifdef ice_src_dist diff --git a/distribution/bin/makegem.py b/distribution/bin/makegem.py new file mode 100755 index 00000000000..f7da0f30a7a --- /dev/null +++ b/distribution/bin/makegem.py @@ -0,0 +1,261 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys, shutil, glob, fnmatch, string, re +from stat import * + +# +# NOTE: See lib/DistUtils.py for default third-party locations and +# languages to be built on each platform. +# + +version = "@ver@" +if version[0] == "@": + version = "3.6b" +distDir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(os.path.join(distDir, "lib")) +import DistUtils + +# +# Program usage. +# +def usage(): + print "Usage: " + sys.argv[0] + " [options] tag" + print + print "Options:" + print "-c Clean previous build" + print "-h Show this message." + print "-v Be verbose." + +# +# Check arguments +# +verbose = 0 +forceclean = 0 +for x in sys.argv[1:]: + if x == "-h": + usage() + sys.exit(0) + elif x == "-v": + verbose = 1 + elif x == "-c": + forceclean = 1 + elif x.startswith("-"): + print sys.argv[0] + ": unknown option `" + x + "'" + print + usage() + sys.exit(1) + else: + if not x in platform.languages: + print sys.argv[0] + ": language `" + x + "' not supported on this platform" + print + usage() + sys.exit(1) + buildLanguages.append(x) + +if verbose: + quiet = "v" +else: + quiet = "" + +# +# Ensure the script is being run from the dist-@ver@ directory. +# +cwd = os.getcwd() +if not os.path.exists(os.path.join(distDir, "src", "windows", "LICENSE.rtf")): + print sys.argv[0] + ": you must run makebindist.py from the dist-" + version + " directory created by makedist.py" + sys.exit(1) + +print "Building Ice " + version + " gem" + +# +# Ensure that the source archive or directory exists and create the build directory. +# +buildRootDir = os.path.join(distDir, "..", os.path.join("build-gem-" + version)) +srcDir = os.path.join(buildRootDir, "Ice-" + version + "-src") + +if forceclean or not os.path.exists(srcDir): + if os.path.exists(buildRootDir): + print "Removing previous build from " + os.path.join("build-gem-" + version) + "...", + sys.stdout.flush() + shutil.rmtree(buildRootDir) + print "ok" + os.mkdir(buildRootDir) + + if not os.path.exists(os.path.join(cwd, "Ice-" + version + ".tar.gz")): + print sys.argv[0] + ": cannot find " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + sys.exit(1) + + print "Unpacking ./Ice-" + version + ".tar.gz ...", + sys.stdout.flush() + os.chdir(buildRootDir) + if os.system("gunzip -c " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + " | tar x" + quiet + "f -"): + print sys.argv[0] + ": failed to unpack ./Ice-" + version + ".tar.gz" + sys.exit(1) + os.rename("Ice-" + version, srcDir) + + os.chdir(cwd) + print "ok" + + buildDirs = [ "cpp/src/IceUtil", "cpp/src/Slice", "cpp/src/slice2rb", "cpp/src/slice2cpp", "rb/ruby" ] + for l in buildDirs: + print "building sources in " + os.path.join(srcDir, l) + os.chdir(os.path.join(srcDir, l)) + if os.system("make") != 0: + print sys.argv[0] + ": `" + l + "' build failed" + os.chdir(cwd) + sys.exit(1) + + sliceBuildDirs = [ "cpp/src/Ice", "cpp/src/IceSSL", "cpp/src/IceDiscovery" ] + for l in sliceBuildDirs: + print "building sources in " + os.path.join(srcDir, l) + os.chdir(os.path.join(srcDir, l)) + if os.system("make compile-slice") != 0: + print sys.argv[0] + ": `" + l + "' build failed" + os.chdir(cwd) + sys.exit(1) + + os.chdir(cwd) + print + print "============= Finished building sources =============" + print + +os.chdir(buildRootDir) +thirdPartyPackage = "ThirdParty-Sources-" + version +downloadUrl = "http://www.zeroc.com/download/Ice/3.6/" + +if not os.path.isfile(os.path.expanduser("~/Downloads/%s.tar.gz" % thirdPartyPackage)): + if os.system(os.path.expanduser("cd ~/Downloads && wget http://www.zeroc.com/download/Ice/3.6/%s.tar.gz" % thirdPartyPackage)) != 0: + print sys.argv[0] + ": downloading the third parties tar.gz failed" + os.chdir(cwd) + sys.exit(1) + +if not os.path.isfile(os.path.expanduser("~/Downloads/%s.zip" % thirdPartyPackage)): + if os.system(os.path.expanduser("cd ~/Downloads && wget http://www.zeroc.com/download/Ice/3.6/%s.zip" % thirdPartyPackage)) != 0: + print sys.argv[0] + ": downloading the third parties zip failed" + os.chdir(cwd) + sys.exit(1) + +if os.system(os.path.expanduser( + "rm -rf %(thirdParty)s && tar zxf ~/Downloads/%(thirdParty)s.tar.gz && cd %(thirdParty)s && tar zxf mcpp-2.7.2.tar.gz && " + "cd mcpp-2.7.2 && patch -p0 < ../mcpp/patch.mcpp.2.7.2" % {"thirdParty": thirdPartyPackage})) != 0: + print sys.argv[0] + ": extracting mcpp failed" + os.chdir(cwd) + sys.exit(1) + +if os.system(os.path.expanduser( + "rm -rf zip && unzip ~/Downloads/%(thirdParty)s.zip -d zip && cd zip/%(thirdParty)s && tar zxf bzip2-1.0.6.tar.gz" + % {"thirdParty": thirdPartyPackage})) != 0: + print sys.argv[0] + ": extracting bzip failed" + os.chdir(cwd) + sys.exit(1) + + +os.chdir(cwd) + +def getGemVersion(file): + for line in open('ice.gemspec'): + if line.find('s.version') != -1: + i = line.find("'") + line = line[i+1:] + end = line.find("'") + return line[:end] + return None + +copyFiles = [] + +# +# Extract all the relevant pieces from the source tree into the gemDir. +# +dirName = "Ice-" + version + "-gem" +gemDir = os.path.join(buildRootDir, dirName) +gemDirLib = os.path.join(gemDir, "lib") +gemDirBin = os.path.join(gemDir, "bin") +if os.path.exists(gemDir): + print "Removing previous build from " + gemDir + " ...", + sys.stdout.flush() + shutil.rmtree(gemDir) + print "ok" + +os.mkdir(gemDir) +os.mkdir(gemDirLib) +os.mkdir(gemDirBin) +DistUtils.copy(os.path.join(srcDir, "ICE_LICENSE"), gemDir, verbose) +DistUtils.copy(os.path.join(srcDir, "LICENSE"), gemDir, verbose) + +DistUtils.copy(os.path.join(distDir, "src/rb/ice.gemspec"), gemDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/rb/ice-x64-mingw.gemspec"), gemDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/rb/ice-x86-mingw.gemspec"), gemDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/rb/slice2rb"), gemDirBin, verbose) +DistUtils.copyMatchingFiles(os.path.join(srcDir, "rb/ruby"), gemDirLib, ["*.rb"], False, verbose) +for d in os.listdir(os.path.join(srcDir, "rb/ruby")): + DistUtils.copyMatchingFiles(os.path.join(srcDir, "rb/ruby", d), os.path.join(gemDirLib, d), ["*.rb"], False, verbose) + +for d in os.listdir(os.path.join(srcDir, "slice")): + DistUtils.copyMatchingFiles(os.path.join(srcDir, "slice", d), os.path.join(gemDir, "slice", d), ["*"], False, verbose) + +gemDirExt = os.path.join(gemDir, "ext") +gemDirIce = os.path.join(gemDir, "ext", "ice") +os.mkdir(gemDirExt) +os.mkdir(gemDirIce) + +DistUtils.copy(os.path.join(distDir, "src/rb/extconf.rb"), gemDirExt, verbose) +DistUtils.copyMatchingFiles(os.path.join(srcDir, "rb/src/IceRuby"), gemDirExt, ["*.cpp", "*.h"], False, verbose) + +# +# Extract the relevant portions of the Ice C++ source tree into the gem. +# +copyDirs = [ "cpp/src/IceUtil", "cpp/src/Slice", "cpp/src/Ice", "cpp/include/IceUtil", + "cpp/include/Slice", "cpp/include/Ice", "cpp/src/IceSSL", "cpp/include/IceSSL", + "cpp/include/IceDiscovery", "cpp/src/IceDiscovery" ] +for d in copyDirs: + DistUtils.copyMatchingFiles(os.path.join(srcDir, d), os.path.join(gemDirIce, d), ["*.cpp", "*.h", "Makefile"], False, verbose) + +os.unlink(os.path.join(gemDirExt, "ice/cpp/src/Ice/DLLMain.cpp")) + +for d in ["main.c", "directive.c", "eval.c", "expand.c", "mbchar.c", "support.c", "system.c", "internal.H", "mcpp_out.h", "mcpp_lib.h", "system.H", "configed.H"]: + DistUtils.copy("%s/%s/mcpp-2.7.2/src/%s" % (buildRootDir, thirdPartyPackage, d), os.path.join(gemDirIce, "mcpp", d)) +DistUtils.copyMatchingFiles(os.path.join(distDir, "src/rb/src/mcpp", ), os.path.join(gemDirIce, "mcpp"), ["*"], False, verbose) + +DistUtils.copy(os.path.join(distDir, "src/unix/MCPP_LICENSE"), gemDirIce) + +for d in ['blocksort.c', 'bzlib.c', 'compress.c','crctable.c','decompress.c','huffman.c','randtable.c','bzlib.h','bzlib_private.h']: + DistUtils.copy("%s/zip/%s/bzip2-1.0.6/%s" % (buildRootDir, thirdPartyPackage, d), os.path.join(gemDirIce, "bzip2", d)) +DistUtils.copy("%s/zip/%s/bzip2-1.0.6/LICENSE" % (buildRootDir, thirdPartyPackage), os.path.join(gemDirIce , "BZIP_LICENSE")) + +os.chdir(gemDir) +gemFile = "zeroc-ice-" + getGemVersion('ice.gemspec') + ".gem" +if os.system("gem build ice.gemspec") != 0: + print sys.argv[0] + ": building the gemspec failed" + os.chdir(cwd) + sys.exit(1) +copyFiles.append(os.path.join(gemDir, gemFile)) + +os.chdir(buildRootDir) + +zipFile = "zeroc-ice-%s-gem.zip" % (version) +tarFile = "zeroc-ice-%s-gem.tar" % (version) +os.system("tar cf %s %s" % (tarFile, dirName)) +if os.path.exists("%s.gz" % (tarFile)): + os.unlink("%s.gz" % (tarFile)) +os.system("gzip -9 %s" % (tarFile)) +tarFile = tarFile + ".gz" + +os.system("zip -9rq %s %s" % (zipFile, dirName)) + +copyFiles.append(os.path.join(buildRootDir, tarFile)) +copyFiles.append(os.path.join(buildRootDir, zipFile)) + +os.chdir(cwd) +for f in copyFiles: + print "Copying %s" % (f) + DistUtils.copy(f, ".", verbose) + os.unlink(f) + diff --git a/distribution/bin/makepy.py b/distribution/bin/makepy.py new file mode 100755 index 00000000000..b7c243e1cc3 --- /dev/null +++ b/distribution/bin/makepy.py @@ -0,0 +1,233 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys, shutil, glob, fnmatch, string, re +from stat import * + +# +# NOTE: See lib/DistUtils.py for default third-party locations and +# languages to be built on each platform. +# + +version = "@ver@" +if version[0] == "@": + version = "3.6b" +distDir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.append(os.path.join(distDir, "lib")) +import DistUtils + +# +# Program usage. +# +def usage(): + print "Usage: " + sys.argv[0] + " [options] tag" + print + print "Options:" + print "-c Clean previous build" + print "-h Show this message." + print "-v Be verbose." + +# +# Check arguments +# +verbose = 0 +forceclean = 0 +for x in sys.argv[1:]: + if x == "-h": + usage() + sys.exit(0) + elif x == "-v": + verbose = 1 + elif x == "-c": + forceclean = 1 + elif x.startswith("-"): + print sys.argv[0] + ": unknown option `" + x + "'" + print + usage() + sys.exit(1) + else: + if not x in platform.languages: + + print sys.argv[0] + ": language `" + x + "' not supported on this platform" + print + usage() + sys.exit(1) + buildLanguages.append(x) + +if verbose: + quiet = "v" +else: + quiet = "" + +# +# Ensure the script is being run from the dist-@ver@ directory. +# +cwd = os.getcwd() +if not os.path.exists(os.path.join(distDir, "src", "windows", "LICENSE.rtf")): + print sys.argv[0] + ": you must run makebindist.py from the dist-" + version + " directory created by makedist.py" + sys.exit(1) + +print "Building Ice " + version + +# +# Ensure that the source archive or directory exists and create the build directory. +# +buildRootDir = os.path.join(distDir, "..", os.path.join("build-py-" + version)) +srcDir = os.path.join(buildRootDir, "Ice-" + version + "-src") + +if forceclean or not os.path.exists(srcDir): + if os.path.exists(buildRootDir): + print "Removing previous build from " + os.path.join("build-py-" + version) + "...", + sys.stdout.flush() + shutil.rmtree(buildRootDir) + print "ok" + os.mkdir(buildRootDir) + + if not os.path.exists(os.path.join(cwd, "Ice-" + version + ".tar.gz")): + print sys.argv[0] + ": cannot find " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + sys.exit(1) + + print "Unpacking ./Ice-" + version + ".tar.gz ...", + sys.stdout.flush() + os.chdir(buildRootDir) + if os.system("gunzip -c " + os.path.join(cwd, "Ice-" + version + ".tar.gz") + " | tar x" + quiet + "f -"): + print sys.argv[0] + ": failed to unpack ./Ice-" + version + ".tar.gz" + sys.exit(1) + os.rename("Ice-" + version, srcDir) + + os.chdir(cwd) + print "ok" + + buildDirs = [ "cpp/src/IceUtil", "cpp/src/Slice", "cpp/src/slice2py", "cpp/src/slice2cpp", "py/python" ] + for l in buildDirs: + print "building sources in " + os.path.join(srcDir, l) + os.chdir(os.path.join(srcDir, l)) + if os.system("make") != 0: + print sys.argv[0] + ": `" + l + "' build failed" + os.chdir(cwd) + sys.exit(1) + + sliceBuildDirs = [ "cpp/src/Ice", "cpp/src/IceSSL", "cpp/src/IceDiscovery" ] + for l in sliceBuildDirs: + print "building sources in " + os.path.join(srcDir, l) + os.chdir(os.path.join(srcDir, l)) + if os.system("make compile-slice") != 0: + print sys.argv[0] + ": `" + l + "' build failed" + os.chdir(cwd) + sys.exit(1) + + os.chdir(cwd) + print + print "============= Finished building sources =============" + print + +os.chdir(buildRootDir) +thirdPartyPackage = "ThirdParty-Sources-" + version +downloadUrl = "http://www.zeroc.com/download/Ice/3.6/" + +if not os.path.isfile(os.path.expanduser("~/Downloads/%s.tar.gz" % thirdPartyPackage)): + if os.system(os.path.expanduser("cd ~/Downloads && wget http://www.zeroc.com/download/Ice/3.6/%s.tar.gz" % thirdPartyPackage)) != 0: + print sys.argv[0] + ": downloading the third parties tar.gz failed" + os.chdir(cwd) + sys.exit(1) + +if not os.path.isfile(os.path.expanduser("~/Downloads/%s.zip" % thirdPartyPackage)): + if os.system(os.path.expanduser("cd ~/Downloads && wget http://www.zeroc.com/download/Ice/3.6/%s.zip" % thirdPartyPackage)) != 0: + print sys.argv[0] + ": downloading the third parties zip failed" + os.chdir(cwd) + sys.exit(1) + +if os.system(os.path.expanduser( + "rm -rf %(thirdParty)s && tar zxf ~/Downloads/%(thirdParty)s.tar.gz && cd %(thirdParty)s && tar zxf mcpp-2.7.2.tar.gz && " + "cd mcpp-2.7.2 && patch -p0 < ../mcpp/patch.mcpp.2.7.2" % {"thirdParty": thirdPartyPackage})) != 0: + print sys.argv[0] + ": extracting mcpp failed" + os.chdir(cwd) + sys.exit(1) + +if os.system(os.path.expanduser( + "rm -rf zip && unzip ~/Downloads/%(thirdParty)s.zip -d zip && cd zip/%(thirdParty)s && tar zxf bzip2-1.0.6.tar.gz" + % {"thirdParty": thirdPartyPackage})) != 0: + print sys.argv[0] + ": extracting bzip failed" + os.chdir(cwd) + sys.exit(1) + + +os.chdir(cwd) + +# +# Extract all the relevant pieces from the source tree into the pyDir. +# +pyDir = os.path.join(buildRootDir, "Ice-" + version + "-py") +pyDirExt = os.path.join(pyDir, "src") +pyDirLib = os.path.join(pyDir, "lib") +if os.path.exists(pyDir): + print "Removing previous build from " + pyDir + " ...", + sys.stdout.flush() + shutil.rmtree(pyDir) + print "ok" + +os.mkdir(pyDir) +os.mkdir(pyDirExt) +os.mkdir(pyDirLib) +DistUtils.copy(os.path.join(srcDir, "ICE_LICENSE"), pyDir, verbose) +DistUtils.copy(os.path.join(srcDir, "LICENSE"), pyDir, verbose) + +DistUtils.copy(os.path.join(distDir, "src/py/MANIFEST.in"), pyDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/py/setup.py"), pyDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/py/setup.cfg"), pyDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/py/README.rst"), pyDir, verbose) +DistUtils.copy(os.path.join(distDir, "src/py/slice2py.py"), pyDirLib, verbose) +DistUtils.copyMatchingFiles(os.path.join(srcDir, "py/modules/IcePy"), pyDirExt, ["*.cpp", "*.h"], False, verbose) +DistUtils.copyMatchingFiles(os.path.join(srcDir, "py/python"), pyDirLib, ["*.py"], False, verbose) +for d in os.listdir(os.path.join(srcDir, "py/python")): + DistUtils.copyMatchingFiles(os.path.join(srcDir, "py/python", d), os.path.join(pyDirLib, d), ["*.py"], False, verbose) + +pyDirIce = os.path.join(pyDir, "src", "ice") +os.mkdir(pyDirIce) + +# +# Extract the relevant portions of the Ice C++ source tree into the package. +# +copyDirs = [ "cpp/src/IceUtil", "cpp/src/Slice", "cpp/src/Ice", "cpp/include/IceUtil", + "cpp/include/Slice", "cpp/include/Ice", "cpp/src/IceSSL", "cpp/include/IceSSL", + "cpp/include/IceDiscovery", "cpp/src/IceDiscovery" ] +for d in copyDirs: + DistUtils.copyMatchingFiles(os.path.join(srcDir, d), os.path.join(pyDirIce, d), ["*.cpp", "*.h"], False, verbose) + +for d in os.listdir(os.path.join(srcDir, "slice")): + DistUtils.copyMatchingFiles(os.path.join(srcDir, "slice", d), os.path.join(pyDirLib, "slice", d), ["*"], False, verbose) + +os.unlink(os.path.join(pyDirExt, "ice/cpp/src/Ice/DLLMain.cpp")) +os.unlink(os.path.join(pyDirExt, "ice/cpp/src/Ice/Service.cpp")) +os.unlink(os.path.join(pyDirExt, "ice/cpp/src/Ice/Application.cpp")) + +for d in ["main.c", "directive.c", "eval.c", "expand.c", "mbchar.c", "support.c", "system.c", "internal.H", "mcpp_out.h", "mcpp_lib.h", "system.H", "configed.H"]: + DistUtils.copy("%s/%s/mcpp-2.7.2/src/%s" % (buildRootDir, thirdPartyPackage, d), os.path.join(pyDirIce, "mcpp", d)) +DistUtils.copyMatchingFiles(os.path.join(distDir, "src/py/src/mcpp", ), os.path.join(pyDirIce, "mcpp"), ["*"], False, verbose) + +DistUtils.copy(os.path.join(distDir, "src/unix/MCPP_LICENSE"), pyDirIce) + +for d in ['blocksort.c', 'bzlib.c', 'compress.c','crctable.c','decompress.c','huffman.c','randtable.c','bzlib.h','bzlib_private.h']: + DistUtils.copy("%s/zip/%s/bzip2-1.0.6/%s" % (buildRootDir, thirdPartyPackage, d), os.path.join(pyDirIce, "bzip2", d)) +DistUtils.copy("%s/zip/%s/bzip2-1.0.6/LICENSE" % (buildRootDir, thirdPartyPackage), os.path.join(pyDirIce , "BZIP_LICENSE")) + +os.chdir(pyDir) +pyFile = "" +if os.system("python setup.py sdist") != 0: + print sys.argv[0] + ": building the source dist" + os.chdir(cwd) + sys.exit(1) +os.chdir(cwd) +pyFile = os.path.join("dist", "zeroc-ice-" + version + ".tar.gz") +DistUtils.copy(os.path.join(pyDir, pyFile), ".", verbose) + +print +print "============= Finished building " + pyFile + " =============" +print diff --git a/distribution/src/common/Make.rules b/distribution/src/common/Make.rules index be2966a0c24..c6414bc7cf1 100644 --- a/distribution/src/common/Make.rules +++ b/distribution/src/common/Make.rules @@ -87,7 +87,7 @@ ICECPPFLAGS = -I$(slicedir) SLICE2CPPFLAGS = $(ICECPPFLAGS) -ifeq ($(ice_dir), /usr) +ifeq ($(ice_dir), $(usr_dir)) LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) ifeq ($(CPP11),yes) LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(ice_dir)/$(libsubdir)$(cpp11libdirsuffix) diff --git a/distribution/src/py/MANIFEST.in b/distribution/src/py/MANIFEST.in new file mode 100644 index 00000000000..504eefd03ed --- /dev/null +++ b/distribution/src/py/MANIFEST.in @@ -0,0 +1,2 @@ +include * +recursive-include src * diff --git a/distribution/src/py/README.rst b/distribution/src/py/README.rst new file mode 100644 index 00000000000..baf46c77f12 --- /dev/null +++ b/distribution/src/py/README.rst @@ -0,0 +1,68 @@ +The Internet Communications Engine (Ice) provides a robust, proven +platform for developing mission-critical networked applications. +Let Ice handle all of the low-level details such as network +connections, serialization, and concurrency so that you can focus +on your application logic. + + +Our Python extension makes the full Ice feature set available to +Python developers, including: + +* Client and server support +* Synchronous and asynchronous invocations +* Communicate via TCP, SSL, UDP, multicast, and WebSocket transports +* Supports IPv4 and IPv6 +* Intuitive mapping from Slice to Python + +To give you an idea of what it's like to use Ice in Python, here's +a complete program that tests whether a remote Ice object is +available: + +:: + + import Ice + communicator = Ice.initialize() + obj = communicator.stringToProxy("hello:tcp -h myhost.mydomain.com -p 10000") + obj.ice_ping() + communicator.destroy() + +With support for Python2 and Python3, you can easily add Ice to +your existing Python infrastructure and discover how easy it is to +build distributed applications with Ice. + + +Package Contents +---------------- + +This package includes the Ice extension for Python, the standard +Slice definition files, and the Slice-to-Python compiler. You will +need to install a full Ice distribution if you want to use other +Ice language mappings, or Ice services such as IceGrid, IceStorm +and Glacier2. + +Installation +------------ + +We recommend using ``pip`` or ``easy_install`` to install this +package. If you install using ``python setup.py install`` instead, +be aware that the Slice-to-Python compiler (``slice2py``) will not +be available. + +Home Page +--------- + +Visit `ZeroC's home page <https://www.zeroc.com>`_ for the latest news +and information about Ice. + +Documentation +------------- + +We provide extensive `online documentation +<https://doc.zeroc.com/display/Ice36>`_ for Ice, the Python extension, +and the other Ice language mappings and services. + +Support +------- + +Join us on our `user forums <https://www.zeroc.com/forums/forum.php>`_ if you have questions +about Ice. diff --git a/distribution/src/py/setup.cfg b/distribution/src/py/setup.cfg new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/distribution/src/py/setup.cfg diff --git a/distribution/src/py/setup.py b/distribution/src/py/setup.py new file mode 100644 index 00000000000..1e795a39e5c --- /dev/null +++ b/distribution/src/py/setup.py @@ -0,0 +1,164 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +# Always prefer setuptools over distutils +try: + from setuptools import setup +except ImportError: + from distutils.core import setup + +from distutils.extension import Extension +import distutils.sysconfig +import sys, os, shutil, fnmatch, glob + +# +# Sort out packages, package_dir and package_data from the lib dir. +# +packages = [ '' ] +package_dir={'' : 'lib'} +for f in os.listdir('lib'): + p = os.path.join('lib', f) + if os.path.isdir(p): + package_dir[f] = p + packages.append(f) +package_data = { 'slice' : ['*/*.ice'] } + +include_dirs=['src', 'src/ice/cpp/include', 'src/ice/cpp/src'] +define_macros=[('HAVE_CONFIG_H', 1), ('MCPP_LIB', 1), ('ICE_STATIC_LIBS', None)] +extra_compile_args=[] + +platform = sys.platform +if platform[:6] == 'darwin': + platform = 'darwin' + +if platform == 'darwin': + if not 'ARCHFLAGS' in os.environ: + os.environ['ARCHFLAGS'] = '-arch x86_64' + extra_compile_args.append('-w') + extra_link_args = ['-framework','Security', '-framework','CoreFoundation'] + libraries=['iconv'] + shutil.copyfile('src/ice/mcpp/config.h.Darwin', 'src/ice/mcpp/config.h') + # Don't compile the bzip2 source under darwin or linux. + def filterName(path): + d = os.path.dirname(path) + if d.find('bzip2') != -1: + return False + return True + +elif platform == 'linux2': + + extra_compile_args.append('-w') + extra_link_args = [] + libraries=['ssl', 'crypto', 'bz2'] + shutil.copyfile('src/ice/mcpp/config.h.Linux', 'src/ice/mcpp/config.h') + # Don't compile the bzip2 source under darwin or linux. + def filterName(path): + d = os.path.dirname(path) + if d.find('bzip2') != -1: + return False + return True + +elif platform == 'win32': + extra_link_args = [] + libraries=[] + define_macros.append(('WIN32_LEAN_AND_MEAN', None)) + define_macros.append(('ICE_NO_PRAGMA_COMMENT', None)) + include_dirs.append('src/ice/bzip2') + extra_compile_args.append('/EHsc') + libraries=['rpcrt4','advapi32','Iphlpapi','secur32','crypt32','ws2_32'] + shutil.copyfile('src/ice/mcpp/config.h.win32', 'src/ice/mcpp/config.h') + # SysLoggerI.cpp shouldn't be built under Windows. + def filterName(path): + b = os.path.basename(path) + if b == 'SysLoggerI.cpp': + return False + return True + +# Gather the list of sources to compile. +sources = [] +for root, dirnames, filenames in os.walk('src'): + for filename in fnmatch.filter(filenames, '*.cpp'): + n = os.path.join(root, filename) + if filterName(n): + sources.append(n) + for filename in fnmatch.filter(filenames, '*.c'): + n = os.path.join(root, filename) + if filterName(n): + sources.append(n) + +with open('README.rst') as file: + long_description = file.read() + +setup( + name='zeroc-ice', + + version='3.6b', + + description="Ice is a modern object-oriented toolkit that enables you to build distributed applications with minimal effort.", + + long_description=long_description, + + # The project's main homepage. + url='https://www.zeroc.com', + + # Author details + author='ZeroC, Inc.', + author_email='info@zeroc.com', + + # Choose your license + license='GPL v2 with exceptions', + + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + 'Development Status :: 4 - Beta', + + # Indicate who your project is intended for + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Build Tools', + + # Pick your license as you wish (should match "license" above) + 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)', + + # Specify the Python versions you support here. In particular, ensure + # that you indicate whether you support Python 2, Python 3 or both. + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.0', + 'Programming Language :: Python :: 3.1', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + ], + + # What does your project relate to? + keywords='distributed systems development', + + packages = packages, + package_dir = package_dir, + package_data = package_data, + + entry_points = { + 'console_scripts': ['slice2py=slice2py:main'], + }, + + ext_modules=[ + Extension('IcePy', sources, + extra_link_args=extra_link_args, + define_macros=define_macros, + include_dirs=include_dirs, + extra_compile_args=extra_compile_args, + libraries=libraries) + ] +) diff --git a/distribution/src/py/slice2py.py b/distribution/src/py/slice2py.py new file mode 100755 index 00000000000..7f2aca37164 --- /dev/null +++ b/distribution/src/py/slice2py.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import sys, Ice, IcePy +def main(): + sliceDir = Ice.getSliceDir() + # Automatically add the slice dir. + if not sliceDir is None: + sys.argv.append('-I' + sliceDir) + val = IcePy.compile(sys.argv) + sys.exit(int(val)) diff --git a/distribution/src/py/src/mcpp/Makefile b/distribution/src/py/src/mcpp/Makefile new file mode 100644 index 00000000000..a8b600ef50e --- /dev/null +++ b/distribution/src/py/src/mcpp/Makefile @@ -0,0 +1,37 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** +# +all: libmcpp.a + +CFLAGS = -O2 -DMCPP_LIB=1 -DHAVE_CONFIG_H +OBJS = directive.o eval.o expand.o main.o mbchar.o support.o system.o + +UNAME = $(shell uname) +ifneq ($(findstring MINGW,$(UNAME)),) + UNAME := MINGW + CC := gcc +endif + +ifeq ($(UNAME),Linux) + CFLAGS += -fPIC +endif + +config: + @if ! test -f config.h; \ + then \ + cp config.h.$(UNAME) config.h ; \ + fi + +libmcpp.a: config $(OBJS) + ar rcs libmcpp.a $(OBJS) + ranlib libmcpp.a + +clean: + rm -f $(OBJS) + rm -f libmcpp.a diff --git a/distribution/src/py/src/mcpp/config.h.Darwin b/distribution/src/py/src/mcpp/config.h.Darwin new file mode 100644 index 00000000000..8d5154fa1ac --- /dev/null +++ b/distribution/src/py/src/mcpp/config.h.Darwin @@ -0,0 +1,227 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if '0x5c' in BIG5 multi-byte character is safe. */ +/* #undef BIGFIVE_IS_ESCAPE_FREE */ + +/* Define the target compiler. */ +#define COMPILER INDEPENDENT + +/* Define the type of size_t. */ +/* #undef COMPILER_SP1_VAL */ + +/* Define the type of ptrdiff_t. */ +/* #undef COMPILER_SP2_VAL */ + +/* Define the type of wchar_t. */ +/* #undef COMPILER_SP3_VAL */ + +/* Define the name of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD */ + +/* Define the value of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD_VAL */ + +/* Define the name of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD */ + +/* Define the value of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD_VAL */ + +/* Define compiler-specific C++ include directory 1. */ +/* #undef CPLUS_INCLUDE_DIR1 */ + +/* Define compiler-specific C++ include directory 2. */ +/* #undef CPLUS_INCLUDE_DIR2 */ + +/* Define compiler-specific C++ include directory 3. */ +/* #undef CPLUS_INCLUDE_DIR3 */ + +/* Define compiler-specific C++ include directory 4. */ +/* #undef CPLUS_INCLUDE_DIR4 */ + +/* Define the cpu-specific-macro. */ +#define CPU "i386" + +/* Define the name of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD */ + +/* Define the value of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD_VAL */ + +/* Define the name of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD */ + +/* Define the value of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD_VAL */ + +/* Define root directory of CYGWIN. */ +/* #undef CYGWIN_ROOT_DIRECTORY */ + +/* Define compiler-specific C include directory 1. */ +/* #undef C_INCLUDE_DIR1 */ + +/* Define compiler-specific C include directory 2. */ +/* #undef C_INCLUDE_DIR2 */ + +/* Define compiler-specific C include directory 3. */ +/* #undef C_INCLUDE_DIR3 */ + +/* Define if the argument of pragma is macro expanded. */ +/* #undef EXPAND_PRAGMA */ + +/* Define if the cases of file name are folded. */ +#define FNAME_FOLD 1 + +/* Define MacOS-specific framework directory 1. */ +#define FRAMEWORK1 "/System/Library/Frameworks" + +/* Define MacOS-specific framework directory 2. */ +#define FRAMEWORK2 "/Library/Frameworks" + +/* Define MacOS-specific framework directory 3. */ +/* #undef FRAMEWORK3 */ + +/* Define gcc major version. */ +#define GCC_MAJOR_VERSION "4" + +/* Define gcc minor version. */ +#define GCC_MINOR_VERSION "2" + +/* Define if digraphs are available. */ +/* #undef HAVE_DIGRAPHS */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if the system has the type `intmax_t'. */ +#define HAVE_INTMAX_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdint.h,> header file. */ +/* #undef HAVE_STDINT_H_ */ + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <unistd.h,> header file. */ +/* #undef HAVE_UNISTD_H_ */ + +/* Define the host compiler name. */ +#define HOST_CMP_NAME "GCC" + +/* Define the host compiler. */ +#define HOST_COMPILER GNUC + +/* Define the host system. */ +#define HOST_SYSTEM SYS_MAC + +/* Define include directory to install mcpp_g*.h header files. */ +/* #undef INC_DIR */ + +/* Define if '0x5c' in ISO2022-JP multi-byte character is safe. */ +/* #undef ISO2022_JP_IS_ESCAPE_FREE */ + +/* Define output format of line directive. */ +/* #undef LINE_PREFIX */ + +/* Define printf length modifier for the longest integer. */ +#define LL_FORM "j" + +/* Define if build libmcpp */ +#define MCPP_LIB 1 + +/* Define /mingw directory. */ +/* #undef MINGW_DIRECTORY */ + +/* Define root directory of MSYS. */ +/* #undef MSYS_ROOT_DIRECTORY */ + +/* Define the suffix of object file. */ +#define OBJEXT "o" + +/* Name of package */ +#define PACKAGE "mcpp" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "kmatsui@t3.rim.or.jp" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "mcpp" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "mcpp 2.7.2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "mcpp" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.7.2" + +/* Define include preference. */ +/* #undef SEARCH_INIT */ + +/* Define if '0x5c' in SJIS multi-byte character is safe. */ +/* #undef SJIS_IS_ESCAPE_FREE */ + +/* Define the default value of __STDC__. */ +/* #undef STDC */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define the default value of __STDC_VERSION__. */ +/* #undef STDC_VERSION */ + +/* Define whether output format of line directive is C source style. */ +/* #undef STD_LINE_PREFIX */ + +/* Define the target system. */ +#define SYSTEM SYS_MAC + +/* Define the version of FreeBSD. */ +/* #undef SYSTEM_EXT_VAL */ + +/* Define the name of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD */ + +/* Define the value of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD_VAL */ + +/* Define the name of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD */ + +/* Define the value of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD_VAL */ + +/* Version number of package */ +#define VERSION "2.7.2" diff --git a/distribution/src/py/src/mcpp/config.h.Linux b/distribution/src/py/src/mcpp/config.h.Linux new file mode 100644 index 00000000000..69134c7df47 --- /dev/null +++ b/distribution/src/py/src/mcpp/config.h.Linux @@ -0,0 +1,227 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if '0x5c' in BIG5 multi-byte character is safe. */ +/* #undef BIGFIVE_IS_ESCAPE_FREE */ + +/* Define the target compiler. */ +#define COMPILER INDEPENDENT + +/* Define the type of size_t. */ +/* #undef COMPILER_SP1_VAL */ + +/* Define the type of ptrdiff_t. */ +/* #undef COMPILER_SP2_VAL */ + +/* Define the type of wchar_t. */ +/* #undef COMPILER_SP3_VAL */ + +/* Define the name of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD */ + +/* Define the value of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD_VAL */ + +/* Define the name of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD */ + +/* Define the value of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD_VAL */ + +/* Define compiler-specific C++ include directory 1. */ +/* #undef CPLUS_INCLUDE_DIR1 */ + +/* Define compiler-specific C++ include directory 2. */ +/* #undef CPLUS_INCLUDE_DIR2 */ + +/* Define compiler-specific C++ include directory 3. */ +/* #undef CPLUS_INCLUDE_DIR3 */ + +/* Define compiler-specific C++ include directory 4. */ +/* #undef CPLUS_INCLUDE_DIR4 */ + +/* Define the cpu-specific-macro. */ +#define CPU "i386" + +/* Define the name of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD */ + +/* Define the value of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD_VAL */ + +/* Define the name of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD */ + +/* Define the value of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD_VAL */ + +/* Define root directory of CYGWIN. */ +/* #undef CYGWIN_ROOT_DIRECTORY */ + +/* Define compiler-specific C include directory 1. */ +/* #undef C_INCLUDE_DIR1 */ + +/* Define compiler-specific C include directory 2. */ +/* #undef C_INCLUDE_DIR2 */ + +/* Define compiler-specific C include directory 3. */ +/* #undef C_INCLUDE_DIR3 */ + +/* Define if the argument of pragma is macro expanded. */ +/* #undef EXPAND_PRAGMA */ + +/* Define if the cases of file name are folded. */ +/* #undef FNAME_FOLD */ + +/* Define MacOS-specific framework directory 1. */ +/* #undef FRAMEWORK1 */ + +/* Define MacOS-specific framework directory 2. */ +/* #undef FRAMEWORK2 */ + +/* Define MacOS-specific framework directory 3. */ +/* #undef FRAMEWORK3 */ + +/* Define gcc major version. */ +#define GCC_MAJOR_VERSION "4" + +/* Define gcc minor version. */ +#define GCC_MINOR_VERSION "8" + +/* Define if digraphs are available. */ +/* #undef HAVE_DIGRAPHS */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if the system has the type `intmax_t'. */ +#define HAVE_INTMAX_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdint.h,> header file. */ +/* #undef HAVE_STDINT_H_ */ + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <unistd.h,> header file. */ +/* #undef HAVE_UNISTD_H_ */ + +/* Define the host compiler name. */ +#define HOST_CMP_NAME "GCC" + +/* Define the host compiler. */ +#define HOST_COMPILER GNUC + +/* Define the host system. */ +#define HOST_SYSTEM SYS_LINUX + +/* Define include directory to install mcpp_g*.h header files. */ +/* #undef INC_DIR */ + +/* Define if '0x5c' in ISO2022-JP multi-byte character is safe. */ +/* #undef ISO2022_JP_IS_ESCAPE_FREE */ + +/* Define output format of line directive. */ +/* #undef LINE_PREFIX */ + +/* Define printf length modifier for the longest integer. */ +#define LL_FORM "j" + +/* Define if build libmcpp */ +#define MCPP_LIB 1 + +/* Define /mingw directory. */ +/* #undef MINGW_DIRECTORY */ + +/* Define root directory of MSYS. */ +/* #undef MSYS_ROOT_DIRECTORY */ + +/* Define the suffix of object file. */ +#define OBJEXT "o" + +/* Name of package */ +#define PACKAGE "mcpp" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "kmatsui@t3.rim.or.jp" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "mcpp" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "mcpp 2.7.2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "mcpp" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.7.2" + +/* Define include preference. */ +/* #undef SEARCH_INIT */ + +/* Define if '0x5c' in SJIS multi-byte character is safe. */ +/* #undef SJIS_IS_ESCAPE_FREE */ + +/* Define the default value of __STDC__. */ +/* #undef STDC */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define the default value of __STDC_VERSION__. */ +/* #undef STDC_VERSION */ + +/* Define whether output format of line directive is C source style. */ +/* #undef STD_LINE_PREFIX */ + +/* Define the target system. */ +#define SYSTEM SYS_LINUX + +/* Define the version of FreeBSD. */ +/* #undef SYSTEM_EXT_VAL */ + +/* Define the name of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD */ + +/* Define the value of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD_VAL */ + +/* Define the name of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD */ + +/* Define the value of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD_VAL */ + +/* Version number of package */ +#define VERSION "2.7.2" diff --git a/distribution/src/py/src/mcpp/config.h.win32 b/distribution/src/py/src/mcpp/config.h.win32 new file mode 100644 index 00000000000..5d21598f007 --- /dev/null +++ b/distribution/src/py/src/mcpp/config.h.win32 @@ -0,0 +1,7 @@ +#define COMPILER INDEPENDENT +#define HOST_SYSTEM SYS_WIN +#define SYSTEM SYS_WIN +#define CPU "x86_64" +#define HOST_COMPILER MSC +#define VERSION "2.7.2" +#define MCPP_LIB 1 diff --git a/distribution/src/rb/extconf.rb b/distribution/src/rb/extconf.rb new file mode 100644 index 00000000000..f874974b214 --- /dev/null +++ b/distribution/src/rb/extconf.rb @@ -0,0 +1,118 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +require "mkmf" + +if ! (RUBY_PLATFORM =~ /mswin|mingw/) + # + # On OSX & Linux bzlib.h is required. + # + if not have_header("bzlib.h") then + exit 1 + end + + + if RUBY_PLATFORM =~ /linux/ + # + # On Linux openssl is required for IceSSL. + # + if not have_header("openssl/ssl.h") then + exit 1 + end + end +end +if ! File.exist?("ice/mcpp/config.h") + if RUBY_PLATFORM =~ /mswin|mingw/ + FileUtils.copy("ice/mcpp/config.h.MINGW", "ice/mcpp/config.h") + elsif RUBY_PLATFORM =~ /linux/ + FileUtils.copy("ice/mcpp/config.h.Linux", "ice/mcpp/config.h") + elsif RUBY_PLATFORM =~ /darwin/ + FileUtils.copy("ice/mcpp/config.h.Darwin", "ice/mcpp/config.h") + end +end + +# +# Ice on OSX is built only with 64 bit support. +# +if RUBY_PLATFORM =~ /darwin/ + $ARCH_FLAG = "-arch x86_64" +end + +$INCFLAGS << ' -Iice/cpp/include' +$INCFLAGS << ' -Iice/cpp/src' + +$CPPFLAGS << ' -DICE_STATIC_LIBS' + +# For mcpp. +$CPPFLAGS << ' -DHAVE_CONFIG_H' + +if RUBY_PLATFORM =~ /mswin|mingw/ + # Change -D_WIN32_WINNT=0x0501 to # Change -D_WIN32_WINNT=0x0601 otherwise the SSL plugin won't compile + $CPPFLAGS = $CPPFLAGS.sub("501", "601") + + $CPPFLAGS << ' -DWIN32_LEAN_AND_MEAN' + $CPPFLAGS << ' -DICE_NO_PRAGMA_COMMENT' + $CPPFLAGS << ' -mthreads' + + $INCFLAGS << ' -Iice/bzip2' + + # -lws2_32 must be in LOCAL_LIBS even though mkmk puts it at the end of the LIBS, otherwise + # you get error 6 when using the socket library. + $LOCAL_LIBS << ' -lrpcrt4 -ladvapi32 -lIphlpapi -lsecur32 -lcrypt32 -lws2_32' + + # statically link the C and C++ runtimes. + $LDFLAGS << ' -static-libgcc -static-libstdc++' +elsif RUBY_PLATFORM =~ /darwin/ + $LOCAL_LIBS << ' -framework Security -framework CoreFoundation' +elsif RUBY_PLATFORM =~ /linux/ + $LOCAL_LIBS << ' -lssl -lcrypto' +end +$CPPFLAGS << ' -w' + +# Setup the object and source files. +$objs = [] +$srcs = [] + +# Add the plugin source. +Dir["*.cpp"].each do |f| + $objs << File.basename(f, ".*") + ".o" + $srcs << f +end + +# The Ice source. +skip = [] +if RUBY_PLATFORM =~ /mswin|mingw/ + skip << "SysLoggerI.cpp" +end +Dir["ice/**/*.cpp"].each do |f| + if ! skip.include? File.basename(f) + $objs << File.dirname(f) + "/" + File.basename(f, ".*") + ".o" + $srcs << f + end +end + +# The mcpp source. +Dir["ice/mcpp/*.c"].each do |f| + dir = "ice/mcpp" + $objs << File.join(dir, File.basename(f, ".*") + ".o") + $srcs << File.join(dir, f) +end + +# +# Add bzip2 source under Windows. +# +if RUBY_PLATFORM =~ /mswin|mingw/ + ['blocksort.c', 'bzlib.c', 'compress.c','crctable.c','decompress.c','huffman.c','randtable.c'].each do |f| + dir = "ice/bzip2" + $objs << File.join(dir, File.basename(f, ".*") + ".o") + $srcs << File.join(dir, f) + end +end + +create_makefile "IceRuby" diff --git a/distribution/src/rb/ice-x64-mingw.gemspec b/distribution/src/rb/ice-x64-mingw.gemspec new file mode 100644 index 00000000000..77fa7be133a --- /dev/null +++ b/distribution/src/rb/ice-x64-mingw.gemspec @@ -0,0 +1,41 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +Gem::Specification.new do |s| + s.name = 'zeroc-ice-x64-mingw' + s.version = '3.6b1' + s.date = '2015-02-17' + s.summary = "ZeroC Ice for Ruby" + s.description = <<-eos +The Internet Communications Engine (Ice) provides a robust, proven +platform for developing mission-critical networked applications +with minimal effort. Let Ice handle all of the low-level details +such as network connections, serialization, and concurrency so that +you can focus on your application logic. + +This package includes the Ice extension for Ruby, the standard Slice +definition files, and the Slice-to-Ruby compiler. You will need to +install a full Ice distribution if you want to use other Ice language +mappings, or Ice services such as IceGrid, IceStorm and Glacier2. + + +We provide extensive online documentation for Ice, the Ruby extension, +and the other Ice language mappings and services. + +Join us on our user forums if you have questions about Ice. +eos + s.authors = ["ZeroC, Inc."] + s.email = 'info@zeroc.com' + s.files = %w[ICE_LICENSE LICENSE ice-x64-mingw.gemspec] + Dir.glob('lib/**/*.rb') + Dir.glob('lib/*.so') + Dir.glob("slice/**/*.ice") + s.homepage = 'https://www.zeroc.com' + s.license = 'GPL v2 with exceptions' + s.rdoc_options = %w[--exclude=IceRuby.so$ --exclude=lib/slice2rb$] + s.executables << 'slice2rb' + s.required_ruby_version = '~> 2.1' +end diff --git a/distribution/src/rb/ice-x86-mingw.gemspec b/distribution/src/rb/ice-x86-mingw.gemspec new file mode 100644 index 00000000000..5b5d9bcc5f6 --- /dev/null +++ b/distribution/src/rb/ice-x86-mingw.gemspec @@ -0,0 +1,41 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +Gem::Specification.new do |s| + s.name = 'zeroc-ice-x86-mingw' + s.version = '3.6b1' + s.date = '2015-02-17' + s.summary = "ZeroC Ice for Ruby" + s.description = <<-eos +The Internet Communications Engine (Ice) provides a robust, proven +platform for developing mission-critical networked applications +with minimal effort. Let Ice handle all of the low-level details +such as network connections, serialization, and concurrency so that +you can focus on your application logic. + +This package includes the Ice extension for Ruby, the standard Slice +definition files, and the Slice-to-Ruby compiler. You will need to +install a full Ice distribution if you want to use other Ice language +mappings, or Ice services such as IceGrid, IceStorm and Glacier2. + + +We provide extensive online documentation for Ice, the Ruby extension, +and the other Ice language mappings and services. + +Join us on our user forums if you have questions about Ice. +eos + s.authors = ["ZeroC, Inc."] + s.email = 'info@zeroc.com' + s.files = %w[ICE_LICENSE LICENSE ice-x86-mingw.gemspec] + Dir.glob('lib/**/*.rb') + Dir.glob('lib/*.so') + Dir.glob("slice/**/*.ice") + s.homepage = 'https://www.zeroc.com' + s.license = 'GPL v2 with exceptions' + s.rdoc_options = %w[--exclude=IceRuby.so$ --exclude=lib/slice2rb$] + s.executables << 'slice2rb' + s.required_ruby_version = '~> 2.1' +end diff --git a/distribution/src/rb/ice.gemspec b/distribution/src/rb/ice.gemspec new file mode 100644 index 00000000000..41065cd3b32 --- /dev/null +++ b/distribution/src/rb/ice.gemspec @@ -0,0 +1,41 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +Gem::Specification.new do |s| + s.name = 'zeroc-ice' + s.version = '3.6b1' + s.date = '2015-01-16' + s.summary = "ZeroC Ice for Ruby" + s.description = <<-eos +The Internet Communications Engine (Ice) provides a robust, proven +platform for developing mission-critical networked applications +with minimal effort. Let Ice handle all of the low-level details +such as network connections, serialization, and concurrency so that +you can focus on your application logic. + +This package includes the Ice extension for Ruby, the standard Slice +definition files, and the Slice-to-Ruby compiler. You will need to +install a full Ice distribution if you want to use other Ice language +mappings, or Ice services such as IceGrid, IceStorm and Glacier2. + + +We provide extensive online documentation for Ice, the Ruby extension, +and the other Ice language mappings and services. + +Join us on our user forums if you have questions about Ice. +eos + s.authors = ["ZeroC, Inc."] + s.email = 'info@zeroc.com' + s.files = %w[ICE_LICENSE LICENSE ice.gemspec] + Dir.glob('lib/**/*.rb') + Dir.glob("ext/*") + Dir.glob("ext/**/*") + Dir.glob("slice/**/*.ice") + s.homepage = 'https://www.zeroc.com' + s.license = 'GPL v2 with exceptions' + s.extensions = %w[ext/extconf.rb] + s.rdoc_options = %w[--exclude=ext/IceRuby/.*\.o$ --exclude=IceRuby\.(bundle|so)$ --exclude=lib/slice2rb$] + s.executables << 'slice2rb' +end diff --git a/distribution/src/rb/slice2rb b/distribution/src/rb/slice2rb new file mode 100755 index 00000000000..c56fc02575f --- /dev/null +++ b/distribution/src/rb/slice2rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +require 'Ice' +sliceDir = Ice.getSliceDir() +if sliceDir != nil + ARGV << "-I" + sliceDir +end +rc = Ice::compile(ARGV) +exit(rc) diff --git a/distribution/src/rb/src/mcpp/config.h.Darwin b/distribution/src/rb/src/mcpp/config.h.Darwin new file mode 100644 index 00000000000..8d5154fa1ac --- /dev/null +++ b/distribution/src/rb/src/mcpp/config.h.Darwin @@ -0,0 +1,227 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if '0x5c' in BIG5 multi-byte character is safe. */ +/* #undef BIGFIVE_IS_ESCAPE_FREE */ + +/* Define the target compiler. */ +#define COMPILER INDEPENDENT + +/* Define the type of size_t. */ +/* #undef COMPILER_SP1_VAL */ + +/* Define the type of ptrdiff_t. */ +/* #undef COMPILER_SP2_VAL */ + +/* Define the type of wchar_t. */ +/* #undef COMPILER_SP3_VAL */ + +/* Define the name of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD */ + +/* Define the value of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD_VAL */ + +/* Define the name of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD */ + +/* Define the value of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD_VAL */ + +/* Define compiler-specific C++ include directory 1. */ +/* #undef CPLUS_INCLUDE_DIR1 */ + +/* Define compiler-specific C++ include directory 2. */ +/* #undef CPLUS_INCLUDE_DIR2 */ + +/* Define compiler-specific C++ include directory 3. */ +/* #undef CPLUS_INCLUDE_DIR3 */ + +/* Define compiler-specific C++ include directory 4. */ +/* #undef CPLUS_INCLUDE_DIR4 */ + +/* Define the cpu-specific-macro. */ +#define CPU "i386" + +/* Define the name of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD */ + +/* Define the value of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD_VAL */ + +/* Define the name of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD */ + +/* Define the value of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD_VAL */ + +/* Define root directory of CYGWIN. */ +/* #undef CYGWIN_ROOT_DIRECTORY */ + +/* Define compiler-specific C include directory 1. */ +/* #undef C_INCLUDE_DIR1 */ + +/* Define compiler-specific C include directory 2. */ +/* #undef C_INCLUDE_DIR2 */ + +/* Define compiler-specific C include directory 3. */ +/* #undef C_INCLUDE_DIR3 */ + +/* Define if the argument of pragma is macro expanded. */ +/* #undef EXPAND_PRAGMA */ + +/* Define if the cases of file name are folded. */ +#define FNAME_FOLD 1 + +/* Define MacOS-specific framework directory 1. */ +#define FRAMEWORK1 "/System/Library/Frameworks" + +/* Define MacOS-specific framework directory 2. */ +#define FRAMEWORK2 "/Library/Frameworks" + +/* Define MacOS-specific framework directory 3. */ +/* #undef FRAMEWORK3 */ + +/* Define gcc major version. */ +#define GCC_MAJOR_VERSION "4" + +/* Define gcc minor version. */ +#define GCC_MINOR_VERSION "2" + +/* Define if digraphs are available. */ +/* #undef HAVE_DIGRAPHS */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if the system has the type `intmax_t'. */ +#define HAVE_INTMAX_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdint.h,> header file. */ +/* #undef HAVE_STDINT_H_ */ + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <unistd.h,> header file. */ +/* #undef HAVE_UNISTD_H_ */ + +/* Define the host compiler name. */ +#define HOST_CMP_NAME "GCC" + +/* Define the host compiler. */ +#define HOST_COMPILER GNUC + +/* Define the host system. */ +#define HOST_SYSTEM SYS_MAC + +/* Define include directory to install mcpp_g*.h header files. */ +/* #undef INC_DIR */ + +/* Define if '0x5c' in ISO2022-JP multi-byte character is safe. */ +/* #undef ISO2022_JP_IS_ESCAPE_FREE */ + +/* Define output format of line directive. */ +/* #undef LINE_PREFIX */ + +/* Define printf length modifier for the longest integer. */ +#define LL_FORM "j" + +/* Define if build libmcpp */ +#define MCPP_LIB 1 + +/* Define /mingw directory. */ +/* #undef MINGW_DIRECTORY */ + +/* Define root directory of MSYS. */ +/* #undef MSYS_ROOT_DIRECTORY */ + +/* Define the suffix of object file. */ +#define OBJEXT "o" + +/* Name of package */ +#define PACKAGE "mcpp" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "kmatsui@t3.rim.or.jp" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "mcpp" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "mcpp 2.7.2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "mcpp" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.7.2" + +/* Define include preference. */ +/* #undef SEARCH_INIT */ + +/* Define if '0x5c' in SJIS multi-byte character is safe. */ +/* #undef SJIS_IS_ESCAPE_FREE */ + +/* Define the default value of __STDC__. */ +/* #undef STDC */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define the default value of __STDC_VERSION__. */ +/* #undef STDC_VERSION */ + +/* Define whether output format of line directive is C source style. */ +/* #undef STD_LINE_PREFIX */ + +/* Define the target system. */ +#define SYSTEM SYS_MAC + +/* Define the version of FreeBSD. */ +/* #undef SYSTEM_EXT_VAL */ + +/* Define the name of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD */ + +/* Define the value of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD_VAL */ + +/* Define the name of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD */ + +/* Define the value of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD_VAL */ + +/* Version number of package */ +#define VERSION "2.7.2" diff --git a/distribution/src/rb/src/mcpp/config.h.Linux b/distribution/src/rb/src/mcpp/config.h.Linux new file mode 100644 index 00000000000..69134c7df47 --- /dev/null +++ b/distribution/src/rb/src/mcpp/config.h.Linux @@ -0,0 +1,227 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if '0x5c' in BIG5 multi-byte character is safe. */ +/* #undef BIGFIVE_IS_ESCAPE_FREE */ + +/* Define the target compiler. */ +#define COMPILER INDEPENDENT + +/* Define the type of size_t. */ +/* #undef COMPILER_SP1_VAL */ + +/* Define the type of ptrdiff_t. */ +/* #undef COMPILER_SP2_VAL */ + +/* Define the type of wchar_t. */ +/* #undef COMPILER_SP3_VAL */ + +/* Define the name of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD */ + +/* Define the value of COMPILER-specific OLD-style predefined macro. */ +/* #undef COMPILER_SP_OLD_VAL */ + +/* Define the name of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD */ + +/* Define the value of COMPILER-specific STD-style predefined macro. */ +/* #undef COMPILER_SP_STD_VAL */ + +/* Define compiler-specific C++ include directory 1. */ +/* #undef CPLUS_INCLUDE_DIR1 */ + +/* Define compiler-specific C++ include directory 2. */ +/* #undef CPLUS_INCLUDE_DIR2 */ + +/* Define compiler-specific C++ include directory 3. */ +/* #undef CPLUS_INCLUDE_DIR3 */ + +/* Define compiler-specific C++ include directory 4. */ +/* #undef CPLUS_INCLUDE_DIR4 */ + +/* Define the cpu-specific-macro. */ +#define CPU "i386" + +/* Define the name of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD */ + +/* Define the value of CPU-specific OLD-style predefined macro. */ +/* #undef CPU_SP_OLD_VAL */ + +/* Define the name of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD */ + +/* Define the value of CPU-specific STD-style predefined macro. */ +/* #undef CPU_SP_STD_VAL */ + +/* Define root directory of CYGWIN. */ +/* #undef CYGWIN_ROOT_DIRECTORY */ + +/* Define compiler-specific C include directory 1. */ +/* #undef C_INCLUDE_DIR1 */ + +/* Define compiler-specific C include directory 2. */ +/* #undef C_INCLUDE_DIR2 */ + +/* Define compiler-specific C include directory 3. */ +/* #undef C_INCLUDE_DIR3 */ + +/* Define if the argument of pragma is macro expanded. */ +/* #undef EXPAND_PRAGMA */ + +/* Define if the cases of file name are folded. */ +/* #undef FNAME_FOLD */ + +/* Define MacOS-specific framework directory 1. */ +/* #undef FRAMEWORK1 */ + +/* Define MacOS-specific framework directory 2. */ +/* #undef FRAMEWORK2 */ + +/* Define MacOS-specific framework directory 3. */ +/* #undef FRAMEWORK3 */ + +/* Define gcc major version. */ +#define GCC_MAJOR_VERSION "4" + +/* Define gcc minor version. */ +#define GCC_MINOR_VERSION "8" + +/* Define if digraphs are available. */ +/* #undef HAVE_DIGRAPHS */ + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if the system has the type `intmax_t'. */ +#define HAVE_INTMAX_T 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if the system has the type `long long'. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the <memory.h> header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdint.h,> header file. */ +/* #undef HAVE_STDINT_H_ */ + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the <unistd.h,> header file. */ +/* #undef HAVE_UNISTD_H_ */ + +/* Define the host compiler name. */ +#define HOST_CMP_NAME "GCC" + +/* Define the host compiler. */ +#define HOST_COMPILER GNUC + +/* Define the host system. */ +#define HOST_SYSTEM SYS_LINUX + +/* Define include directory to install mcpp_g*.h header files. */ +/* #undef INC_DIR */ + +/* Define if '0x5c' in ISO2022-JP multi-byte character is safe. */ +/* #undef ISO2022_JP_IS_ESCAPE_FREE */ + +/* Define output format of line directive. */ +/* #undef LINE_PREFIX */ + +/* Define printf length modifier for the longest integer. */ +#define LL_FORM "j" + +/* Define if build libmcpp */ +#define MCPP_LIB 1 + +/* Define /mingw directory. */ +/* #undef MINGW_DIRECTORY */ + +/* Define root directory of MSYS. */ +/* #undef MSYS_ROOT_DIRECTORY */ + +/* Define the suffix of object file. */ +#define OBJEXT "o" + +/* Name of package */ +#define PACKAGE "mcpp" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "kmatsui@t3.rim.or.jp" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "mcpp" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "mcpp 2.7.2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "mcpp" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "2.7.2" + +/* Define include preference. */ +/* #undef SEARCH_INIT */ + +/* Define if '0x5c' in SJIS multi-byte character is safe. */ +/* #undef SJIS_IS_ESCAPE_FREE */ + +/* Define the default value of __STDC__. */ +/* #undef STDC */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define the default value of __STDC_VERSION__. */ +/* #undef STDC_VERSION */ + +/* Define whether output format of line directive is C source style. */ +/* #undef STD_LINE_PREFIX */ + +/* Define the target system. */ +#define SYSTEM SYS_LINUX + +/* Define the version of FreeBSD. */ +/* #undef SYSTEM_EXT_VAL */ + +/* Define the name of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD */ + +/* Define the value of SYSTEM-specific OLD-style predefined macro. */ +/* #undef SYSTEM_SP_OLD_VAL */ + +/* Define the name of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD */ + +/* Define the value of SYSTEM-specific STD-style predefined macro. */ +/* #undef SYSTEM_SP_STD_VAL */ + +/* Version number of package */ +#define VERSION "2.7.2" diff --git a/distribution/src/rb/src/mcpp/config.h.MINGW b/distribution/src/rb/src/mcpp/config.h.MINGW new file mode 100644 index 00000000000..5d21598f007 --- /dev/null +++ b/distribution/src/rb/src/mcpp/config.h.MINGW @@ -0,0 +1,7 @@ +#define COMPILER INDEPENDENT +#define HOST_SYSTEM SYS_WIN +#define SYSTEM SYS_WIN +#define CPU "x86_64" +#define HOST_COMPILER MSC +#define VERSION "2.7.2" +#define MCPP_LIB 1 diff --git a/php/config/Make.rules.php b/php/config/Make.rules.php index e122b32d505..1c570bd4201 100644 --- a/php/config/Make.rules.php +++ b/php/config/Make.rules.php @@ -107,7 +107,8 @@ else endif libdir = $(top_srcdir)/lib -ifneq ($(prefix), /usr) + +ifndef usr_dir_install install_phpdir = $(prefix)/php install_libdir = $(prefix)/php else diff --git a/py/config/Make.rules b/py/config/Make.rules index b142a7ddc48..6b7e709bc2c 100644 --- a/py/config/Make.rules +++ b/py/config/Make.rules @@ -46,19 +46,20 @@ embedded_runpath ?= yes # # If multiple versions of Python are installed and you want a specific -# version used for building the Ice extension, then set PYTHON_VERSION -# to a value like "python2.5". Otherwise, the settings below use the -# default Python interpreter found in your PATH. +# version used for building the Ice extension, then set PYTHON to +# the specific to the location of the python interpreter. # -PYTHON_VERSION ?= python$(shell python -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())") +PYTHON ?= python -PYTHON_BASE_VERSION ?= $(shell $(PYTHON_VERSION) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())") +PYTHON_VERSION ?= python$(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())") -PYTHON_INCLUDE_DIR ?= $(shell $(PYTHON_VERSION) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_inc())") +PYTHON_BASE_VERSION ?= $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_version())") -PYTHON_LIB_DIR ?= $(shell $(PYTHON_VERSION) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_config_var('LIBPL'))") +PYTHON_INCLUDE_DIR ?= $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_python_inc())") -PYTHON_LIB_SUFFIX ?= $(shell $(PYTHON_VERSION) -c "import sys; sys.stdout.write(sys.__dict__['abiflags'] if 'abiflags' in sys.__dict__ else '')") +PYTHON_LIB_DIR ?= $(shell $(PYTHON) -c "import sys; import distutils.sysconfig as ds; sys.stdout.write(ds.get_config_var('LIBPL'))") + +PYTHON_LIB_SUFFIX ?= $(shell $(PYTHON) -c "import sys; sys.stdout.write(sys.__dict__['abiflags'] if 'abiflags' in sys.__dict__ else '')") PYTHON_LIB_NAME ?= $(PYTHON_VERSION)$(PYTHON_LIB_SUFFIX) @@ -91,7 +92,7 @@ else include $(top_srcdir)/../config/Make.common.rules endif -ifneq ($(prefix),/usr) +ifndef usr_dir_install RPATH_DIR = $(prefix)/$(libsubdir) endif @@ -105,29 +106,17 @@ else endif libdir = $(top_srcdir)/python -ifneq ($(prefix), /usr) + +ifndef usr_dir_install install_pythondir = $(prefix)/python install_libdir = $(prefix)/python else - ifeq ($(shell test -d $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/dist-packages && echo 0),0) - install_pythondir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/dist-packages - install_libdir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/dist-packages - endif - - ifeq ($(shell test -d $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/site-packages && echo 0),0) - install_pythondir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/site-packages - install_libdir = $(prefix)/$(libsubdir)/$(PYTHON_VERSION)/site-packages - endif - - ifeq ($(shell test -d $(prefix)/lib/$(PYTHON_VERSION)/dist-packages && echo 0),0) - install_pythondir = $(prefix)/lib/$(PYTHON_VERSION)/dist-packages - install_libdir = $(prefix)/lib/$(PYTHON_VERSION)/dist-packages - endif - - ifeq ($(shell test -d $(prefix)/lib/$(PYTHON_VERSION)/site-packages && echo 0),0) - install_pythondir = $(prefix)/lib/$(PYTHON_VERSION)/site-packages - install_libdir = $(prefix)/lib/$(PYTHON_VERSION)/site-packages - endif + # + # The install_dir script says where python wants site-packages installed. + # + + install_pythondir = $(shell $(PYTHON) $(top_srcdir)/config/install_dir) + install_libdir = $(install_pythondir) endif ifeq ($(UNAME),SunOS) diff --git a/py/config/install_dir b/py/config/install_dir new file mode 100644 index 00000000000..8bb2e0c62f5 --- /dev/null +++ b/py/config/install_dir @@ -0,0 +1,35 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +from setuptools.command.easy_install import easy_install +class easy_install_default(easy_install): + """ class easy_install had problems with the fist parameter not being + an instance of Distribution, even though it was. This is due to + some import-related mess. + """ + + def __init__(self): + from distutils.dist import Distribution + dist = Distribution() + self.distribution = dist + self.initialize_options() + self._dry_run = None + self.verbose = dist.verbose + self.force = None + self.help = 0 + self.finalized = 0 + +e = easy_install_default() +import distutils.errors +try: + e.finalize_options() +except distutils.errors.DistutilsError: + pass + +print e.install_dir diff --git a/py/modules/IcePy/Init.cpp b/py/modules/IcePy/Init.cpp index 96425f593e8..5d1541af69a 100644 --- a/py/modules/IcePy/Init.cpp +++ b/py/modules/IcePy/Init.cpp @@ -25,6 +25,7 @@ #include <Proxy.h> #include <Slice.h> #include <Types.h> +#include <Ice/Initialize.h> using namespace std; using namespace IcePy; @@ -87,6 +88,8 @@ static PyMethodDef methods[] = PyDoc_STR(STRCAST("loadSlice(cmd) -> None")) }, { STRCAST("cleanup"), reinterpret_cast<PyCFunction>(IcePy_cleanup), METH_NOARGS, PyDoc_STR(STRCAST("internal function")) }, + { STRCAST("compile"), reinterpret_cast<PyCFunction>(IcePy_compile), METH_VARARGS, + PyDoc_STR(STRCAST("internal function")) }, { 0, 0 } /* sentinel */ }; @@ -115,6 +118,12 @@ PyDoc_STRVAR(moduleDoc, "The Internet Communications Engine."); #endif +extern "C" +{ +Ice::Plugin* createIceSSL(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&); +Ice::Plugin* createIceDiscovery(const Ice::CommunicatorPtr&, const string&, const Ice::StringSeq&); +} + PyMODINIT_FUNC #ifndef _WIN32 // On Windows, PyMODINIT_FUNC already defines dllexport ICE_DECLSPEC_EXPORT @@ -127,6 +136,9 @@ initIcePy(void) { PyObject* module; + Ice::registerPluginFactory("IceSSL", createIceSSL, false); + Ice::registerPluginFactory("IceDiscovery", createIceDiscovery, false); + // // Notify Python that we are a multi-threaded extension. // diff --git a/py/modules/IcePy/Slice.cpp b/py/modules/IcePy/Slice.cpp index 3d8862182fd..9adccc5e4c3 100644 --- a/py/modules/IcePy/Slice.cpp +++ b/py/modules/IcePy/Slice.cpp @@ -14,6 +14,7 @@ #include <Util.h> #include <Slice/Preprocessor.h> #include <Slice/PythonUtil.h> +#include <Slice/Util.h> #include <IceUtil/Options.h> // @@ -199,3 +200,60 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) Py_INCREF(Py_None); return Py_None; } + +extern "C" +PyObject* +IcePy_compile(PyObject* /*self*/, PyObject* args) +{ + PyObject* list = 0; + if(!PyArg_ParseTuple(args, STRCAST("O!"), &PyList_Type, &list)) + { + return 0; + } + + vector<string> argSeq; + if(list) + { + if(!listToStringSeq(list, argSeq)) + { + return 0; + } + } + + char** argv = new char*[argSeq.size()]; + for(size_t i = 0; i < argSeq.size(); ++i) + { + argv[i] = const_cast<char*>(argSeq[i].c_str()); + } + + int rc; + try + { + rc = Slice::Python::compile(static_cast<int>(argSeq.size()), argv); + } + catch(const std::exception& ex) + { + getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + rc = EXIT_FAILURE; + } + catch(const std::string& msg) + { + getErrorStream() << argv[0] << ": error:" << msg << endl; + rc = EXIT_FAILURE; + } + catch(const char* msg) + { + getErrorStream() << argv[0] << ": error:" << msg << endl; + rc = EXIT_FAILURE; + } + catch(...) + { + getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + rc = EXIT_FAILURE; + } + + delete[] argv; + + // PyInt_FromLong doesn't exist in python 3. + return PyLong_FromLong(rc); +} diff --git a/py/modules/IcePy/Slice.h b/py/modules/IcePy/Slice.h index 5c4a2c18533..4d142906d66 100644 --- a/py/modules/IcePy/Slice.h +++ b/py/modules/IcePy/Slice.h @@ -13,5 +13,6 @@ #include <Config.h> extern "C" PyObject* IcePy_loadSlice(PyObject*, PyObject*); +extern "C" PyObject* IcePy_compile(PyObject*, PyObject*); #endif diff --git a/py/python/Ice.py b/py/python/Ice.py index 7133fd5956f..ef8c253d829 100644 --- a/py/python/Ice.py +++ b/py/python/Ice.py @@ -294,6 +294,14 @@ def getSliceDir(): '''Convenience function for locating the directory containing the Slice files.''' # + # Detect setup.py installation in site-packages. The slice + # files live along side Ice.py + # + dir = os.path.join(os.path.dirname(__file__), "slice") + if os.path.isdir(dir): + return dir + + # # Get the parent of the directory containing this file (Ice.py). # pyHome = os.path.join(os.path.dirname(__file__), "..") diff --git a/rb/config/Make.rules b/rb/config/Make.rules index 6e37fd8b405..06990afbd36 100644 --- a/rb/config/Make.rules +++ b/rb/config/Make.rules @@ -150,7 +150,7 @@ install_rubydir = $(prefix)/ruby install_libdir = $(prefix)/ruby endif else -ifneq ($(prefix), /usr) +ifndef usr_dir_install install_rubydir = $(prefix)/ruby install_libdir = $(prefix)/ruby else @@ -158,6 +158,7 @@ install_rubydir = $(RUBY_LIB_DIR) install_libdir = $(RUBY_LIB_DIR)/$(RUBY_ARCH) endif endif + install_bindir = $(prefix)/$(binsubdir) # @@ -169,7 +170,7 @@ else configdir = $(top_srcdir)/../cpp/config endif -ifneq ($(prefix),/usr) +ifndef usr_dir_install RPATH_DIR = $(prefix)/$(libsubdir) endif @@ -182,7 +183,7 @@ else ICE_LIB_DIR = -L$(ice_dir)/$(libsubdir) ICE_FLAGS = -I$(ice_dir)/include endif -ICE_LIBS = $(ICE_LIB_DIR) -lIce -lSlice -lIceUtil +ICE_LIBS = $(ICE_LIB_DIR) -lIceDiscovery -lIce -lIceSSL -lSlice -lIceUtil CPPFLAGS = ICECPPFLAGS = -I$(slicedir) diff --git a/rb/config/Make.rules.Darwin b/rb/config/Make.rules.Darwin index 0ba47dbc5f7..3386f07c09e 100644 --- a/rb/config/Make.rules.Darwin +++ b/rb/config/Make.rules.Darwin @@ -7,11 +7,6 @@ # # ********************************************************************** -$(warning ===================================================================) -$(warning OS X is currently an unsupported platform for Ice for Ruby.) -$(warning Contact sales@zeroc.com if you wish to sponsor official support.) -$(warning ===================================================================) - # # This file is included by Make.rules when uname is Darwin. # diff --git a/rb/src/IceRuby/Init.cpp b/rb/src/IceRuby/Init.cpp index 96ca34deca4..c23e57b5dbb 100644 --- a/rb/src/IceRuby/Init.cpp +++ b/rb/src/IceRuby/Init.cpp @@ -26,9 +26,15 @@ static VALUE iceModule; extern "C" { +Ice::Plugin* createIceSSL(const Ice::CommunicatorPtr&, const std::string&, const Ice::StringSeq&); +Ice::Plugin* createIceDiscovery(const Ice::CommunicatorPtr&, const string&, const Ice::StringSeq&); + void ICE_DECLSPEC_EXPORT Init_IceRuby() { + Ice::registerPluginFactory("IceSSL", createIceSSL, false); + Ice::registerPluginFactory("IceDiscovery", createIceDiscovery, false); + iceModule = rb_define_module("Ice"); initCommunicator(iceModule); initLogger(iceModule); diff --git a/rb/src/IceRuby/Slice.cpp b/rb/src/IceRuby/Slice.cpp index a6a8a13d300..06f1d232866 100644 --- a/rb/src/IceRuby/Slice.cpp +++ b/rb/src/IceRuby/Slice.cpp @@ -11,6 +11,7 @@ #include <Util.h> #include <Slice/Preprocessor.h> #include <Slice/RubyUtil.h> +#include <Slice/Util.h> #include <IceUtil/Options.h> using namespace std; @@ -156,8 +157,67 @@ IceRuby_loadSlice(int argc, VALUE* argv, VALUE self) return Qnil; } +extern "C" +VALUE +IceRuby_compile(int argc, VALUE* argv, VALUE self) +{ + ICE_RUBY_TRY + { + if(argc != 1) + { + throw RubyException(rb_eArgError, "wrong number of arguments"); + } + + vector<string> argSeq; + if(!arrayToStringSeq(argv[0], argSeq)) + { + throw RubyException(rb_eTypeError, "argument is not an array"); + } + char** argv = new char*[argSeq.size()+1]; + // Manufacture a fake argv[0]. + argv[0] = const_cast<char*>("slice2rb"); + for(size_t i = 0; i < argSeq.size(); ++i) + { + argv[i+1] = const_cast<char*>(argSeq[i].c_str()); + } + + int rc; + try + { + rc = Slice::Ruby::compile(argSeq.size()+1, argv); + } + catch(const std::exception& ex) + { + getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + rc = EXIT_FAILURE; + } + catch(const std::string& msg) + { + getErrorStream() << argv[0] << ": error:" << msg << endl; + rc = EXIT_FAILURE; + } + catch(const char* msg) + { + getErrorStream() << argv[0] << ": error:" << msg << endl; + rc = EXIT_FAILURE; + } + catch(...) + { + getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + rc = EXIT_FAILURE; + } + + delete[] argv; + return INT2FIX(rc); + } + ICE_RUBY_CATCH + + return Qnil; +} + void IceRuby::initSlice(VALUE iceModule) { rb_define_module_function(iceModule, "loadSlice", CAST_METHOD(IceRuby_loadSlice), -1); + rb_define_module_function(iceModule, "compile", CAST_METHOD(IceRuby_compile), -1); } |