From a5f8d57d5f882cf6f24e7d7b36fc85461c9b8755 Mon Sep 17 00:00:00 2001 From: Uchio Kondo Date: Sun, 27 Oct 2024 13:38:19 +0900 Subject: [PATCH] Update some readme --- README.md | 36 ++++++++++++++++++++++++++++++------ exe/wardite | 3 ++- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f1e0ed8..767fb76 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,40 @@ A pure-ruby webassembly runtime. ## Installation -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. - Install the gem and add to the application's Gemfile by executing: - $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG + $ bundle add wardite If bundler is not being used to manage dependencies, install the gem by executing: - $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG + $ gem install wardite ## Usage -TODO: Write usage instructions here +- In your ruby code, instanciate Wardite runtime: + +```ruby +require "wardite" + +path = ARGV[0] +method = ARGV[1] +args = ARGV[2..-1] || [] + +f = File.open(path) +instance = Wardite::BinaryLoader::load_from_buffer(f); +if !method && instance.runtime.respond_to?(:_start) + instance.runtime._start +else + instance.runtime.call(method, args) +end +``` + +- Wardite bundles `wardite` cli command: + +```console +$ wardite examples/test.wasm +#=> Test! +``` ## Development @@ -32,4 +53,7 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/udzura - https://github.com/technohippy/wasmrb?tab=readme-ov-file - Referencial implementation but no support with WASI - - Wardite aims to support full WASI (previwe 1) \ No newline at end of file + - Wardite aims to support full WASI (previwe 1) +- https://github.com/skanehira/chibiwasm + - Small and consise implementation in Rust + - Wardite was first built upon [its development tutorial](https://skanehira.github.io/writing-a-wasm-runtime-in-rust/). Thanks! \ No newline at end of file diff --git a/exe/wardite b/exe/wardite index 70e084d..25e7a45 100755 --- a/exe/wardite +++ b/exe/wardite @@ -11,5 +11,6 @@ instance = Wardite::BinaryLoader::load_from_buffer(f); if !method && instance.runtime.respond_to?(:_start) instance.runtime._start else - instance.runtime.call(method, args) + ret = instance.runtime.call(method, args) + $stderr.puts "return value: #{ret.inspect}" end \ No newline at end of file