Switch cts_runner to clearer no_main style of wasm compat

This commit is contained in:
Connor Fitzgerald 2025-04-25 18:16:37 -04:00 committed by Andreas Reich
parent 267f14632f
commit 65eb10ed5a

View File

@ -1,5 +1,6 @@
#[cfg(not(target_arch = "wasm32"))]
mod native {
#![cfg_attr(target_arch = "wasm32", no_main)]
#![cfg(not(target_arch = "wasm32"))]
use std::sync::Arc;
use std::{
env, fmt,
@ -103,10 +104,7 @@ mod native {
}
#[op2(fast)]
fn op_write_file_sync(
#[string] path: &str,
#[buffer] buf: &[u8],
) -> Result<(), std::io::Error> {
fn op_write_file_sync(#[string] path: &str, #[buffer] buf: &[u8]) -> Result<(), std::io::Error> {
let path = std::path::Path::new(path);
let mut file = std::fs::File::create(path)?;
file.write_all(buf)?;
@ -146,15 +144,8 @@ mod native {
false
}
}
}
#[cfg(not(target_arch = "wasm32"))]
#[tokio::main(flavor = "current_thread")]
async fn main() {
native::unwrap_or_exit(native::run().await)
}
#[cfg(target_arch = "wasm32")]
fn main() {
panic!("This is a native only module. It can't be run on the web!");
unwrap_or_exit(run().await)
}