wasmtime 0.3.0-aarch64-linux → 0.4.0-aarch64-linux

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: 36dab3eda1742ecde52a18315fd90fd087c6de231eed0809fd7439ef15e58cb7
4
- data.tar.gz: 0770aaa3ad56a5986bfc5313d007a0075adcacc92c2d194bf6f9b92408fef25f
3
+ metadata.gz: 78fb03fd3257d473f84b06d949a4e2bdbd48cfde021158c63e561746c97fa355
4
+ data.tar.gz: b2a08b348616e5c7701e8234f694daaab0b3a602bf0237b6b17057835557357c
5
5
  SHA512:
6
- metadata.gz: d9983a9cbb73b2ee7e090fe81e30a8a1ded602ba5e61debffd68c94c87ec857e3cb3bb37ce16c5e344c8c9c940fa230eebc4b3569978fc870e98bae819214bb2
7
- data.tar.gz: 3fb4f406e88e7b32eb6c9081cee9b62abef8b6166da66ef651b51771d725d33ef2d89718dc29701d88adcf36339abf0836e01087cd881cb9a55c74ee3f8f4075
6
+ metadata.gz: 34fb2f6f8372111ca9e55463207aeb58ba81c96dc8b343456971038b79d360378beb88709a4f7f1f1f03293929a8ae313460b60eb7fd86612322595f7961b054
7
+ data.tar.gz: 823f638fd34f881a12c6fe9535908a60dc78685db8aa8eeb8eb31544281bdfc6d6103d5bea2625ee678581909a722a850bde0be4da8a18ed14fc0dfaf58c8652
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
+ }
Binary file
Binary file
Binary file
@@ -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: aarch64-linux
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,10 +19,11 @@ 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
25
- - lib/wasmtime/3.1/ext.so
24
+ - lib/wasmtime/2.7/wasmtime_rb.so
25
+ - lib/wasmtime/3.0/wasmtime_rb.so
26
+ - lib/wasmtime/3.1/wasmtime_rb.so
26
27
  - lib/wasmtime/version.rb
27
28
  homepage: https://github.com/BytecodeAlliance/wasmtime-rb
28
29
  licenses:
@@ -33,7 +34,9 @@ metadata:
33
34
  cargo_crate_name: ext
34
35
  changelog_uri: https://github.com/bytecodealliance/wasmtime-rb/blob/main/CHANGELOG.md
35
36
  post_install_message:
36
- rdoc_options: []
37
+ rdoc_options:
38
+ - "--exclude"
39
+ - vendor
37
40
  require_paths:
38
41
  - lib
39
42
  required_ruby_version: !ruby/object:Gem::Requirement
Binary file
Binary file
Binary file