mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
ruby: Add a replacement rb_hash_lookup function for Ruby 1.8.5.
This function was first added to Ruby in 1.8.7.
This commit is contained in:
@@ -981,7 +981,13 @@ AS_IF([test "x$enable_ruby" != "xno"],[
|
||||
AC_CHECK_PROG([RAKE],[rake],[rake],[no])
|
||||
AC_CHECK_LIB([ruby],[ruby_init],[HAVE_LIBRUBY=1],[HAVE_LIBRUBY=])
|
||||
AC_SUBST([RAKE])
|
||||
AS_IF([test -n "$HAVE_LIBRUBY"],[
|
||||
old_LIBS="$LIBS"
|
||||
LIBS="$LIBS -lruby"
|
||||
AC_CHECK_FUNCS([rb_hash_lookup])
|
||||
LIBS="$old_LIBS"
|
||||
])
|
||||
])
|
||||
AM_CONDITIONAL([HAVE_RUBY],
|
||||
[test "x$RAKE" != "xno" && test -n "$HAVE_LIBRUBY"])
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ let rec generate_ruby_c () =
|
||||
generate_header CStyle LGPLv2plus;
|
||||
|
||||
pr "\
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -59,6 +61,20 @@ let rec generate_ruby_c () =
|
||||
#define RSTRING_PTR(r) (RSTRING((r))->ptr)
|
||||
#endif
|
||||
|
||||
/* For RHEL 5 (Ruby 1.8.5) */
|
||||
#ifndef HAVE_RB_HASH_LOOKUP
|
||||
VALUE
|
||||
rb_hash_lookup (VALUE hash, VALUE key)
|
||||
{
|
||||
VALUE val;
|
||||
|
||||
if (!st_lookup (RHASH(hash)->tbl, key, &val))
|
||||
return Qnil;
|
||||
|
||||
return val;
|
||||
}
|
||||
#endif /* !HAVE_RB_HASH_LOOKUP */
|
||||
|
||||
static VALUE m_guestfs; /* guestfs module */
|
||||
static VALUE c_guestfs; /* guestfs_h handle */
|
||||
static VALUE e_Error; /* used for all errors */
|
||||
|
||||
@@ -38,7 +38,7 @@ CLOBBER.include [ "@builddir@/config.save", "@builddir@/ext/**/mkmf.log",
|
||||
# Build locally
|
||||
|
||||
file MAKEFILE => EXT_CONF do |t|
|
||||
unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; mkdir -p @builddir@/ext/guestfs; cd @builddir@/ext/guestfs; @RUBY@ #{EXT_CONF} --with-_guestfs-include=$top_srcdir/src --with-_guestfs-lib=$top_builddir/src/.libs"
|
||||
unless sh "top_srcdir=$(pwd)/@top_srcdir@; top_builddir=$(pwd)/@top_builddir@; export ARCHFLAGS=\"-arch $(uname -m)\"; mkdir -p @builddir@/ext/guestfs; cd @builddir@/ext/guestfs; @RUBY@ #{EXT_CONF} --with-_guestfs-include=$top_srcdir/src:$top_builddir --with-_guestfs-lib=$top_builddir/src/.libs"
|
||||
$stderr.puts "Failed to run extconf"
|
||||
break
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user