mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 15:20:18 +00:00
Merge branch 'master' into fce_test
This commit is contained in:
commit
9811e476ed
@ -12,9 +12,9 @@ jobs:
|
||||
keys:
|
||||
- backendsdk01-{{ checksum "Cargo.toml" }}
|
||||
- run: | #TODO: enable 'stable' and 'beta' once `allocator_api` becomes stable
|
||||
rustup toolchain install nightly-2020-04-20
|
||||
rustup default nightly-2020-04-20
|
||||
rustup override set nightly-2020-04-20
|
||||
rustup toolchain install nightly-2021-02-27
|
||||
rustup default nightly-2021-02-27
|
||||
rustup override set nightly-2021-02-27
|
||||
rustup target add wasm32-unknown-unknown
|
||||
rustup component add rustfmt
|
||||
rustup component add clippy
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence"
|
||||
version = "0.4.2" # remember to update html_root_url
|
||||
version = "0.5.0" # remember to update html_root_url
|
||||
description = "Fluence backend SDK for developing backend applications for the Fluence network"
|
||||
documentation = "https://docs.rs/fluence/"
|
||||
repository = "https://github.com/fluencelabs/rust-sdk"
|
||||
@ -18,8 +18,8 @@ all-features = true
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
fluence-sdk-macro = { path = "crates/macro", version = "=0.4.2" }
|
||||
fluence-sdk-main = { path = "crates/main", version = "=0.4.2" }
|
||||
fluence-sdk-macro = { path = "crates/macro", version = "=0.5.0" }
|
||||
fluence-sdk-main = { path = "crates/main", version = "=0.5.0" }
|
||||
|
||||
[features]
|
||||
# Print some internal logs by log_utf8_string
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence-sdk-macro"
|
||||
version = "0.4.2" # remember to update html_root_url
|
||||
version = "0.5.0" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Definition of the `#[fce]` macro"
|
||||
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
|
||||
@ -17,4 +17,4 @@ all-features = true
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
fluence-sdk-wit = { path = "../wit", version = "=0.4.2" }
|
||||
fluence-sdk-wit = { path = "../wit", version = "=0.5.0" }
|
||||
|
@ -50,7 +50,7 @@
|
||||
//!
|
||||
//! ```
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/fluence-sdk-macro/0.4.2")]
|
||||
#![doc(html_root_url = "https://docs.rs/fluence-sdk-macro/0.5.0")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence-sdk-main"
|
||||
version = "0.4.2" # remember to update html_root_url
|
||||
version = "0.5.0" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Rust SDK for applications for the Fluence network"
|
||||
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
|
||||
@ -18,7 +18,7 @@ path = "src/lib.rs"
|
||||
crate-type = ["rlib"]
|
||||
|
||||
[dependencies]
|
||||
fluence-sdk-macro = { path = "../macro", version = "=0.4.2" }
|
||||
fluence-sdk-macro = { path = "../macro", version = "=0.5.0" }
|
||||
|
||||
log = { version = "0.4.8", features = ["std"] }
|
||||
serde = "=1.0.118"
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(clippy::needless_doctest_main)]
|
||||
#![doc(html_root_url = "https://docs.rs/fluence-sdk-main/0.4.2")]
|
||||
#![doc(html_root_url = "https://docs.rs/fluence-sdk-main/0.5.0")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
@ -35,8 +35,10 @@ mod call_parameters;
|
||||
mod export_allocator;
|
||||
#[cfg(any(feature = "debug", feature = "logger"))]
|
||||
mod logger;
|
||||
mod module_manifest;
|
||||
pub mod mounted_binary;
|
||||
mod result;
|
||||
mod sdk_version_embedder;
|
||||
|
||||
pub use call_parameters::CallParameters;
|
||||
pub use call_parameters::SecurityTetraplet;
|
||||
@ -58,6 +60,9 @@ pub use result::get_result_size;
|
||||
pub use result::set_result_ptr;
|
||||
pub use result::set_result_size;
|
||||
|
||||
pub use module_manifest::MANIFEST_SECTION_NAME;
|
||||
pub use sdk_version_embedder::VERSION_SECTION_NAME;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub(crate) fn log<S: AsRef<str>>(msg: S) {
|
||||
// logs will be printed only if debug feature is enabled
|
||||
|
88
crates/main/src/module_manifest.rs
Normal file
88
crates/main/src/module_manifest.rs
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// TODO: avoid duplication with the link_section when key-value attributes become stable
|
||||
pub const MANIFEST_SECTION_NAME: &str = "__fluence_wasm_module_manifest";
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! module_manifest {
|
||||
($authors:expr, $version:expr, $description:expr, $repository:expr) => {
|
||||
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_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;
|
||||
|
||||
const fn append_data(
|
||||
mut manifest: [u8; __FCE_MANIFEST_SIZE],
|
||||
data: &'static str,
|
||||
offset: usize,
|
||||
) -> ([u8; __FCE_MANIFEST_SIZE], usize) {
|
||||
let data_as_bytes = data.as_bytes();
|
||||
let data_len = data_as_bytes.len();
|
||||
|
||||
// write data prefix with data size in LE
|
||||
let data_len_u64 = data_len as u64;
|
||||
let data_len_le_bytes = data_len_u64.to_le_bytes();
|
||||
let mut byte_idx = 0;
|
||||
while byte_idx < __FCE_SDK_FIELD_PREFIX_SIZE {
|
||||
manifest[offset + byte_idx] = data_len_le_bytes[byte_idx];
|
||||
byte_idx += 1;
|
||||
}
|
||||
|
||||
// write data
|
||||
let mut byte_idx = 0;
|
||||
while byte_idx < data_len {
|
||||
manifest[__FCE_SDK_FIELD_PREFIX_SIZE + offset + byte_idx] = data_as_bytes[byte_idx];
|
||||
byte_idx += 1;
|
||||
}
|
||||
|
||||
(manifest, offset + __FCE_SDK_FIELD_PREFIX_SIZE + data_len)
|
||||
}
|
||||
|
||||
const fn generate_manifest() -> [u8; __FCE_MANIFEST_SIZE] {
|
||||
let manifest: [u8; __FCE_MANIFEST_SIZE] = [0; __FCE_MANIFEST_SIZE];
|
||||
|
||||
let offset = 0;
|
||||
let (manifest, offset) = append_data(manifest, $authors, offset);
|
||||
let (manifest, offset) = append_data(manifest, $version, offset);
|
||||
let (manifest, offset) = append_data(manifest, $description, offset);
|
||||
let (manifest, _) = append_data(manifest, $repository, offset);
|
||||
|
||||
manifest
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link_section = "__fluence_wasm_module_manifest"]
|
||||
#[doc(hidden)]
|
||||
pub static __FCE_WASM_MODULE_MANIFEST: [u8; __FCE_MANIFEST_SIZE] = generate_manifest();
|
||||
};
|
||||
|
||||
() => {
|
||||
module_manifest!(
|
||||
env!("CARGO_PKG_AUTHORS"),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("CARGO_PKG_DESCRIPTION"),
|
||||
env!("CARGO_PKG_REPOSITORY")
|
||||
);
|
||||
};
|
||||
}
|
41
crates/main/src/sdk_version_embedder.rs
Normal file
41
crates/main/src/sdk_version_embedder.rs
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
const PKG_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
const VERSION_SIZE: usize = PKG_VERSION.len();
|
||||
|
||||
const fn sdk_version() -> [u8; VERSION_SIZE] {
|
||||
let version_as_slice = PKG_VERSION.as_bytes();
|
||||
|
||||
let mut version_as_array: [u8; VERSION_SIZE] = [0; VERSION_SIZE];
|
||||
let mut byte_id = 0;
|
||||
while byte_id < VERSION_SIZE {
|
||||
version_as_array[byte_id] = version_as_slice[byte_id];
|
||||
byte_id += 1;
|
||||
}
|
||||
|
||||
version_as_array
|
||||
}
|
||||
|
||||
// TODO: avoid duplication with the link_section when key-value attributes become stable
|
||||
pub const VERSION_SECTION_NAME: &str = "__fluence_sdk_version";
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link_section = "__fluence_sdk_version"]
|
||||
#[doc(hidden)]
|
||||
pub static __FCE_SDK_VERSION: [u8; VERSION_SIZE] = sdk_version();
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "fluence-sdk-wit"
|
||||
version = "0.4.2" # remember to update html_root_url
|
||||
version = "0.5.0" # remember to update html_root_url
|
||||
edition = "2018"
|
||||
description = "Webassembly interface-types generator"
|
||||
documentation = "https://docs.rs/fluence/fluence-sdk-macro"
|
||||
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#![doc(html_root_url = "https://docs.rs/wit-support/0.4.2")]
|
||||
#![doc(html_root_url = "https://docs.rs/wit-support/0.5.0")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
|
@ -55,7 +55,7 @@
|
||||
//! pub fn curl_get(url: String) -> String;
|
||||
//! }
|
||||
//! ```
|
||||
#![doc(html_root_url = "https://docs.rs/fluence/0.4.2")]
|
||||
#![doc(html_root_url = "https://docs.rs/fluence/0.5.0")]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
@ -83,6 +83,8 @@ pub use fluence_sdk_main::mounted_binary::Result as MountedBinaryResult;
|
||||
pub use fluence_sdk_main::mounted_binary::StringResult as MountedBinaryStringResult;
|
||||
pub use fluence_sdk_main::mounted_binary::SUCCESS_CODE as BINARY_SUCCESS_CODE;
|
||||
|
||||
pub use fluence_sdk_main::module_manifest;
|
||||
|
||||
/// These API functions are intended for internal usage in generated code.
|
||||
/// Normally, you shouldn't use them.
|
||||
pub mod internal {
|
||||
|
Loading…
Reference in New Issue
Block a user