can we compile the std library with special features

This commit is contained in:
Sebastian Moser
2024-09-18 18:09:03 +02:00
parent 1dedfb8500
commit e04b955ae0
4 changed files with 51 additions and 1 deletions

5
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,5 @@
[toolchain]
channel = "nightly-2024-07-30"
components = [ "cargo", "rustc-dev" ]
targets = [ "wasm32-unknown-unknown" ]
profile = "minimal"

View File

@@ -409,6 +409,27 @@ impl Instance {
debug!("spawning thread: {}", name_to_move);
let my_thread_id = my_thread_id_no_mutex_guard;
#[cfg(feature = "wasm-target")]
unsafe {
// console_log macro
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
}
macro_rules! console_log {
// Note that this is using the `log` function imported above during
// `bare_bones`
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
}
//end of console_log macro
console_log!("in other threadddddddddddddd");
}
func()?;
let mut threads_inner = thread_mutex.lock()?;

View File

@@ -49,6 +49,23 @@ pub fn updater_thread(operation_rx : Receiver<Operation>, instance: &Instance) -
}
pub fn handle_operation(operation: &mut Operation, instance: &Instance) -> MizeResult<()> {
#[cfg(feature = "wasm-target")]
unsafe {
// console_log macro
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
}
macro_rules! console_log {
// Note that this is using the `log` function imported above during
// `bare_bones`
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
}
//end of console_log macro
console_log!("handle operation....");
}
match operation {
Operation::Set(id, value, maybe_conn) => {
let item_data: ItemData = value.to_owned();

View File

@@ -1,4 +1,3 @@
use wasm_bindgen::prelude::*;
use std::ptr::NonNull;
use std::panic;
use web_sys::js_sys;
@@ -10,9 +9,11 @@ use crate::instance::{self, Instance};
use crate::error::MizeResult;
use crate::{mize_err, Module};
use crate::MizeError;
use crate::core::item::IntoItemData;
// console_log macro
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
@@ -131,6 +132,12 @@ impl JsInstance {
return js_instance;
}
#[wasm_bindgen]
pub unsafe fn test(&mut self) -> () {
console_log!("hiiiiiiiiiiiiiiii from test");
self.inner.as_mut().set("0/config/hello", "hello world".into_item_data());
}
//#[wasm_bindgen]
}