add logger feature

This commit is contained in:
vms 2020-07-14 00:36:23 +03:00
parent 5c5287f572
commit 043af06af6
8 changed files with 15 additions and 6 deletions

View File

@ -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",

View File

@ -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" }

View File

@ -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 = []

View File

@ -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;

View File

@ -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]

View File

@ -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 {

View File

@ -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);

View File

@ -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.