wasm builds

This commit is contained in:
Sebastian Moser
2024-08-27 11:50:18 +02:00
parent 39cf7f5ee3
commit 31e071078a
8 changed files with 36 additions and 13 deletions

View File

@@ -1,7 +1,6 @@
use core::fmt;
use std::collections::HashMap;
use std::fs::create_dir;
use std::thread::JoinHandle;
use std::{thread, vec};
use crossbeam::channel::{self, bounded, Receiver, Sender};
use std::sync::{Arc, Mutex};
@@ -23,20 +22,24 @@ use crate::memstore::MemStore;
use crate::instance::updater::Operation;
use crate::mize_err;
use crate::proto::MizeMessage;
use tokio::runtime::Handle;
use self::connection::{ConnListener, Connection};
use self::updater::handle_operation;
#[cfg(feature = "async")]
use tokio::runtime::Runtime;
#[cfg(feature = "async")]
use tokio::runtime::Handle;
use core::future::Future;
use std::thread::JoinHandle;
pub mod connection;
pub mod store;
pub mod subscription;
pub mod updater;
pub mod msg_thread;
pub mod module;
static MSG_CHANNEL_SIZE: usize = 200;
@@ -136,9 +139,7 @@ impl Instance {
fn init(&mut self) -> MizeResult<()> {
// platform specific init code
if cfg!(feature = "os-target") { // on os platforms
crate::platform::os::os_instance_init(self)?
}
crate::platform::any::instance_init(self);
// end of platform specific init code

View File

@@ -0,0 +1,6 @@
// https://users.rust-lang.org/t/casting-between-trait-object-types/97220/2
pub trait Module {
}

View File

@@ -5,7 +5,6 @@ use std::fmt::Debug;
use std::{i128, string};
use std::{collections::HashMap, path::PathBuf, io::Cursor, fmt::Display};
use std::fs::File;
use tokio::sync::Mutex;
use std::rc::Rc;
use colored::Colorize;
use std::io;

View File

@@ -1,6 +1,5 @@
use core::fmt;
use std::io;
use nix::libc::CTRL_CMD_UNSPEC;
use serde::Serialize;
use ciborium::{value::Integer, Value as CborValue};

View File

@@ -22,8 +22,16 @@ pub mod platform {
#[cfg(feature = "wasm-target")]
pub mod wasm;
//#[cfg(feature = "os-target")]
#[cfg(feature = "os-target")]
pub mod os;
pub mod any {
#[cfg(feature = "wasm-target")]
pub use super::wasm::wasm_instance_init as instance_init;
#[cfg(feature = "os-target")]
pub use super::os::os_instance_init as instance_init;
}
}

View File

@@ -316,7 +316,7 @@ impl MinimalTracer {
pub fn register() -> Result<(), tracing::subscriber::SetGlobalDefaultError> {
let mut enabled = true;
let mut span_names_to_enable = Vec::new();
let mut my_level = Level::INFO;
let mut my_level = Level::ERROR;
let mut filters: Vec<LogFilter> = Vec::with_capacity(10);
if let Ok(env_value) = env::var("RUST_LOG") {

View File

@@ -2,6 +2,9 @@ mod utils;
use wasm_bindgen::prelude::*;
use crate::instance::Instance;
use crate::error::MizeResult;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
@@ -17,3 +20,10 @@ extern {
pub fn greet() {
alert("Hello, wasm-game-of-life!");
}
pub fn wasm_instance_init(instance: &mut Instance) -> MizeResult<()> {
println!("Hello world from wasm_instance_init!!!!!!!!!!");
alert("Hello world from wasm_instance_init!!!!!!!!!!");
Ok(())
}