Merge branch 'master' into support_references

This commit is contained in:
vms 2021-04-09 15:57:54 +03:00
commit 16d0210531
10 changed files with 72 additions and 8 deletions

View File

@ -4,6 +4,7 @@ members = [
"crates/fce-test-macro",
"crates/fce-test-macro-impl",
"crates/main",
"crates/timestamp-macro",
"crates/wit",
"fluence",
"fluence-test"

View File

@ -18,4 +18,4 @@ proc-macro = true
doctest = false
[dependencies]
fluence-sdk-wit = { path = "../wit", version = "=0.6.0" }
fluence-sdk-wit = { path = "../wit", version = "0.6.0" }

View File

@ -17,7 +17,7 @@ proc-macro = true
doctest = false
[dependencies]
fluence-sdk-test-macro-impl = { path = "../fce-test-macro-impl", version = "=0.6.0" }
fluence-sdk-test-macro-impl = { path = "../fce-test-macro-impl", version = "0.6.0" }
quote = "1.0.9"
proc-macro2 = "1.0.24"

View File

@ -19,7 +19,7 @@ crate-type = ["rlib"]
doctest = false
[dependencies]
fluence-sdk-macro = { path = "../fce-macro", version = "=0.6.0" }
fluence-sdk-macro = { path = "../fce-macro", version = "0.6.0" }
log = { version = "0.4.8", features = ["std"] }
serde = "=1.0.118"

View File

@ -20,17 +20,21 @@ pub const MANIFEST_SECTION_NAME: &str = "__fluence_wasm_module_manifest";
#[macro_export]
macro_rules! module_manifest {
($authors:expr, $version:expr, $description:expr, $repository:expr) => {
fluence::internal::build_timestamp!();
const __FCE_SDK_AUTHORS_SIZE: usize = $authors.as_bytes().len();
const __FCE_SDK_VERSION_SIZE: usize = $version.as_bytes().len();
const __FCE_SDK_DESCRIPTION_SIZE: usize = $description.as_bytes().len();
const __FCE_SDK_REPOSITORY_SIZE: usize = $repository.as_bytes().len();
const __FCE_SDK_BUILD_TIME_SIZE: usize = __FCE_SDK_BUILD_TIME.as_bytes().len();
const __FCE_SDK_FIELD_PREFIX_SIZE: usize = std::mem::size_of::<u64>();
const __FCE_MANIFEST_SIZE: usize = __FCE_SDK_AUTHORS_SIZE
+ __FCE_SDK_VERSION_SIZE
+ __FCE_SDK_DESCRIPTION_SIZE
+ __FCE_SDK_REPOSITORY_SIZE
+ __FCE_SDK_FIELD_PREFIX_SIZE * 4;
+ __FCE_SDK_BUILD_TIME_SIZE
+ __FCE_SDK_FIELD_PREFIX_SIZE * 5;
const fn __fce_sdk_append_data(
mut manifest: [u8; __FCE_MANIFEST_SIZE],
@ -66,7 +70,8 @@ macro_rules! module_manifest {
let (manifest, offset) = __fce_sdk_append_data(manifest, $authors, offset);
let (manifest, offset) = __fce_sdk_append_data(manifest, $version, offset);
let (manifest, offset) = __fce_sdk_append_data(manifest, $description, offset);
let (manifest, _) = __fce_sdk_append_data(manifest, $repository, offset);
let (manifest, offset) = __fce_sdk_append_data(manifest, $repository, offset);
let (manifest, _) = __fce_sdk_append_data(manifest, __FCE_SDK_BUILD_TIME, offset);
manifest
}

View File

@ -0,0 +1,18 @@
[package]
name = "fce-timestamp-macro"
version = "0.5.0" # remember to update html_root_url
edition = "2018"
description = "Definition of the `#[build_timestamp]` macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/timestamp-macro"
authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "procedural_macros"]
categories = ["api-bindings", "wasm"]
license = "Apache-2.0"
[lib]
proc-macro = true
doctest = false
[dependencies]
chrono = "0.4.19"
quote = "1.0.9"

View File

@ -0,0 +1,38 @@
/*
* Copyright 2020 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#![deny(
dead_code,
nonstandard_style,
unused_imports,
unused_mut,
unused_variables,
unused_unsafe,
unreachable_patterns
)]
#![warn(rust_2018_idioms)]
#![recursion_limit = "1024"]
use proc_macro::TokenStream;
#[proc_macro]
pub fn build_timestamp(_: TokenStream) -> TokenStream {
let current_utc_date = chrono::Utc::now();
let current_utc_date = current_utc_date.to_rfc3339();
let glue_code = quote::quote! { const __FCE_SDK_BUILD_TIME: &str = #current_utc_date; };
glue_code.into()
}

View File

@ -19,7 +19,7 @@ path = "src/lib.rs"
doctest = false
[dependencies]
fluence-sdk-test-macro = { path = "../crates/fce-test-macro", version = "=0.6.0" }
fluence-sdk-test-macro = { path = "../crates/fce-test-macro", version = "0.6.0" }
fluence-app-service = { version = "0.5.2", features = ["raw-module-api"] }
serde = { version = "1.0.118", features = ["derive"] }

View File

@ -19,8 +19,9 @@ path = "src/lib.rs"
doctest = false
[dependencies]
fluence-sdk-macro = { path = "../crates/fce-macro", version = "=0.6.0" }
fluence-sdk-main = { path = "../crates/main", version = "=0.6.0" }
fluence-sdk-macro = { path = "../crates/fce-macro", version = "0.6.0" }
fluence-sdk-main = { path = "../crates/main", version = "0.6.0" }
fce-timestamp-macro = { path = "../crates/timestamp-macro", version = "0.6.0" }
serde = { version = "1.0.118", features = ["derive"]}

View File

@ -102,4 +102,5 @@ pub mod internal {
pub use fluence_sdk_main::set_result_ptr;
pub use fluence_sdk_main::set_result_size;
pub use fluence_sdk_main::add_object_to_release;
pub use fce_timestamp_macro::build_timestamp;
}