Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,458 changes: 1,627 additions & 831 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builders/wasm32-unknown-emscripten/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENV PATH=/usr/bin:$PATH
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.79.0
RUST_VERSION=1.89.0

RUN set -eux pipefail; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
Expand Down
2 changes: 1 addition & 1 deletion builders/wasm32-unknown-wasip2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN set -eux pipefail; \
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.79.0
RUST_VERSION=1.89.0

RUN set -eux pipefail; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
Expand Down
3 changes: 1 addition & 2 deletions ext/ruby_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ crate-type = ["cdylib"]
[dependencies]
magnus = { version = "0.8", features = ["bytes"] }
bytes = "1"
wizer = "6.0.0"
wasi-vfs-cli = { git = "https://github.com/kateinoigakukun/wasi-vfs/", tag = "v0.5.3-p1" }
structopt = "0.3.26"
wit-component = "0.216.0"
wasm-compose = "0.219.1"
wasi-virt = { git = "https://github.com/bytecodealliance/wasi-virt", rev = "dadd131d8cf8ed1ed4265e96350f5f166e27a339", default-features = false }
wasi-vfs-cli = { git = "https://github.com/kateinoigakukun/wasi-vfs/", tag = "v0.6.2" }
26 changes: 3 additions & 23 deletions ext/ruby_wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
use std::{collections::HashMap, env, path::PathBuf, time::SystemTime};

use magnus::{
eval, function, method,
function, method,
prelude::*,
value::{self, InnerValue},
wrap, Error, ExceptionClass, RModule, Ruby,
wrap, Error, RModule, Ruby,
};
use structopt::StructOpt;
use wizer::Wizer;
use wasi_virt;

static RUBY_WASM: value::Lazy<RModule> =
value::Lazy::new(|ruby| ruby.define_module("RubyWasmExt").unwrap());

fn preinit(core_module: bytes::Bytes) -> Result<bytes::Bytes, Error> {
let rbwasm_error = eval("RubyWasmExt::Error")?;
let rbwasm_error = ExceptionClass::from_value(rbwasm_error).unwrap();
let mut wizer = Wizer::new();
wizer
.wasm_bulk_memory(true)
.inherit_stdio(true)
.inherit_env(true)
.allow_wasi(true)
.map_err(|e| Error::new(rbwasm_error, format!("failed to create wizer: {}", e)))?;

wizer
.run(&core_module)
.map_err(|e| Error::new(rbwasm_error, format!("failed to run wizer: {}", e)))
.map(|output| output.into())
}

struct WasiVfsInner {
map_dirs: Vec<(PathBuf, PathBuf)>,
map_dirs: Vec<(String, PathBuf)>,
}

#[wrap(class = "RubyWasmExt::WasiVfs")]
Expand Down Expand Up @@ -284,8 +266,6 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
let module = RUBY_WASM.get_inner_with(ruby);
module.define_error("Error", ruby.exception_standard_error())?;

module.define_singleton_method("preinitialize", function!(preinit, 1))?;

let wasi_vfs = module.define_class("WasiVfs", ruby.class_object())?;
wasi_vfs.define_singleton_method("new", function!(WasiVfs::new, 0))?;
wasi_vfs.define_singleton_method("run_cli", function!(WasiVfs::run_cli, 1))?;
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_wasm/build/product/wasi_vfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module RubyWasm
class WasiVfsProduct < BuildProduct
WASI_VFS_VERSION = "0.5.0"
WASI_VFS_VERSION = "0.6.2"

def initialize(build_dir)
@build_dir = build_dir
Expand Down
5 changes: 0 additions & 5 deletions lib/ruby_wasm/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def build(args)
# @type var options: cli_options
options = {
save_temps: false,
optimize: false,
remake: false,
reconfigure: false,
clean: false,
Expand Down Expand Up @@ -84,10 +83,6 @@ def build(args)
"Build profile. full or minimal"
) { |profile| options[:profile] = profile }

opts.on("--optimize", "Optimize the output") do
options[:optimize] = true
end

opts.on("--remake", "Re-execute make for Ruby") do
options[:remake] = true
end
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_wasm/packager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def package(executor, dest_dir, options)
wasm_bytes = wasi_virt.compose(wasm_bytes)
end

wasm_bytes = RubyWasmExt.preinitialize(wasm_bytes) if options[:optimize]
wasm_bytes
end

Expand Down
1 change: 0 additions & 1 deletion sig/ruby_wasm/cli.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module RubyWasm
save_temps: bool,
output: String,

optimize: bool,
remake: bool,
reconfigure: bool,
clean: bool,
Expand Down
2 changes: 0 additions & 2 deletions sig/ruby_wasm/ext.rbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module RubyWasmExt
type bytes = String

def self.preinitialize: (bytes module_bytes) -> bytes

class WasiVfs
def initialize: () -> void

Expand Down
Loading