mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-06 20:58:28 +00:00
Correctly recognize .wai bindings
This commit is contained in:
@@ -65,6 +65,24 @@ struct MiniCargoTomlPackage {
|
|||||||
impl Init {
|
impl Init {
|
||||||
/// `wasmer init` execution
|
/// `wasmer init` execution
|
||||||
pub fn execute(&self) -> Result<(), anyhow::Error> {
|
pub fn execute(&self) -> Result<(), anyhow::Error> {
|
||||||
|
|
||||||
|
let bin_or_lib = match (self.empty, self.bin, self.lib) {
|
||||||
|
(true, true, _) | (true, _, true) => {
|
||||||
|
return Err(anyhow::anyhow!(
|
||||||
|
"cannot combine --empty with --bin or --lib"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
(true, false, false) => BinOrLib::Empty,
|
||||||
|
(_, true, true) => {
|
||||||
|
return Err(anyhow::anyhow!(
|
||||||
|
"cannot initialize a wapm manifest with both --bin and --lib, pick one"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
(false, true, _) => BinOrLib::Bin,
|
||||||
|
(false, _, true) => BinOrLib::Lib,
|
||||||
|
_ => BinOrLib::Bin,
|
||||||
|
};
|
||||||
|
|
||||||
let target_file = match self.out.as_ref() {
|
let target_file = match self.out.as_ref() {
|
||||||
None => std::env::current_dir()?.join("wapm.toml"),
|
None => std::env::current_dir()?.join("wapm.toml"),
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
@@ -146,23 +164,6 @@ impl Init {
|
|||||||
.and_then(|t| t.description.clone())
|
.and_then(|t| t.description.clone())
|
||||||
.unwrap_or(format!("Description for package {module_name}"));
|
.unwrap_or(format!("Description for package {module_name}"));
|
||||||
|
|
||||||
let bin_or_lib = match (self.empty, self.bin, self.lib) {
|
|
||||||
(true, true, _) | (true, _, true) => {
|
|
||||||
return Err(anyhow::anyhow!(
|
|
||||||
"cannot combine --empty with --bin or --lib"
|
|
||||||
))
|
|
||||||
}
|
|
||||||
(true, false, false) => BinOrLib::Empty,
|
|
||||||
(_, true, true) => {
|
|
||||||
return Err(anyhow::anyhow!(
|
|
||||||
"cannot initialize a wapm manifest with both --bin and --lib, pick one"
|
|
||||||
))
|
|
||||||
}
|
|
||||||
(false, true, _) => BinOrLib::Bin,
|
|
||||||
(false, _, true) => BinOrLib::Lib,
|
|
||||||
_ => BinOrLib::Bin,
|
|
||||||
};
|
|
||||||
|
|
||||||
let modules = vec![wapm_toml::Module {
|
let modules = vec![wapm_toml::Module {
|
||||||
name: module_name.to_string(),
|
name: module_name.to_string(),
|
||||||
source: cargo_toml
|
source: cargo_toml
|
||||||
@@ -195,9 +196,10 @@ impl Init {
|
|||||||
wit_bindgen: semver::Version::parse("0.1.0").unwrap(),
|
wit_bindgen: semver::Version::parse("0.1.0").unwrap(),
|
||||||
}))
|
}))
|
||||||
} else if is_wai {
|
} else if is_wai {
|
||||||
Some(wapm_toml::Bindings::Wit(wapm_toml::WitBindings {
|
Some(wapm_toml::Bindings::Wai(wapm_toml::WaiBindings {
|
||||||
wit_exports: e.path().to_path_buf(),
|
exports: None,
|
||||||
wit_bindgen: semver::Version::parse("0.1.0").unwrap(),
|
imports: vec![e.path().to_path_buf()],
|
||||||
|
wai_version: semver::Version::parse("0.1.0").unwrap(),
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in New Issue
Block a user