diff options
author | Bram Moolenaar <Bram@vim.org> | 2010-10-27 16:49:47 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2010-10-27 16:49:47 +0200 |
commit | 3ca71f1f1f6b83e0ec078897959387fca58bdf55 (patch) | |
tree | cc6b8d8a69e4147709a7028d2757f858ab72778f | |
parent | beca055b0c7bfd5abdfdcbd7f601d060ff3865e5 (diff) | |
download | vim-3ca71f1f1f6b83e0ec078897959387fca58bdf55.zip |
updated for version 7.3.043
Problem: Can't load Ruby dynamically on Unix.
Solution: Adjust the configure script. (James Vega)
-rw-r--r-- | src/Makefile | 13 | ||||
-rwxr-xr-x | src/auto/configure | 11 | ||||
-rw-r--r-- | src/config.h.in | 3 | ||||
-rw-r--r-- | src/configure.in | 10 | ||||
-rw-r--r-- | src/if_ruby.c | 48 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 61 insertions, 26 deletions
diff --git a/src/Makefile b/src/Makefile index e582eedd2..ad9b113d4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -414,12 +414,16 @@ CClink = $(CC) # However, this may still cause problems, such as "import termios" failing. # Build two separate versions of Vim in that case. #CONF_OPT_PYTHON = --enable-pythoninterp +#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic #CONF_OPT_PYTHON3 = --enable-python3interp +#CONF_OPT_PYTHON3 = --enable-python3interp=dynamic # RUBY # Uncomment this when you want to include the Ruby interface. +# First one for static linking, second one for loading when used. # Note: you need the development package (e.g., ruby1.9.1-dev on Ubuntu). #CONF_OPT_RUBY = --enable-rubyinterp +#CONF_OPT_RUBY = --enable-rubyinterp=dynamic #CONF_OPT_RUBY = --enable-rubyinterp --with-ruby-command=ruby1.9.1 # TCL @@ -1047,8 +1051,9 @@ INSTALL_PROG = cp INSTALL_DATA = cp INSTALL_DATA_R = cp -r -### Program to run on installed binary +### Program to run on installed binary. Use the second one to disable strip. #STRIP = strip +#STRIP = /bin/true ### Permissions for binaries {{{1 BINMOD = 755 @@ -1321,7 +1326,7 @@ SHELL = /bin/sh .SUFFIXES: .c .o .pro PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS) -POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS) +POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(TCL_CFLAGS) $(EXTRA_DEFS) ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS) @@ -1329,7 +1334,7 @@ ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS) # with "-E". OSDEF_CFLAGS = $(PRE_DEFS) $(POST_DEFS) -LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) -Dinline= -D__extension__= -Dalloca=alloca +LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) $(RUBY_CFLAGS) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) -Dinline= -D__extension__= -Dalloca=alloca LINT_EXTRA = -DUSE_SNIFF -DHANGUL_INPUT -D"__attribute__(x)=" @@ -2532,7 +2537,7 @@ objects/if_python3.o: if_python3.c if_py_both.h $(CCC) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) -o $@ if_python3.c objects/if_ruby.o: if_ruby.c - $(CCC) -o $@ if_ruby.c + $(CCC) $(RUBY_CFLAGS) -o $@ if_ruby.c objects/if_sniff.o: if_sniff.c $(CCC) -o $@ if_sniff.c diff --git a/src/auto/configure b/src/auto/configure index d09ee92dd..87e6b8e47 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -1427,7 +1427,7 @@ Optional Features: --enable-pythoninterp=OPTS Include Python interpreter. default=no OPTS=no/yes/dynamic --enable-python3interp=OPTS Include Python3 interpreter. default=no OPTS=no/yes/dynamic --enable-tclinterp Include Tcl interpreter. - --enable-rubyinterp Include Ruby interpreter. + --enable-rubyinterp=OPTS Include Ruby interpreter. default=no OPTS=no/yes/dynamic --enable-cscope Include cscope interface. --enable-workshop Include Sun Visual Workshop support. --disable-netbeans Disable NetBeans integration support. @@ -6103,7 +6103,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_rubyinterp" >&5 $as_echo "$enable_rubyinterp" >&6; } -if test "$enable_rubyinterp" = "yes"; then +if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-ruby-command argument" >&5 $as_echo_n "checking --with-ruby-command argument... " >&6; } @@ -6209,6 +6209,13 @@ $as_echo "$rubyhdrdir" >&6; } RUBY_PRO="if_ruby.pro" $as_echo "#define FEAT_RUBY 1" >>confdefs.h + if test "$enable_rubyinterp" = "dynamic"; then + libruby=`$vi_cv_path_ruby -r rbconfig -e 'printf "lib%s.%s\n", Config::CONFIG["RUBY_SO_NAME"], Config::CONFIG["DLEXT"]'` + $as_echo "#define DYNAMIC_RUBY 1" >>confdefs.h + + RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" + RUBY_LIBS= + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found; disabling Ruby" >&5 $as_echo "not found; disabling Ruby" >&6; } diff --git a/src/config.h.in b/src/config.h.in index f6c7fa4aa..4c3a89b76 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -349,6 +349,9 @@ /* Define if you want to include the Ruby interpreter. */ #undef FEAT_RUBY +/* Define for linking via dlopen() or LoadLibrary() */ +#undef DYNAMIC_RUBY + /* Define if you want to include the Tcl interpreter. */ #undef FEAT_TCL diff --git a/src/configure.in b/src/configure.in index 152313b7a..e7794f1ee 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1299,10 +1299,10 @@ AC_SUBST(TCL_LIBS) AC_MSG_CHECKING(--enable-rubyinterp argument) AC_ARG_ENABLE(rubyinterp, - [ --enable-rubyinterp Include Ruby interpreter.], , + [ --enable-rubyinterp[=OPTS] Include Ruby interpreter. [default=no] [OPTS=no/yes/dynamic]], , [enable_rubyinterp="no"]) AC_MSG_RESULT($enable_rubyinterp) -if test "$enable_rubyinterp" = "yes"; then +if test "$enable_rubyinterp" = "yes" -o "$enable_rubyinterp" = "dynamic"; then AC_MSG_CHECKING(--with-ruby-command argument) AC_ARG_WITH(ruby-command, [ --with-ruby-command=RUBY name of the Ruby command (default: ruby)], RUBY_CMD="$withval"; AC_MSG_RESULT($RUBY_CMD), @@ -1360,6 +1360,12 @@ if test "$enable_rubyinterp" = "yes"; then RUBY_OBJ="objects/if_ruby.o" RUBY_PRO="if_ruby.pro" AC_DEFINE(FEAT_RUBY) + if test "$enable_rubyinterp" = "dynamic"; then + libruby=`$vi_cv_path_ruby -r rbconfig -e 'printf "lib%s.%s\n", Config::CONFIG[["RUBY_SO_NAME"]], Config::CONFIG[["DLEXT"]]'` + AC_DEFINE(DYNAMIC_RUBY) + RUBY_CFLAGS="-DDYNAMIC_RUBY_DLL=\\\"$libruby\\\" -DDYNAMIC_RUBY_VER=$rubyversion $RUBY_CFLAGS" + RUBY_LIBS= + fi else AC_MSG_RESULT(not found; disabling Ruby) fi diff --git a/src/if_ruby.c b/src/if_ruby.c index d7df24819..0e95e17b7 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -14,6 +14,8 @@ #include <stdio.h> #include <string.h> +#include "auto/config.h" + #ifdef _WIN32 # if !defined(DYNAMIC_RUBY_VER) || (DYNAMIC_RUBY_VER < 18) # define NT @@ -48,13 +50,15 @@ # define RUBY_EXPORT # endif -#if !(defined(WIN32) || defined(_WIN64)) +#ifndef WIN3264 # include <dlfcn.h> -# define HANDLE void* +# define HINSTANCE void* +# define RUBY_PROC void* # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) # define symbol_from_dll dlsym # define close_dll dlclose #else +# define RUBY_PROC FARPROC # define load_dll vimLoadLib # define symbol_from_dll GetProcAddress # define close_dll FreeLibrary @@ -174,7 +178,9 @@ static void ruby_vim_init(void); #define rb_lastline_get dll_rb_lastline_get #define rb_lastline_set dll_rb_lastline_set #define rb_load_protect dll_rb_load_protect +#ifndef RUBY19_OR_LATER #define rb_num2long dll_rb_num2long +#endif #define rb_num2ulong dll_rb_num2ulong #define rb_obj_alloc dll_rb_obj_alloc #define rb_obj_as_string dll_rb_obj_as_string @@ -186,6 +192,9 @@ static void ruby_vim_init(void); #ifdef rb_str_new2 /* Ruby may #define rb_str_new2 to use rb_str_new_cstr. */ # define need_rb_str_new_cstr 1 +/* Ruby's headers #define rb_str_new_cstr to make use of GCC's + * __builtin_constant_p extension. */ +# undef rb_str_new_cstr # define rb_str_new_cstr dll_rb_str_new_cstr #else # define rb_str_new2 dll_rb_str_new2 @@ -206,9 +215,11 @@ static void ruby_vim_init(void); #endif #define ruby_init dll_ruby_init #define ruby_init_loadpath dll_ruby_init_loadpath -#define NtInitialize dll_NtInitialize -#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 -# define rb_w32_snprintf dll_rb_w32_snprintf +#ifdef WIN3264 +# define NtInitialize dll_NtInitialize +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 +# define rb_w32_snprintf dll_rb_w32_snprintf +# endif #endif #ifdef RUBY19_OR_LATER @@ -283,7 +294,12 @@ static VALUE *dll_ruby_errinfo; #endif static void (*dll_ruby_init) (void); static void (*dll_ruby_init_loadpath) (void); +#ifdef WIN3264 static void (*dll_NtInitialize) (int*, char***); +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 +static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); +# endif +#endif #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 static char * (*dll_rb_string_value_ptr) (volatile VALUE*); static VALUE (*dll_rb_float_new) (double); @@ -293,9 +309,6 @@ static VALUE (*dll_rb_ary_push) (VALUE, VALUE); #ifdef RUBY19_OR_LATER static VALUE (*dll_rb_int2big)(SIGNED_VALUE); #endif -#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 -static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); -#endif #ifdef RUBY19_OR_LATER static void (*dll_ruby_script) (const char*); @@ -317,12 +330,11 @@ VALUE rb_int2big_stub(SIGNED_VALUE x) } #endif -static HINSTANCE hinstRuby = 0; /* Instance of ruby.dll */ +static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */ /* * Table of name to function pointer of ruby. */ -#define RUBY_PROC FARPROC static struct { char *name; @@ -387,15 +399,17 @@ static struct #endif {"ruby_init", (RUBY_PROC*)&dll_ruby_init}, {"ruby_init_loadpath", (RUBY_PROC*)&dll_ruby_init_loadpath}, +#ifdef WIN3264 { -#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER < 19 "NtInitialize", -#else +# else "ruby_sysinit", -#endif +# endif (RUBY_PROC*)&dll_NtInitialize}, -#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 +# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf}, +# endif #endif #if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr}, @@ -424,7 +438,7 @@ end_dynamic_ruby() if (hinstRuby) { close_dll(hinstRuby); - hinstRuby = 0; + hinstRuby = NULL; } } @@ -454,7 +468,7 @@ ruby_runtime_link_init(char *libname, int verbose) ruby_funcname_table[i].name))) { close_dll(hinstRuby); - hinstRuby = 0; + hinstRuby = NULL; if (verbose) EMSG2(_(e_loadfunc), ruby_funcname_table[i].name); return FAIL; @@ -936,9 +950,7 @@ static VALUE get_buffer_line(buf_T *buf, linenr_T n) return line ? vim_str2rb_enc_str(line) : Qnil; } rb_raise(rb_eIndexError, "line number %ld out of range", (long)n); -#ifndef __GNUC__ return Qnil; /* For stop warning */ -#endif } static VALUE buffer_aref(VALUE self, VALUE num) diff --git a/src/version.c b/src/version.c index f18e1497f..344fc3b65 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 43, +/**/ 42, /**/ 41, |