wasm builds
This commit is contained in:
@@ -17,9 +17,9 @@ path = "src/platform/os/main.rs"
|
|||||||
required-features = [ "os-target" ]
|
required-features = [ "os-target" ]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
os-target = [ "clap", "home", "daemonize", "nix", "toml", "serde_json", "sysinfo", "ciborium/default", "tracing-subscriber", "async", "tracing-subscriber/env-filter"]
|
os-target = [ "clap", "home", "daemonize", "nix", "toml", "sysinfo", "ciborium/default", "tracing-subscriber", "async", "tracing-subscriber/env-filter"]
|
||||||
async = ["tokio/net", "tokio", "tokio/rt-multi-thread", "tokio/io-util"]
|
|
||||||
wasm-target = [ "wasm-bindgen", "console_error_panic_hook", "wasm-bindgen-cli" ]
|
wasm-target = [ "wasm-bindgen", "console_error_panic_hook", "wasm-bindgen-cli" ]
|
||||||
|
async = ["tokio/net", "tokio", "tokio/rt-multi-thread", "tokio/io-util"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
@@ -30,6 +30,8 @@ ciborium = { version = "0.2.2", default-features = false }
|
|||||||
serde = "1.0.203"
|
serde = "1.0.203"
|
||||||
interner = { git = "https://github.com/c2vi/interner" }
|
interner = { git = "https://github.com/c2vi/interner" }
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
|
serde_json = { version = "1.0.117", optional = false }
|
||||||
|
crossbeam = "0.8.4"
|
||||||
|
|
||||||
# wasm dependencies
|
# wasm dependencies
|
||||||
wasm-bindgen = { version = "0.2.84", optional = true }
|
wasm-bindgen = { version = "0.2.84", optional = true }
|
||||||
@@ -42,7 +44,6 @@ home = { version = "0.5.9", optional = true }
|
|||||||
daemonize = { version = "0.5.0", optional = true }
|
daemonize = { version = "0.5.0", optional = true }
|
||||||
nix = { version = "0.27.1", features = ["signal"], optional = true }
|
nix = { version = "0.27.1", features = ["signal"], optional = true }
|
||||||
toml = { version = "0.8.13", features = ["parse"], optional = true }
|
toml = { version = "0.8.13", features = ["parse"], optional = true }
|
||||||
serde_json = { version = "1.0.117", optional = true }
|
|
||||||
sysinfo = { version = "0.30.12", optional = true }
|
sysinfo = { version = "0.30.12", optional = true }
|
||||||
tracing-subscriber = { version = "0.3.18", optional = true }
|
tracing-subscriber = { version = "0.3.18", optional = true }
|
||||||
tokio = { version = "1.21.0", features = ["sync"], optional = true }
|
tokio = { version = "1.21.0", features = ["sync"], optional = true }
|
||||||
@@ -53,7 +54,6 @@ tokio = { version = "1.21.0", features = ["sync"], optional = true }
|
|||||||
axum = { version = "0.6.1", features = ["ws", "headers"], optional = true }
|
axum = { version = "0.6.1", features = ["ws", "headers"], optional = true }
|
||||||
axum-extra = { version = "0.4.2", features = ["spa"], optional = true }
|
axum-extra = { version = "0.4.2", features = ["spa"], optional = true }
|
||||||
axum-macros = { version = "0.3.0", optional = true }
|
axum-macros = { version = "0.3.0", optional = true }
|
||||||
crossbeam = "0.8.4"
|
|
||||||
dyn-clone = "1.0.17"
|
dyn-clone = "1.0.17"
|
||||||
tokio-core = "0.1.18"
|
tokio-core = "0.1.18"
|
||||||
tokio-io = "0.1.13"
|
tokio-io = "0.1.13"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::create_dir;
|
use std::fs::create_dir;
|
||||||
use std::thread::JoinHandle;
|
|
||||||
use std::{thread, vec};
|
use std::{thread, vec};
|
||||||
use crossbeam::channel::{self, bounded, Receiver, Sender};
|
use crossbeam::channel::{self, bounded, Receiver, Sender};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@@ -23,20 +22,24 @@ use crate::memstore::MemStore;
|
|||||||
use crate::instance::updater::Operation;
|
use crate::instance::updater::Operation;
|
||||||
use crate::mize_err;
|
use crate::mize_err;
|
||||||
use crate::proto::MizeMessage;
|
use crate::proto::MizeMessage;
|
||||||
use tokio::runtime::Handle;
|
|
||||||
|
|
||||||
use self::connection::{ConnListener, Connection};
|
use self::connection::{ConnListener, Connection};
|
||||||
use self::updater::handle_operation;
|
use self::updater::handle_operation;
|
||||||
|
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
|
#[cfg(feature = "async")]
|
||||||
|
use tokio::runtime::Handle;
|
||||||
|
|
||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
|
use std::thread::JoinHandle;
|
||||||
|
|
||||||
pub mod connection;
|
pub mod connection;
|
||||||
pub mod store;
|
pub mod store;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
pub mod updater;
|
pub mod updater;
|
||||||
pub mod msg_thread;
|
pub mod msg_thread;
|
||||||
|
pub mod module;
|
||||||
|
|
||||||
static MSG_CHANNEL_SIZE: usize = 200;
|
static MSG_CHANNEL_SIZE: usize = 200;
|
||||||
|
|
||||||
@@ -136,9 +139,7 @@ impl Instance {
|
|||||||
fn init(&mut self) -> MizeResult<()> {
|
fn init(&mut self) -> MizeResult<()> {
|
||||||
|
|
||||||
// platform specific init code
|
// platform specific init code
|
||||||
if cfg!(feature = "os-target") { // on os platforms
|
crate::platform::any::instance_init(self);
|
||||||
crate::platform::os::os_instance_init(self)?
|
|
||||||
}
|
|
||||||
|
|
||||||
// end of platform specific init code
|
// end of platform specific init code
|
||||||
|
|
||||||
|
|||||||
6
src/core/instance/module.rs
Normal file
6
src/core/instance/module.rs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
// https://users.rust-lang.org/t/casting-between-trait-object-types/97220/2
|
||||||
|
|
||||||
|
pub trait Module {
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ use std::fmt::Debug;
|
|||||||
use std::{i128, string};
|
use std::{i128, string};
|
||||||
use std::{collections::HashMap, path::PathBuf, io::Cursor, fmt::Display};
|
use std::{collections::HashMap, path::PathBuf, io::Cursor, fmt::Display};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use tokio::sync::Mutex;
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::io;
|
use std::io;
|
||||||
use nix::libc::CTRL_CMD_UNSPEC;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use ciborium::{value::Integer, Value as CborValue};
|
use ciborium::{value::Integer, Value as CborValue};
|
||||||
|
|||||||
10
src/lib.rs
10
src/lib.rs
@@ -22,8 +22,16 @@ pub mod platform {
|
|||||||
#[cfg(feature = "wasm-target")]
|
#[cfg(feature = "wasm-target")]
|
||||||
pub mod wasm;
|
pub mod wasm;
|
||||||
|
|
||||||
//#[cfg(feature = "os-target")]
|
#[cfg(feature = "os-target")]
|
||||||
pub mod os;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ impl MinimalTracer {
|
|||||||
pub fn register() -> Result<(), tracing::subscriber::SetGlobalDefaultError> {
|
pub fn register() -> Result<(), tracing::subscriber::SetGlobalDefaultError> {
|
||||||
let mut enabled = true;
|
let mut enabled = true;
|
||||||
let mut span_names_to_enable = Vec::new();
|
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);
|
let mut filters: Vec<LogFilter> = Vec::with_capacity(10);
|
||||||
if let Ok(env_value) = env::var("RUST_LOG") {
|
if let Ok(env_value) = env::var("RUST_LOG") {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ mod utils;
|
|||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
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
|
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
||||||
// allocator.
|
// allocator.
|
||||||
#[cfg(feature = "wee_alloc")]
|
#[cfg(feature = "wee_alloc")]
|
||||||
@@ -17,3 +20,10 @@ extern {
|
|||||||
pub fn greet() {
|
pub fn greet() {
|
||||||
alert("Hello, wasm-game-of-life!");
|
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(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user