wasmtime 0.3.0-x64-mingw-ucrt → 0.4.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7462e60ae2338ea16576fc753d1e16de7635f3acf023bc3f435ffca1c498f7f
4
- data.tar.gz: 99df7c74782a0d263b23a14c96c88bc37c0d563f42d50a26dc448f09cbbfc78b
3
+ metadata.gz: 951a4771403f4117b2d10df53a5814b0e8e25c2d2058f3dce0b61ec4a12178c8
4
+ data.tar.gz: a811d2d87de203af3ee8028e195d8acca7620ead96805d5ba62e2c82622ebdbb
5
5
  SHA512:
6
- metadata.gz: 4b19ed52ab402ef99b95e9f60a389429c92921cbbb2d4bbabb2f7049a2a131eeac28fda121ffd3810ae29bc5bb140154880f9be42441d3e2dd7c74b8958f4826
7
- data.tar.gz: 2e451eda2b0841ef9fab8330c4265c65e88663a1267dacb76619ced8e50530c866b364bf07999039aec43b3b0608f2ad124347d4c17726235e423008185e1bac
6
+ metadata.gz: 0f6f8865950ffecbbfa5d6d3d2b0862a182ca8fc1a5c553db68bd9274dc0cb5bda0bc4f078eb903cd151e0151bb5e8e6824475c85fff27b80c6818dd8b855b94
7
+ data.tar.gz: 0af5cb536829504ca0afe926153da576a393cfee957a8fec45bdfbf663424320aeb00f19f379f982499d010ccbdc9e0e067c7ee2b07574f1ff12d36806eeac72
data/README.md CHANGED
@@ -15,22 +15,39 @@
15
15
  </p>
16
16
  </div>
17
17
 
18
- ## Status
18
+ ## Goal
19
19
 
20
- The Wasmtime Ruby bindings are still under development, [some features](https://github.com/bytecodealliance/wasmtime-rb/issues?q=is%3Aissue+is%3Aopen+label%3A%22missing+feature%22) are still missing.
20
+ `wasmtime-rb`'s goal is to expose the full power of Wasmtime in Ruby with
21
+ minimal overhead, serving as a foundation layer for other projects or gems.
21
22
 
22
23
  ## Installation
23
24
 
24
- Install from RubyGems
25
+ Add the `wasmtime` gem to your Gemfile and run `bundle install`:
25
26
 
26
- ```shell
27
+ ```ruby
28
+ gem "wasmtime"
29
+ ```
30
+
31
+ Alternatively, you can install the gem manually:
32
+
33
+ ```sh
27
34
  gem install wasmtime
28
35
  ```
29
36
 
30
- Or use in your Gemfile:
37
+ ### Precompiled gems
31
38
 
32
- ```ruby
33
- gem "wasmtime", "~> 0.3.0"
39
+ We recommend installing the `wasmtime` precompiled gems available for Linux, macOS, and Windows. Installing a precompiled gem avoids the need to compile from source code, which is generally slower and less reliable.
40
+
41
+ When installing the `wasmtime` gem for the first time using `bundle install`, Bundler will automatically download the precompiled gem for your current platform. However, you will need to inform Bundler of any additional platforms you plan to use.
42
+
43
+ To do this, lock your Bundle to the required platforms you will need from the list of supported platforms below:
44
+
45
+ ```sh
46
+ bundle lock --add-platform x86_64-linux # Standard Linux (e.g. Heroku, GitHub Actions, etc.)
47
+ bundle lock --add-platform x86_64-linux-musl # MUSL Linux deployments (i.e. Alpine Linux)
48
+ bundle lock --add-platform aarch64-linux # ARM64 Linux deployments (i.e. AWS Graviton2)
49
+ bundle lock --add-platform x86_64-darwin # Intel MacOS (i.e. pre-M1)
50
+ bundle lock --add-platform arm64-darwin # Apple Silicon MacOS (i.e. M1)
34
51
  ```
35
52
 
36
53
  ## Usage
@@ -41,10 +58,10 @@ Example usage:
41
58
  require "wasmtime"
42
59
 
43
60
  # Create an engine. Generally, you only need a single engine and can
44
- # re-use it a throughout your program
61
+ # re-use it throughout your program.
45
62
  engine = Wasmtime::Engine.new
46
63
 
47
- # Compile a Wasm module from either Wasm or WAT. The compiled module is
64
+ # Compile a Wasm module from either Wasm or WAT. The compiled module is
48
65
  # specific to the Engine's configuration.
49
66
  mod = Wasmtime::Module.new(engine, <<~WAT)
50
67
  (module
@@ -57,19 +74,20 @@ WAT
57
74
  store = Wasmtime::Store.new(engine, {count: 0})
58
75
 
59
76
  # Define a Wasm function from Ruby code.
60
- func = Wasmtime::Func.new(store, Wasmtime::FuncType.new([], [])) do |caller|
77
+ func = Wasmtime::Func.new(store, [], []) do |caller|
61
78
  puts "Hello from Func!"
62
- puts "Ran #{caller[:count]} time(s)"
79
+ caller.store_data[:count] += 1
80
+ puts "Ran #{caller.store_data[:count]} time(s)"
63
81
  end
64
82
 
65
- # Build the Wasm instance by providing its imports
83
+ # Build the Wasm instance by providing its imports.
66
84
  instance = Wasmtime::Instance.new(store, mod, [func])
67
85
 
68
86
  # Run the `run` export.
69
87
  instance.invoke("run")
70
88
 
71
- # Or: get the `run` export and call it
72
- instance.export("run").call
89
+ # Or: get the `run` export and call it.
90
+ instance.export("run").to_func.call
73
91
  ```
74
92
 
75
93
  For more, see [examples](https://github.com/bytecodealliance/wasmtime-rb/tree/main/examples)
data/ext/build.rs ADDED
@@ -0,0 +1,8 @@
1
+ use std::error::Error;
2
+
3
+ // Propogate linking from rb-sys for usage in the wasmtime-rb Rust crate
4
+ fn main() -> Result<(), Box<dyn Error>> {
5
+ let _ = rb_sys_env::activate()?;
6
+
7
+ Ok(())
8
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wasmtime
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/wasmtime.rb CHANGED
@@ -5,18 +5,25 @@ require_relative "wasmtime/version"
5
5
  # Tries to require the extension for the given Ruby version first
6
6
  begin
7
7
  RUBY_VERSION =~ /(\d+\.\d+)/
8
- require "wasmtime/#{Regexp.last_match(1)}/ext"
8
+ require "wasmtime/#{Regexp.last_match(1)}/wasmtime_rb"
9
9
  rescue LoadError
10
- require "wasmtime/ext"
10
+ require "wasmtime/wasmtime_rb"
11
11
  end
12
12
 
13
13
  module Wasmtime
14
14
  class Error < StandardError; end
15
15
 
16
+ # Raised when failing to convert the return value of a Ruby-backed Func to
17
+ # Wasm types.
18
+ class ResultError < Error; end
19
+
20
+ # Raised when converting an {Extern} to its concrete type fails.
16
21
  class ConversionError < Error; end
17
22
 
23
+ # Raised on Wasm trap.
18
24
  class Trap < Error
19
25
  STACK_OVERFLOW = :stack_overflow
26
+ MEMORY_OUT_OF_BOUNDS = :memory_out_of_bounds
20
27
  HEAP_MISALIGNED = :heap_misaligned
21
28
  TABLE_OUT_OF_BOUNDS = :table_out_of_bounds
22
29
  INDIRECT_CALL_TO_NULL = :indirect_call_to_null
@@ -27,6 +34,22 @@ module Wasmtime
27
34
  UNREACHABLE_CODE_REACHED = :unreachable_code_reached
28
35
  INTERRUPT = :interrupt
29
36
  ALWAYS_TRAP_ADAPTER = :always_trap_adapter
37
+ OUT_OF_FUEL = :out_of_fuel
30
38
  UNKNOWN = :unknown
31
39
  end
40
+
41
+ # Raised when a WASI program terminates early by calling +exit+.
42
+ class WasiExit < Error
43
+ # @return [Integer] The system exit code.
44
+ attr_reader(:code)
45
+
46
+ def initialize(code)
47
+ @code = code
48
+ end
49
+
50
+ # @return [String]
51
+ def message
52
+ "WASI exit with code #{code}"
53
+ end
54
+ end
32
55
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wasmtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - The Wasmtime Project Developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-24 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby binding for Wasmtime, a WebAssembly runtime.
14
14
  email:
@@ -19,8 +19,9 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - LICENSE
21
21
  - README.md
22
+ - ext/build.rs
22
23
  - lib/wasmtime.rb
23
- - lib/wasmtime/3.1/ext.so
24
+ - lib/wasmtime/3.1/wasmtime_rb.so
24
25
  - lib/wasmtime/version.rb
25
26
  homepage: https://github.com/BytecodeAlliance/wasmtime-rb
26
27
  licenses:
@@ -31,7 +32,9 @@ metadata:
31
32
  cargo_crate_name: ext
32
33
  changelog_uri: https://github.com/bytecodealliance/wasmtime-rb/blob/main/CHANGELOG.md
33
34
  post_install_message:
34
- rdoc_options: []
35
+ rdoc_options:
36
+ - "--exclude"
37
+ - vendor
35
38
  require_paths:
36
39
  - lib
37
40
  required_ruby_version: !ruby/object:Gem::Requirement