Skip to content

Commit 3347d28

Browse files
committed
feat: allow wit-path flag to receive .wasm files
Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
1 parent 6776c98 commit 3347d28

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

src/command.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ pub struct Common {
1919
/// The location of the WIT document(s).
2020
///
2121
/// This may be specified more than once, for example:
22-
/// `-d ./wit/deps -d ./wit/app`
22+
/// `-d ./wit/deps -d ./wit/app`.
23+
///
24+
/// These paths can be either directories containing `*.wit` files, `*.wit`
25+
/// files themselves, or `*.wasm` files which are wasm-encoded WIT packages.
2326
#[arg(long, short = 'd')]
2427
pub wit_path: Vec<PathBuf>,
2528

src/componentize.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
path::{Path, PathBuf},
44
process::Command,
55
};
6-
use wit_parser::{Resolve, UnresolvedPackageGroup, WorldId};
6+
use wit_parser::{PackageId, Resolve, WorldId};
77

88
/// Ensure that the Go version is compatible with the embedded Wasm tooling.
99
fn check_go_version(go_path: &PathBuf) -> Result<()> {
@@ -191,19 +191,12 @@ fn parse_wit(
191191
}
192192
}
193193

194-
let mut last_pkg = None;
194+
let mut main_packages: Vec<PackageId> = vec![];
195195
for path in paths.iter().map(AsRef::as_ref) {
196-
let pkg = if path.is_dir() {
197-
resolve.push_dir(path)?.0
198-
} else {
199-
let pkg = UnresolvedPackageGroup::parse_file(path)?;
200-
resolve.push_group(pkg)?
201-
};
202-
last_pkg = Some(pkg);
196+
let (pkg, _files) = resolve.push_path(path)?;
197+
main_packages.push(pkg);
203198
}
204199

205-
let pkg = last_pkg.unwrap(); // The paths should not be empty
206-
let world = resolve.select_world(&[pkg], world)?;
207-
200+
let world = resolve.select_world(&main_packages, world)?;
208201
Ok((resolve, world))
209202
}

0 commit comments

Comments
 (0)