Skip to content

Commit

Permalink
port to ruby 1.9 ( segfaults now in our ruby )
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jun 7, 2012
1 parent 4de5ca4 commit a57589f
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 56 deletions.
2 changes: 1 addition & 1 deletion VERSION.cmake
@@ -1,3 +1,3 @@
SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "3")
SET(VERSION_PATCH "10")
SET(VERSION_PATCH "11")
53 changes: 17 additions & 36 deletions cmake/modules/FindRuby.cmake
Expand Up @@ -15,65 +15,46 @@ if(RUBY_LIBRARY AND RUBY_INCLUDE_PATH)
set(RUBY_FIND_QUIETLY TRUE)
endif (RUBY_LIBRARY AND RUBY_INCLUDE_PATH)

# RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'`
# RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'`
# RUBY_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'`
# RUBY_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'`
# RUBY_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'`
FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby1.9 ruby19 )

FIND_PROGRAM(RUBY_EXECUTABLE NAMES ruby ruby1.8 ruby18 )

EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['archdir']"
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['archdir']"
OUTPUT_VARIABLE RUBY_ARCH_DIR)

EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['libdir']"
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 Config::CONFIG['rubylibdir']"
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubylibdir']"
OUTPUT_VARIABLE RUBY_RUBY_LIB_PATH)

# site_ruby
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['sitearchdir']"
OUTPUT_VARIABLE RUBY_SITEARCH_DIR)

EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['sitelibdir']"
OUTPUT_VARIABLE RUBY_SITELIB_DIR)


# vendor_ruby
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print '-rvendor-specific'"
OUTPUT_VARIABLE RUBY_VENDOR_ARG)

IF(RUBY_VENDOR_ARG)
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorarchdir']"
OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['vendorarchdir']"
OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)

EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['vendorlibdir']"
OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
ELSE(RUBY_VENDOR_ARG)
# fall back to site*dir
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitearchdir']"
OUTPUT_VARIABLE RUBY_VENDORARCH_DIR)
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['vendorlibdir']"
OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)

EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['sitelibdir']"
OUTPUT_VARIABLE RUBY_VENDORLIB_DIR)
ENDIF(RUBY_VENDOR_ARG)
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['rubyhdrdir']"
OUTPUT_VARIABLE RUBY_HEADER_DIR)

# this is not needed if you use "print" inside the ruby statements
# remove the new lines from the output by replacing them with empty strings
#STRING(REPLACE "\n" "" RUBY_ARCH_DIR "${RUBY_ARCH_DIR}")
#STRING(REPLACE "\n" "" RUBY_POSSIBLE_LIB_PATH "${RUBY_POSSIBLE_LIB_PATH}")
#STRING(REPLACE "\n" "" RUBY_RUBY_LIB_PATH "${RUBY_RUBY_LIB_PATH}")
EXECUTE_PROCESS(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['arch']"
OUTPUT_VARIABLE RUBY_ARCH)


FIND_PATH(RUBY_INCLUDE_PATH
NAMES ruby.h
PATHS
${RUBY_ARCH_DIR}
/usr/lib/ruby/1.8/i586-linux-gnu/ )
${RUBY_HEADER_DIR}
)

FIND_LIBRARY(RUBY_LIBRARY
NAMES ruby ruby1.8
NAMES ruby ruby1.9
PATHS ${RUBY_POSSIBLE_LIB_PATH}
)

Expand Down
5 changes: 5 additions & 0 deletions package/yast2-ruby-bindings.changes
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Jun 7 15:44:29 UTC 2012 - jreidinger@suse.com

- port to ruby 1.9

This comment has been minimized.

Copy link
@kobliha

kobliha Jun 8, 2012

Member

Missing new version in changes file?

This comment has been minimized.

Copy link
@jreidinger

jreidinger Jun 8, 2012

Author Member

yes, you are right, thanks

-------------------------------------------------------------------
Thu Apr 5 10:32:47 CEST 2012 - jsuchome@suse.cz

Expand Down
2 changes: 2 additions & 0 deletions src/ruby/CMakeLists.txt
Expand Up @@ -34,6 +34,8 @@ set(ruby_yast_plugin_HEADERS
)

include_directories( ${RUBY_INCLUDE_PATH} )
#include also arch specific config.h
include_directories( ${RUBY_HEADER_DIR}/${RUBY_ARCH} )
include_directories( ${YAST_INCLUDE_DIR} )

link_directories(${YAST_PLUGIN_DIR})
Expand Down
13 changes: 1 addition & 12 deletions src/ruby/Y2RubyTypeTerm.cc
Expand Up @@ -85,7 +85,7 @@ ryast_term_initialize( int argc, VALUE *argv, VALUE self )

// we need at least the name to create a YCPTerm
Check_Type( argv[0], T_STRING);
wrapper->term = YCPTerm( RSTRING(argv[0])->ptr );
wrapper->term = YCPTerm( RSTRING_PTR(argv[0]));
// add the remaining YCPTerm arguments
if (argc > 1)
{
Expand Down Expand Up @@ -146,17 +146,6 @@ ryast_term_name(VALUE self)
return rb_str_new2(wrapper->term.name().c_str());
}

// static VALUE
// ryast_term_set_name(VALUE self, VALUE name)
// {
// Check_Type(name, T_STRING);
// ryast_Term_Wrapper *wrapper;
// Data_Get_Struct(self, ryast_Term_Wrapper, wrapper);
//
// wrapper->term->setName(RSTRING(name)->ptr);
// return self;
// }

void
ryast_term_init( VALUE super )
{
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/YCP.cc
Expand Up @@ -630,7 +630,7 @@ yast_y2_logger( int argc, VALUE *argv, VALUE self )
{
Check_Type(argv[i], T_STRING);
}
y2_logger((loglevel_t)NUM2INT(argv[0]),RSTRING(argv[1])->ptr,RSTRING(argv[2])->ptr,NUM2INT(argv[3]),"",RSTRING(argv[5])->ptr);
y2_logger((loglevel_t)NUM2INT(argv[0]),RSTRING_PTR(argv[1]),RSTRING_PTR(argv[2]),NUM2INT(argv[3]),"",RSTRING_PTR(argv[5]));
return Qnil;
}

Expand Down
12 changes: 6 additions & 6 deletions src/ruby/YRubyNamespace.cc
Expand Up @@ -191,17 +191,17 @@ YRubyNamespace::YRubyNamespace (string name)
}

int i;
for(i = 0; i < RARRAY(methods)->len; i++)
for(i = 0; i < RARRAY_LEN(methods); i++)
{
VALUE current = RARRAY(methods)->ptr[i];
y2milestone("New method: '%s'", RSTRING(current)->ptr);
VALUE current = rb_funcall( methods, rb_intern("at"), 1, rb_fix_new(i) );
y2milestone("New method: '%s'", RSTRING_PTR(current));

// figure out arity.
Check_Type(module,T_MODULE);
VALUE methodobj = rb_funcall( module, rb_intern("method"), 1, current );
if ( methodobj == Qnil )
{
y2error ("Cannot access method object '%s'", RSTRING(current)->ptr);
y2error ("Cannot access method object '%s'", RSTRING_PTR(current));
continue;
}
string signature = "any( ";
Expand All @@ -222,13 +222,13 @@ YRubyNamespace::YRubyNamespace (string name)
// symbol entry for the function
SymbolEntry *fun_se = new SymbolEntry ( this,
i,// position. arbitrary numbering. must stay consistent when?
RSTRING(current)->ptr, // passed to Ustring, no need to strdup
RSTRING_PTR(current), // passed to Ustring, no need to strdup
SymbolEntry::c_function,
sym_tp);
fun_se->setGlobal (true);
// enter it to the symbol table
enterSymbol (fun_se, 0);
y2milestone("method: '%s' added", RSTRING(current)->ptr);
y2milestone("method: '%s' added", RSTRING_PTR(current));
}
//add to all modules method last_exception to get last exception raised inside module
constTypePtr sym_tp = Type::fromSignature("any()");
Expand Down

0 comments on commit a57589f

Please sign in to comment.