Skip to content

Commit b036a50

Browse files
authored
Merge pull request #52 from Hywan/feat-remove-rutie-rb
feat: Remove Ruby dependency to `rutie`
2 parents 408e41a + d05d4cc commit b036a50

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

Rakefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require "rbconfig"
21
require "bundler/gem_tasks"
32
require "rake/testtask"
43

crates/rutie-test/src/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,7 @@ root = File.expand_path("../..", ENV["CARGO_MANIFEST_DIR"])
99
1010
Dir.chdir(root)
1111
12-
class RbConfig
13-
CONFIG = {{
14-
"host_os" => ENV["TARGET"]
15-
}}
16-
end
17-
1812
$LOAD_PATH.unshift(File.expand_path("lib", root))
19-
$LOAD_PATH.unshift(File.expand_path("vendor/bundle/rutie/lib", root))
2013
2114
require "wasmer"
2215

crates/wasmer/build.rs

-7
This file was deleted.

lib/wasmer.rb

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
1-
require "rutie"
1+
require "fiddle"
22

33
module Wasmer
4-
Rutie.new(:wasmer_ruby).init "init", __dir__
4+
shared_library_name = :wasmer_ruby
5+
init_function = :init
6+
7+
shared_library_prefix =
8+
case RUBY_PLATFORM
9+
when /windows|mswin|mingw/ then ""
10+
when /cygwin/ then "cyg"
11+
else "lib"
12+
end
13+
14+
shared_library_suffix =
15+
case RUBY_PLATFORM
16+
when /darwin/ then "dylib"
17+
when /windows|mswin|mingw|cygwin/ then "dll"
18+
else "so"
19+
end
20+
21+
shared_library_directory = File.expand_path "../target/release/", __dir__
22+
shared_library_path = File.join(
23+
shared_library_directory,
24+
[shared_library_prefix, shared_library_name, ".", shared_library_suffix].join()
25+
)
26+
27+
Fiddle::Function.new(
28+
Fiddle::dlopen(shared_library_path)[init_function.to_s],
29+
[],
30+
Fiddle::TYPE_VOIDP
31+
).call
532
end

wasmer.gemspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ Gem::Specification.new do |spec|
1515
spec.extensions = %w(Rakefile)
1616

1717
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(examples|tests)/}) }
18+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(examples|tests|doc)/}) }
1919
end
2020

2121
spec.require_paths = %w(lib)
2222

23-
spec.add_dependency "rutie", "~> 0.0.4"
2423
spec.add_development_dependency "bundler", "~> 2.1"
2524
spec.add_development_dependency "rake", "~> 13.0"
2625
end

0 commit comments

Comments
 (0)