use cfg_aliases::cfg_aliases;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo::rustc-check-cfg=cfg(wasm)");
println!("cargo::rustc-check-cfg=cfg(native)");
cfg_aliases! {
wasm: { all(target_family = "wasm", target_os = "unknown") },
native: { not(all(target_family = "wasm", target_os = "unknown")) },
}
let target_family = std::env::var("CARGO_CFG_TARGET_FAMILY").unwrap_or_default();
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
if target_family == "wasm" && target_os == "unknown" {
return Ok(());
}
let proto_dir = std::path::Path::new("tests/proto");
if !proto_dir.exists() {
return Ok(());
}
tonic_prost_build::configure()
.build_server(true)
.build_client(true)
.compile_protos(
&[
"tests/proto/common.proto",
"tests/proto/user.proto",
"tests/proto/user_events.proto",
],
&["tests/proto"],
)?;
Ok(())
}