ruby: add detection and fix compilation with Ruby 2.0 (patch #8209)
Now the search for Ruby is first performed with pkg-config and includes detection of Ruby 2.0. If not found, the old code for detection is used (for old distros or old Ruby versions). The specific test on Ruby 1.9.0 (to disable this version) has been removed (1.9.0 was a dev/unstable version from 2007, quite old now).
This commit is contained in:
parent
15394897e3
commit
d8b9e0a6bf
@ -127,7 +127,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
* python: fix load of scripts with python >= 3.3
|
||||
* relay: send backlog for irc private buffers
|
||||
* relay: fix memory leak on unload of relay plugin
|
||||
* ruby: fix ruby init with ruby >= 2.0 (bug #41115)
|
||||
* ruby: add detection and fix compilation with Ruby 2.0 (patch #8209)
|
||||
* ruby: fix ruby init with Ruby >= 2.0 (bug #41115)
|
||||
* scripts: fix script interpreter used after register during load of script
|
||||
in python/perl/ruby/lua/guile plugins (bug #41345)
|
||||
* xfer: add support of IPv6 for DCC chat/file (patch #7992)
|
||||
@ -614,7 +615,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
* relay: add object type "arr" (array) in WeeChat protocol
|
||||
* relay: fix freeze when writing on relay socket (use non-blocking sockets in
|
||||
relay for irc and weechat protocols) (bug #36655)
|
||||
* ruby: detect ruby version 1.9.3 in cmake and autotools
|
||||
* ruby: detect Ruby version 1.9.3 in cmake and autotools
|
||||
* script: new plugin "script" (scripts manager, replacing scripts weeget.py and
|
||||
script.pl)
|
||||
* scripts: add signals for scripts loaded/unloaded/installed/removed
|
||||
|
@ -22,71 +22,78 @@
|
||||
# and libraries are. It also determines what the name of the library is. This
|
||||
# code sets the following variables:
|
||||
#
|
||||
# RUBY_EXECUTABLE = full path to the ruby binary
|
||||
# RUBY_INCLUDE_PATH = path to where ruby.h can be found
|
||||
# RUBY_LIBRARY = path to where libruby.so* can be found
|
||||
# RUBY_INCLUDE_DIRS = C flags to compile with ruby
|
||||
# RUBY_LIBRARY_DIRS = linker flags to compile with ruby (found with pkg-config)
|
||||
# RUBY_LIB = ruby library (found without pkg-config)
|
||||
|
||||
IF(RUBY_FOUND)
|
||||
# Already in cache, be silent
|
||||
SET(RUBY_FIND_QUIETLY TRUE)
|
||||
ENDIF(RUBY_FOUND)
|
||||
|
||||
FIND_PROGRAM(RUBY_EXECUTABLE
|
||||
NAMES ruby1.9.3 ruby193 ruby1.9.2 ruby192 ruby1.9.1 ruby191 ruby1.9 ruby19 ruby1.8 ruby18 ruby1.6 ruby16 ruby
|
||||
PATHS /usr/bin /usr/local/bin /usr/pkg/bin
|
||||
)
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
IF(PKG_CONFIG_FOUND)
|
||||
pkg_search_module(RUBY ruby-2.0 ruby-1.9 ruby-1.8)
|
||||
ENDIF(PKG_CONFIG_FOUND)
|
||||
|
||||
IF(RUBY_EXECUTABLE)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubyhdrdir'] || RbConfig::CONFIG['archdir']"
|
||||
OUTPUT_VARIABLE RUBY_ARCH_DIR
|
||||
IF(RUBY_FOUND)
|
||||
|
||||
SET(RUBY_LIB "")
|
||||
MARK_AS_ADVANCED(RUBY_LIB)
|
||||
|
||||
ELSE(RUBY_FOUND)
|
||||
|
||||
FIND_PROGRAM(RUBY_EXECUTABLE
|
||||
NAMES ruby1.9.3 ruby193 ruby1.9.2 ruby192 ruby1.9.1 ruby191 ruby1.9 ruby19 ruby1.8 ruby18 ruby
|
||||
PATHS /usr/bin /usr/local/bin /usr/pkg/bin
|
||||
)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['arch']"
|
||||
OUTPUT_VARIABLE RUBY_ARCH
|
||||
)
|
||||
IF(RUBY_EXECUTABLE)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['libdir']"
|
||||
OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH
|
||||
)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubyhdrdir'] || RbConfig::CONFIG['archdir']"
|
||||
OUTPUT_VARIABLE RUBY_ARCH_DIR
|
||||
)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubylibdir']"
|
||||
OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH
|
||||
)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['arch']"
|
||||
OUTPUT_VARIABLE RUBY_ARCH
|
||||
)
|
||||
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['ruby_version']"
|
||||
OUTPUT_VARIABLE RUBY_VERSION
|
||||
)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['libdir']"
|
||||
OUTPUT_VARIABLE RUBY_POSSIBLE_LIB_PATH
|
||||
)
|
||||
|
||||
FIND_PATH(RUBY_INCLUDE_PATH
|
||||
NAMES ruby.h
|
||||
PATHS ${RUBY_ARCH_DIR}
|
||||
)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubylibdir']"
|
||||
OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH
|
||||
)
|
||||
|
||||
SET(RUBY_ARCH
|
||||
"${RUBY_INCLUDE_PATH}/${RUBY_ARCH}")
|
||||
FIND_PATH(RUBY_INCLUDE_DIRS
|
||||
NAMES ruby.h
|
||||
PATHS ${RUBY_ARCH_DIR}
|
||||
)
|
||||
|
||||
FIND_LIBRARY(RUBY_LIBRARY
|
||||
NAMES ruby-1.9.3 ruby1.9.3 ruby193 ruby-1.9.2 ruby1.9.2 ruby192 ruby-1.9.1 ruby1.9.1 ruby191 ruby1.9 ruby19 ruby1.8 ruby18 ruby1.6 ruby16 ruby
|
||||
PATHS ${RUBY_POSSIBLE_LIB_PATH} ${RUBY_RUBY_LIB_PATH}
|
||||
)
|
||||
SET(RUBY_INCLUDE_ARCH "${RUBY_INCLUDE_DIRS}/${RUBY_ARCH}")
|
||||
|
||||
IF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
|
||||
SET(RUBY_FOUND TRUE)
|
||||
ENDIF(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
|
||||
FIND_LIBRARY(RUBY_LIB
|
||||
NAMES ruby-1.9.3 ruby1.9.3 ruby193 ruby-1.9.2 ruby1.9.2 ruby192 ruby-1.9.1 ruby1.9.1 ruby191 ruby1.9 ruby19 ruby1.8 ruby18 ruby
|
||||
PATHS ${RUBY_POSSIBLE_LIB_PATH} ${RUBY_RUBY_LIB_PATH}
|
||||
)
|
||||
|
||||
IF(${RUBY_VERSION} STREQUAL "1.9.0")
|
||||
SET(RUBY_FOUND FALSE)
|
||||
ENDIF(${RUBY_VERSION} STREQUAL "1.9.0")
|
||||
IF(RUBY_LIB AND RUBY_INCLUDE_DIRS)
|
||||
SET(RUBY_FOUND TRUE)
|
||||
ENDIF(RUBY_LIB AND RUBY_INCLUDE_DIRS)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
RUBY_EXECUTABLE
|
||||
RUBY_LIBRARY
|
||||
RUBY_ARCH
|
||||
RUBY_INCLUDE_PATH
|
||||
)
|
||||
ENDIF(RUBY_EXECUTABLE)
|
||||
SET(RUBY_INCLUDE_DIRS "${RUBY_INCLUDE_DIRS};${RUBY_INCLUDE_ARCH}")
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
RUBY_INCLUDE_DIRS
|
||||
RUBY_LIBRARY_DIRS
|
||||
RUBY_LIB
|
||||
)
|
||||
|
||||
ENDIF(RUBY_EXECUTABLE)
|
||||
|
||||
ENDIF(RUBY_FOUND)
|
||||
|
33
configure.ac
33
configure.ac
@ -553,31 +553,34 @@ fi
|
||||
RUBY_VERSION=
|
||||
|
||||
if test "x$enable_ruby" = "xyes" ; then
|
||||
AC_PATH_PROGS(RUBY, ruby1.9.3 ruby1.9.2 ruby1.9.1 ruby1.9 ruby1.8 ruby)
|
||||
if test -z $RUBY ; then
|
||||
AC_MSG_WARN([
|
||||
RUBY_CFLAGS=""
|
||||
RUBY_LFLAGS=""
|
||||
for v in "2.0" "1.9" "1.8" ; do
|
||||
pkgconfig_ruby_found=`$PKGCONFIG --exists ruby-$v 2>/dev/null`
|
||||
if test "x$?" = "x0" ; then
|
||||
RUBY_VERSION=`$PKGCONFIG --modversion ruby-$v`
|
||||
RUBY_CFLAGS=`$PKGCONFIG --cflags ruby-$v`
|
||||
RUBY_LFLAGS=`$PKGCONFIG --libs ruby-$v`
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if test "x$RUBY_CFLAGS" = "x" -o "x$RUBY_LFLAGS" = "x" ; then
|
||||
AC_PATH_PROGS(RUBY, ruby1.9.3 ruby1.9.2 ruby1.9.1 ruby1.9 ruby1.8 ruby)
|
||||
if test -z $RUBY ; then
|
||||
AC_MSG_WARN([
|
||||
*** Ruby must be installed on your system but ruby interpreter couldn't be found in path.
|
||||
*** Please check that ruby is in path, or install it with your software package manager.
|
||||
*** WeeChat will be built without Ruby support.])
|
||||
enable_ruby="no"
|
||||
not_found="$not_found ruby"
|
||||
else
|
||||
RUBY_VERSION=`$RUBY -rrbconfig -e "puts RbConfig::CONFIG[['ruby_version']]"`
|
||||
if test "$RUBY_VERSION" = "1.9.0"; then
|
||||
AC_MSG_WARN([
|
||||
*** Ruby header files have been found, but they're of the version 1.9.0.
|
||||
*** Ruby 1.9.0 is an unstable release and should not be used in production.
|
||||
*** Please install Ruby 1.8.x (>= 1.8.6) or >= 1.9.1.
|
||||
*** WeeChat will be built without Ruby support.])
|
||||
enable_ruby="no"
|
||||
not_found="$not_found ruby"
|
||||
else
|
||||
RUBY_VERSION=`$RUBY -rrbconfig -e "puts RbConfig::CONFIG[['MAJOR']] + '.' + RbConfig::CONFIG[['MINOR']] + '.' + RbConfig::CONFIG[['TEENY']]"`
|
||||
RUBY_INCLUDE=`$RUBY -rrbconfig -e "puts RbConfig::CONFIG[['rubyhdrdir']] || RbConfig::CONFIG[['archdir']]"`
|
||||
RUBY_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["arch"]]'`
|
||||
AC_MSG_CHECKING(for Ruby header files)
|
||||
if test -d "$RUBY_INCLUDE/"; then
|
||||
M_RUBY_VERSION=`$RUBY -rrbconfig -e "puts RbConfig::CONFIG[['ruby_version']].gsub(/\./, '')[[0,3]]"`
|
||||
RUBY_CFLAGS="-I$RUBY_INCLUDE/ -I$RUBY_INCLUDE/$RUBY_ARCH -DRUBY_VERSION=$M_RUBY_VERSION"
|
||||
RUBY_CFLAGS="-I$RUBY_INCLUDE/ -I$RUBY_INCLUDE/$RUBY_ARCH"
|
||||
else
|
||||
AC_MSG_WARN([
|
||||
*** Ruby header files couldn't be found on your system.
|
||||
|
@ -23,8 +23,10 @@ weechat-ruby-api.h)
|
||||
SET_TARGET_PROPERTIES(ruby PROPERTIES PREFIX "")
|
||||
|
||||
IF(RUBY_FOUND)
|
||||
INCLUDE_DIRECTORIES(${RUBY_INCLUDE_PATH} ${RUBY_ARCH})
|
||||
TARGET_LINK_LIBRARIES(ruby ${RUBY_LIBRARY} weechat_plugins_scripts)
|
||||
INCLUDE_DIRECTORIES(${RUBY_INCLUDE_DIRS})
|
||||
SET(LINK_LIBS)
|
||||
LIST(APPEND LINK_LIBS ${RUBY_LDFLAGS})
|
||||
TARGET_LINK_LIBRARIES(ruby ${LINK_LIBS} ${RUBY_LIB} weechat_plugins_scripts)
|
||||
ENDIF(RUBY_FOUND)
|
||||
|
||||
INSTALL(TARGETS ruby LIBRARY DESTINATION ${LIBDIR}/plugins)
|
||||
|
@ -23,7 +23,7 @@
|
||||
#undef _
|
||||
|
||||
#include <ruby.h>
|
||||
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
|
||||
#if (defined(RUBY_API_VERSION_MAJOR) && defined(RUBY_API_VERSION_MINOR)) && (RUBY_API_VERSION_MAJOR >= 2 || (RUBY_API_VERSION_MAJOR == 1 && RUBY_API_VERSION_MINOR >= 9))
|
||||
#include <ruby/encoding.h>
|
||||
#endif
|
||||
#ifdef HAVE_RUBY_VERSION_H
|
||||
@ -1149,7 +1149,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
/* init stdout/stderr buffer */
|
||||
ruby_buffer_output[0] = '\0';
|
||||
|
||||
#if defined(RUBY_VERSION) && RUBY_VERSION >= 19
|
||||
#if (defined(RUBY_API_VERSION_MAJOR) && defined(RUBY_API_VERSION_MINOR)) && (RUBY_API_VERSION_MAJOR >= 2 || (RUBY_API_VERSION_MAJOR == 1 && RUBY_API_VERSION_MINOR >= 9))
|
||||
RUBY_INIT_STACK;
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user