ruby: link libruby, fix stuff, it works

develop
jj 2012-03-21 19:30:31 +01:00
parent b2846492f4
commit f46e1ee518
3 changed files with 45 additions and 40 deletions

@ -2,6 +2,8 @@ find_package(Ruby)
if(RUBY_FOUND) if(RUBY_FOUND)
include_directories("${dfhack_SOURCE_DIR}/depends/tthread" ${RUBY_INCLUDE_PATH}) include_directories("${dfhack_SOURCE_DIR}/depends/tthread" ${RUBY_INCLUDE_PATH})
DFHACK_PLUGIN(ruby ruby.cpp LINK_LIBRARIES dfhack-tinythread) DFHACK_PLUGIN(ruby ruby.cpp LINK_LIBRARIES dfhack-tinythread)
target_link_libraries(ruby ${RUBY_LIBRARY})
install(FILES ruby.rb DESTINATION ${DFHACK_LIBRARY_DESTINATION})
else(RUBY_FOUND) else(RUBY_FOUND)
MESSAGE(STATUS "Required library (ruby) not found - ruby plugin can't be built.") MESSAGE(STATUS "Required library (ruby) not found - ruby plugin can't be built.")
endif(RUBY_FOUND) endif(RUBY_FOUND)

@ -44,6 +44,7 @@ DFHACK_PLUGIN("ruby")
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands) DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
{ {
out.print("plugin_init\n");
m_irun = new tthread::mutex(); m_irun = new tthread::mutex();
m_mutex = new tthread::mutex(); m_mutex = new tthread::mutex();
r_type = RB_INIT; r_type = RB_INIT;
@ -72,6 +73,7 @@ DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <Plug
"Ruby interpreter dev. Eval() a ruby string.", "Ruby interpreter dev. Eval() a ruby string.",
df_rubyeval)); df_rubyeval));
out.print("plugin_init done\n");
return CR_OK; return CR_OK;
} }
@ -521,6 +523,7 @@ static void ruby_bind_world(void) {
rb_c_world_T_units = rb_define_class_under(rb_c_world, "T_units", rb_c_WrapData); rb_c_world_T_units = rb_define_class_under(rb_c_world, "T_units", rb_c_WrapData);
rb_define_method(rb_c_world, "units", RUBY_METHOD_FUNC(rb_m_world_units), 0); rb_define_method(rb_c_world, "units", RUBY_METHOD_FUNC(rb_m_world_units), 0);
rb_define_method(rb_c_world_T_units, "all", RUBY_METHOD_FUNC(rb_m_world_T_units_all), 0);
} }
static VALUE rb_global_world(VALUE self) { static VALUE rb_global_world(VALUE self) {
@ -603,7 +606,7 @@ static void ruby_bind_dfhack(void) {
// load the default ruby-level definitions // load the default ruby-level definitions
int state=0; int state=0;
rb_load_protect(rb_str_new2("./hack/plugins/ruby.rb"), Qfalse, &state); rb_load_protect(rb_str_new2("./hack/ruby.rb"), Qfalse, &state);
if (state) if (state)
dump_rb_error(); dump_rb_error();
} }

@ -1,4 +1,5 @@
module DFHack module DFHack
class << self
def suspend def suspend
if block_given? if block_given?
begin begin
@ -37,7 +38,6 @@ module DFHack
puts "done" puts "done"
end end
end end
end end
# load user-specified startup file # load user-specified startup file