Rename init fn to be able to require binary
directly
This commit is contained in:
parent
41cacb3c78
commit
916d647a24
4 changed files with 7 additions and 31 deletions
|
@ -5,9 +5,9 @@ module RubyImag
|
|||
IMAG_INIT_FN_NAME = 'imag_ruby_initialize'
|
||||
|
||||
def self.setup binary_path
|
||||
require 'fiddle'
|
||||
require binary_path
|
||||
|
||||
self.core_setup binary_path
|
||||
self.core_setup
|
||||
self.classes_setup
|
||||
end
|
||||
|
||||
|
@ -55,10 +55,7 @@ module RubyImag
|
|||
]
|
||||
end
|
||||
|
||||
def self.core_setup binary
|
||||
lib = Fiddle::dlopen binary
|
||||
Fiddle::Function::new(lib[RubyImag::IMAG_INIT_FN_NAME], [], Fiddle::TYPE_VOIDP).call
|
||||
|
||||
def self.core_setup
|
||||
self.class_names.map {|n| [n, "R#{n}".to_sym ] }.each do |elem|
|
||||
RubyImag.const_set elem.first, Kernel.const_get(elem.last)
|
||||
end
|
||||
|
|
|
@ -41,7 +41,8 @@ pub mod storeid;
|
|||
pub mod toml_utils;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern fn imag_ruby_initialize() {
|
||||
#[allow(non_snake_case)]
|
||||
pub extern fn Init_liblibimagruby() {
|
||||
self::store::setup();
|
||||
self::storeid::setup();
|
||||
self::entry::setup_filelockentry();
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'fiddle'
|
||||
|
||||
INIT_FN = 'imag_ruby_initialize'
|
||||
|
||||
for targ in %w(debug release)
|
||||
begin
|
||||
lib = Fiddle::dlopen "../target/#{targ}/liblibimagruby.so"
|
||||
Fiddle::Function::new(lib[INIT_FN], [], Fiddle::TYPE_VOIDP).call
|
||||
break;
|
||||
rescue Fiddle::DLError
|
||||
end
|
||||
end
|
||||
require "../target/debug/liblibimagruby.so"
|
||||
|
||||
color = true
|
||||
verbose = true
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'fiddle'
|
||||
|
||||
INIT_FN = 'imag_ruby_initialize'
|
||||
|
||||
for targ in %w(debug)
|
||||
begin
|
||||
lib = Fiddle::dlopen "../target/#{targ}/liblibimagruby.so"
|
||||
Fiddle::Function::new(lib[INIT_FN], [], Fiddle::TYPE_VOIDP).call
|
||||
break;
|
||||
rescue Fiddle::DLError
|
||||
end
|
||||
end
|
||||
require "../target/debug/liblibimagruby.so"
|
||||
|
||||
color = true
|
||||
verbose = true
|
||||
|
|
Loading…
Reference in a new issue