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'
|
IMAG_INIT_FN_NAME = 'imag_ruby_initialize'
|
||||||
|
|
||||||
def self.setup binary_path
|
def self.setup binary_path
|
||||||
require 'fiddle'
|
require binary_path
|
||||||
|
|
||||||
self.core_setup binary_path
|
self.core_setup
|
||||||
self.classes_setup
|
self.classes_setup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,10 +55,7 @@ module RubyImag
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.core_setup binary
|
def self.core_setup
|
||||||
lib = Fiddle::dlopen binary
|
|
||||||
Fiddle::Function::new(lib[RubyImag::IMAG_INIT_FN_NAME], [], Fiddle::TYPE_VOIDP).call
|
|
||||||
|
|
||||||
self.class_names.map {|n| [n, "R#{n}".to_sym ] }.each do |elem|
|
self.class_names.map {|n| [n, "R#{n}".to_sym ] }.each do |elem|
|
||||||
RubyImag.const_set elem.first, Kernel.const_get(elem.last)
|
RubyImag.const_set elem.first, Kernel.const_get(elem.last)
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,7 +41,8 @@ pub mod storeid;
|
||||||
pub mod toml_utils;
|
pub mod toml_utils;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn imag_ruby_initialize() {
|
#[allow(non_snake_case)]
|
||||||
|
pub extern fn Init_liblibimagruby() {
|
||||||
self::store::setup();
|
self::store::setup();
|
||||||
self::storeid::setup();
|
self::storeid::setup();
|
||||||
self::entry::setup_filelockentry();
|
self::entry::setup_filelockentry();
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'fiddle'
|
require "../target/debug/liblibimagruby.so"
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
color = true
|
color = true
|
||||||
verbose = true
|
verbose = true
|
||||||
|
|
|
@ -1,17 +1,6 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'fiddle'
|
require "../target/debug/liblibimagruby.so"
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
color = true
|
color = true
|
||||||
verbose = true
|
verbose = true
|
||||||
|
|
Loading…
Reference in a new issue