wasmtime 0.3.0-x64-mingw32 → 0.4.0-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7da44cfffd95306a044885024790f8e72f8d8311fb7d1ac2fa20769da4039664
4
- data.tar.gz: '009295a87373108f51068985cc4e1729af1937653385107a2ecf3bea45df953b'
3
+ metadata.gz: 42f22c3364bc4f6444f2f1f64d100c477528f84e169a76d7853eddae94626319
4
+ data.tar.gz: d32ff46a0deea6f4ece93eee203f44225153f146d41c04adfdb956fed0773041
5
5
  SHA512:
6
- metadata.gz: 34b7f8d1b983543f82804590b1c1c966a1cde6ef9c1bdb3d67284596f73dc77d130dae5fe5c8ed21929f5fe72dbd08c469a18699718bfccfde8217710cd882d5
7
- data.tar.gz: ddeb4b62bda0ead2cb2654eabd1464f973e59d4134808ca6cb5f146e40a3c93972550a87bafcfed48d0123276c97f26b2792d680ffea134f3991bcd50bea6c4e
6
+ metadata.gz: 3eefdb7e8902e74cdf19918a24d14d26a07bfd703db7eb424e269e11b6aa35015f9928e46018b5acd471506f551fb462e0ad1bbfb729c745eb2288fb6e2bf2b0
7
+ data.tar.gz: 72de3e3f3cc4f0579f3a4946df1ffb5a1c88c2e9ac33b399ec4626b99bdeaae649135398c32a46f125f147ea3432be68b9aee1b1b7b2d2fe1099778dfd458af2
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-mingw32
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,9 +19,10 @@ 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/2.7/ext.so
24
- - lib/wasmtime/3.0/ext.so
24
+ - lib/wasmtime/2.7/wasmtime_rb.so
25
+ - lib/wasmtime/3.0/wasmtime_rb.so
25
26
  - lib/wasmtime/version.rb
26
27
  homepage: https://github.com/BytecodeAlliance/wasmtime-rb
27
28
  licenses:
@@ -32,7 +33,9 @@ metadata:
32
33
  cargo_crate_name: ext
33
34
  changelog_uri: https://github.com/bytecodealliance/wasmtime-rb/blob/main/CHANGELOG.md
34
35
  post_install_message:
35
- rdoc_options: []
36
+ rdoc_options:
37
+ - "--exclude"
38
+ - vendor
36
39
  require_paths:
37
40
  - lib
38
41
  required_ruby_version: !ruby/object:Gem::Requirement