Skip to content

Commit

Permalink
Updated the wasmer CLI to pick up the WasiRunner API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed Jan 16, 2024
1 parent 84b2374 commit 5727d53
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/cli/src/commands/run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,9 @@ impl Run {
) -> Result<WasiRunner, anyhow::Error> {
let packages = self.load_injected_packages(runtime)?;

let mut runner = WasiRunner::new()
let mut runner = WasiRunner::new();

runner
.with_args(&self.args)
.with_injected_packages(packages)
.with_envs(self.wasi.env_vars.clone())
Expand All @@ -371,10 +373,10 @@ impl Run {
#[cfg(feature = "journal")]
{
for trigger in self.wasi.snapshot_on.iter().cloned() {
runner.add_snapshot_trigger(trigger);
runner.with_snapshot_trigger(trigger);
}
if self.wasi.snapshot_on.is_empty() && !self.wasi.journals.is_empty() {
runner.add_default_snapshot_triggers();
runner.with_default_snapshot_triggers();
}
if let Some(period) = self.wasi.snapshot_interval {
if self.wasi.journals.is_empty() {
Expand All @@ -385,7 +387,7 @@ impl Run {
runner.with_snapshot_interval(Duration::from_millis(period));
}
for journal in self.wasi.build_journals()? {
runner.add_journal(journal);
runner.with_journal(journal);
}
}

Expand Down
7 changes: 6 additions & 1 deletion lib/wasix/src/runners/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ impl WasiRunner {
self
}

pub fn mount(&mut self, dest: String, fs: Arc<dyn FileSystem + Send + Sync>) -> &mut Self {
/// Mount a [`FileSystem`] instance at a particular location.
pub fn with_mount(&mut self, dest: String, fs: Arc<dyn FileSystem + Send + Sync>) -> &mut Self {
self.wasi.mounts.push(MountedDirectory { guest: dest, fs });
self
}

/// Override the directory the WASIX instance will start in.
pub fn with_current_dir(&mut self, dir: impl Into<PathBuf>) -> &mut Self {
self.wasi.current_dir = Some(dir.into());
self
Expand Down Expand Up @@ -198,6 +200,9 @@ impl WasiRunner {
self.with_imports([((namespace, name), value)])
}

/// Add multiple import functions.
///
/// This method will accept a [`&Imports`][wasmer::Imports] object.
pub fn with_imports<I, S1, S2, E>(&mut self, imports: I) -> &mut Self
where
I: IntoIterator<Item = ((S1, S2), E)>,
Expand Down

0 comments on commit 5727d53

Please sign in to comment.