wasmtime 0.3.0-x64-mingw-ucrt → 0.4.0-x64-mingw-ucrt
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 +4 -4
- data/README.md +32 -14
- data/ext/build.rs +8 -0
- data/lib/wasmtime/3.1/{ext.so → wasmtime_rb.so} +0 -0
- data/lib/wasmtime/version.rb +1 -1
- data/lib/wasmtime.rb +25 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951a4771403f4117b2d10df53a5814b0e8e25c2d2058f3dce0b61ec4a12178c8
|
4
|
+
data.tar.gz: a811d2d87de203af3ee8028e195d8acca7620ead96805d5ba62e2c82622ebdbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
##
|
18
|
+
## Goal
|
19
19
|
|
20
|
-
|
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
|
-
|
25
|
+
Add the `wasmtime` gem to your Gemfile and run `bundle install`:
|
25
26
|
|
26
|
-
```
|
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
|
-
|
37
|
+
### Precompiled gems
|
31
38
|
|
32
|
-
|
33
|
-
|
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
|
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.
|
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,
|
77
|
+
func = Wasmtime::Func.new(store, [], []) do |caller|
|
61
78
|
puts "Hello from Func!"
|
62
|
-
|
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
Binary file
|
data/lib/wasmtime/version.rb
CHANGED
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)}/
|
8
|
+
require "wasmtime/#{Regexp.last_match(1)}/wasmtime_rb"
|
9
9
|
rescue LoadError
|
10
|
-
require "wasmtime/
|
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.
|
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
|
+
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/
|
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
|