Run cc tests if any are found in the examples folder
@@ -51,7 +51,7 @@ fn main() {
.arg("--example")
.arg(&example));
- println!("======== C example `{}` ============", example);
+ println!("======== C/C++ example `{}` ============", example);
let mut cmd = cc::Build::new()
.opt_level(0)
.cargo_metadata(false)
@@ -63,11 +63,20 @@ fn main() {
.warnings(false)
.get_compiler()
.to_command();
- if is_dir {
- cmd.arg(format!("examples/{}/main.c", example));
+
+ for extension in ["c", "cc"].iter() {
+ let file = if is_dir {
+ format!("examples/{}/main.{}", example, extension)
} else {
- cmd.arg(format!("examples/{}.c", example));
+ format!("examples/{}.{}", example, extension)
+ };
+
+ if extension == &"cc" && !std::path::Path::new(&file).exists() {
+ // cc files are optional so we can skip them.
+ continue;
}
+
+ cmd.arg(file);
let exe = if cfg!(windows) {
cmd.arg("target/debug/wasmtime.lib")
.arg("ws2_32.lib")
@@ -89,6 +98,7 @@ fn main() {
run(&mut Command::new(exe));
}
}
+}
fn run(cmd: &mut Command) {
let s = cmd.status().unwrap();
