mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 15:20:18 +00:00
add logger feature
This commit is contained in:
parent
5c5287f572
commit
043af06af6
@ -24,6 +24,9 @@ fluence-sdk-main = { path = "crates/main", version = "=0.2.0" }
|
||||
# Print some internal logs by log_utf8_string
|
||||
debug = ["fluence-sdk-main/debug"]
|
||||
|
||||
# Print some internal logs by log_utf8_string
|
||||
logger = ["fluence-sdk-main/logger"]
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/main",
|
||||
|
@ -17,4 +17,4 @@ all-features = true
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
fluence-sdk-wit = { path = "../wit" }
|
||||
fluence-sdk-wit = { path = "../wit", version = "=0.2.0" }
|
||||
|
@ -27,3 +27,6 @@ lazy_static = "1.4.0" # used in doc test
|
||||
[features]
|
||||
# Print some internal logs by log_utf8_string
|
||||
debug = []
|
||||
|
||||
# Enable logger, this will cause log_utf8_string to appear in imports
|
||||
logger = []
|
||||
|
@ -32,11 +32,13 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
mod export_allocator;
|
||||
#[cfg(feature = "logger")]
|
||||
mod logger;
|
||||
mod result;
|
||||
|
||||
pub use export_allocator::allocate;
|
||||
pub use export_allocator::deallocate;
|
||||
#[cfg(feature = "logger")]
|
||||
pub use logger::WasmLogger;
|
||||
pub use result::get_result_ptr;
|
||||
pub use result::get_result_size;
|
||||
|
@ -68,6 +68,7 @@ impl quote::ToTokens for fce_ast_types::AstFunctionItem {
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
pub unsafe fn #func_name(#(#raw_arg_names: #raw_arg_types),*) #fn_return_type {
|
||||
// arguments conversation from Wasm types to Rust types
|
||||
#prolog
|
||||
|
||||
// calling the original function with converted args
|
||||
@ -77,7 +78,7 @@ impl quote::ToTokens for fce_ast_types::AstFunctionItem {
|
||||
#epilog
|
||||
}
|
||||
|
||||
// #[cfg(target_arch = "wasm32")]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
#[link_section = #section_name]
|
||||
|
@ -40,14 +40,14 @@ impl quote::ToTokens for fce_ast_types::AstExternModItem {
|
||||
|
||||
let glue_code = quote! {
|
||||
#[link(wasm_import_module = #wasm_import_module_name)]
|
||||
// #[cfg(target_arch = "wasm32")]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
extern "C" {
|
||||
#generated_imports
|
||||
}
|
||||
|
||||
#wrapper_functions
|
||||
|
||||
// #[cfg(target_arch = "wasm32")]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
#[link_section = #section_name]
|
||||
@ -113,7 +113,7 @@ fn generate_wrapper_functions(extern_item: &fce_ast_types::AstExternModItem) ->
|
||||
let epilog = signature.output_type.generate_wrapper_epilog();
|
||||
|
||||
let wrapper_func = quote! {
|
||||
// #[cfg(target_arch = "wasm32")]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[doc(hidden)]
|
||||
#[allow(clippy::all)]
|
||||
#visibility fn #func_name(#(#arg_names: #arg_types), *) #return_type {
|
||||
|
@ -37,7 +37,6 @@ impl quote::ToTokens for fce_ast_types::AstRecordItem {
|
||||
#[allow(clippy::all)]
|
||||
#[link_section = #section_name]
|
||||
pub static #global_static_name: [u8; #data_size] = { *#data };
|
||||
|
||||
};
|
||||
|
||||
tokens.extend(glue_code);
|
||||
|
@ -35,6 +35,7 @@ extern crate fluence_sdk_macro;
|
||||
extern crate fluence_sdk_main;
|
||||
|
||||
pub use fluence_sdk_macro::fce;
|
||||
#[cfg(feature = "logger")]
|
||||
pub use fluence_sdk_main::WasmLogger;
|
||||
|
||||
/// These API functions are intended for internal usage in generated code.
|
||||
|
Loading…
Reference in New Issue
Block a user