Browse Source

tokio example requires enabling a cargo feature

and also a dummy C example
pull/2832/head
Pat Hickey 4 years ago
parent
commit
2ddf4c1da9
  1. 23
      crates/misc/run-examples/src/main.rs
  2. 1
      examples/tokio/CARGO_FEATURES
  3. 5
      examples/tokio/main.c

23
crates/misc/run-examples/src/main.rs

@ -13,7 +13,11 @@ fn main() -> anyhow::Result<()> {
continue;
}
examples.insert((path.file_stem().unwrap().to_str().unwrap().to_owned(), dir));
examples.insert((
path.clone(),
path.file_stem().unwrap().to_str().unwrap().to_owned(),
dir,
));
}
println!("======== Building libwasmtime.a ===========");
@ -21,7 +25,7 @@ fn main() -> anyhow::Result<()> {
.args(&["build"])
.current_dir("crates/c-api"))?;
for (example, is_dir) in examples {
for (example_path, example, is_dir) in examples {
if example == "README" {
continue;
}
@ -45,10 +49,17 @@ fn main() -> anyhow::Result<()> {
.arg(target))?;
}
println!("======== Rust example `{}` ============", example);
run(Command::new("cargo")
.arg("run")
.arg("--example")
.arg(&example))?;
let mut cargo_cmd = Command::new("cargo");
cargo_cmd.arg("run").arg("--example").arg(&example);
if is_dir {
let mut features_path = std::path::PathBuf::from(example_path);
features_path.push("CARGO_FEATURES");
if features_path.exists() {
let features = std::fs::read_to_string(features_path)?;
cargo_cmd.arg("--features").arg(features);
}
}
run(&mut cargo_cmd)?;
println!("======== C/C++ example `{}` ============", example);
for extension in ["c", "cc"].iter() {

1
examples/tokio/CARGO_FEATURES

@ -0,0 +1 @@
wasmtime-wasi/tokio

5
examples/tokio/main.c

@ -0,0 +1,5 @@
int main(int argc, char *argv[]) {
// This example is specific to integrating with Rust's tokio ecosystem, so
// it isnt applicable to C/C++.
return 0;
}
Loading…
Cancel
Save