Merge remote-tracking branch 'jjyg/develop'

develop
expwnent 2014-09-19 17:09:43 -04:00
commit b0b6a82c92
4 changed files with 28 additions and 18 deletions

@ -1,21 +1,25 @@
OPTION(DL_RUBY "download libruby from the internet" ON) OPTION(DL_RUBY "download libruby from the internet" OFF)
IF (DL_RUBY AND NOT APPLE) IF (NOT APPLE)
IF (UNIX) IF (UNIX)
FILE(DOWNLOAD http://cloud.github.com/downloads/jjyg/dfhack/libruby187.tar.gz ${CMAKE_CURRENT_BINARY_DIR}/libruby187.tar.gz IF (DL_RUBY)
EXPECTED_MD5 eb2adea59911f68e6066966c1352f291) FILE(DOWNLOAD http://cloud.github.com/downloads/jjyg/dfhack/libruby187.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/libruby187.tar.gz
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E tar xzf libruby187.tar.gz EXPECTED_MD5 eb2adea59911f68e6066966c1352f291)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(DL_RUBY)
FILE(RENAME ${CMAKE_CURRENT_BINARY_DIR}/libruby1.8.so.1.8.7 ${CMAKE_CURRENT_BINARY_DIR}/libruby.so) EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/libruby187.tar.gz
SET(RUBYLIB ${CMAKE_CURRENT_BINARY_DIR}/libruby.so) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
ELSE (UNIX) FILE(RENAME ${CMAKE_CURRENT_BINARY_DIR}/libruby1.8.so.1.8.7 ${CMAKE_CURRENT_BINARY_DIR}/libruby.so)
FILE(DOWNLOAD http://cloud.github.com/downloads/jjyg/dfhack/msvcrtruby187.tar.gz ${CMAKE_CURRENT_BINARY_DIR}/msvcrtruby187.tar.gz SET(RUBYLIB ${CMAKE_CURRENT_BINARY_DIR}/libruby.so)
EXPECTED_MD5 9f4a1659ac3a5308f32d3a1937bbeeae) ELSE (UNIX)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E tar xzf msvcrtruby187.tar.gz IF (DL_RUBY)
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) FILE(DOWNLOAD http://cloud.github.com/downloads/jjyg/dfhack/msvcrtruby187.tar.gz ${CMAKE_CURRENT_SOURCE_DIR}/msvcrtruby187.tar.gz
FILE(RENAME ${CMAKE_CURRENT_BINARY_DIR}/msvcrt-ruby18.dll ${CMAKE_CURRENT_BINARY_DIR}/libruby.dll) EXPECTED_MD5 9f4a1659ac3a5308f32d3a1937bbeeae)
SET(RUBYLIB ${CMAKE_CURRENT_BINARY_DIR}/libruby.dll) ENDIF(DL_RUBY)
ENDIF(UNIX) EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_CURRENT_SOURCE_DIR}/msvcrtruby187.tar.gz
ENDIF(DL_RUBY AND NOT APPLE) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
FILE(RENAME ${CMAKE_CURRENT_BINARY_DIR}/msvcrt-ruby18.dll ${CMAKE_CURRENT_BINARY_DIR}/libruby.dll)
SET(RUBYLIB ${CMAKE_CURRENT_BINARY_DIR}/libruby.dll)
ENDIF(UNIX)
ENDIF(NOT APPLE)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ruby-autogen.rb OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ruby-autogen.rb

Binary file not shown.

Binary file not shown.

@ -293,6 +293,7 @@ typedef unsigned long ID;
#define FIX2INT(i) (((long)i) >> 1) #define FIX2INT(i) (((long)i) >> 1)
#define RUBY_METHOD_FUNC(func) ((VALUE(*)(...))func) #define RUBY_METHOD_FUNC(func) ((VALUE(*)(...))func)
void (*ruby_init_stack)(VALUE*);
void (*ruby_sysinit)(int *, const char ***); void (*ruby_sysinit)(int *, const char ***);
void (*ruby_init)(void); void (*ruby_init)(void);
void (*ruby_init_loadpath)(void); void (*ruby_init_loadpath)(void);
@ -337,6 +338,7 @@ static int df_loadruby(void)
// ruby_sysinit is optional (ruby1.9 only) // ruby_sysinit is optional (ruby1.9 only)
ruby_sysinit = (decltype(ruby_sysinit))LookupPlugin(libruby_handle, "ruby_sysinit"); ruby_sysinit = (decltype(ruby_sysinit))LookupPlugin(libruby_handle, "ruby_sysinit");
#define rbloadsym(s) if (!(s = (decltype(s))LookupPlugin(libruby_handle, #s))) return 0 #define rbloadsym(s) if (!(s = (decltype(s))LookupPlugin(libruby_handle, #s))) return 0
rbloadsym(ruby_init_stack);
rbloadsym(ruby_init); rbloadsym(ruby_init);
rbloadsym(ruby_init_loadpath); rbloadsym(ruby_init_loadpath);
rbloadsym(ruby_script); rbloadsym(ruby_script);
@ -401,6 +403,10 @@ static void df_rubythread(void *p)
{ {
int state, running; int state, running;
// may need to be run from df main thread?
VALUE foo;
ruby_init_stack(&foo);
if (ruby_sysinit) { if (ruby_sysinit) {
// ruby1.9 specific API // ruby1.9 specific API
static int argc; static int argc;