split on two crates

This commit is contained in:
vms 2021-04-08 12:49:53 +03:00
parent 3580e429c3
commit 176b71b4a1
5 changed files with 62 additions and 11 deletions

View File

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

View File

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

View File

@ -0,0 +1,40 @@
/*
* 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_macro2::TokenStream;
pub const FORMAT_STRING: &str = "%H:%M:%S / %Y-%m-%d";
pub fn build_timestamp() -> TokenStream {
let time = chrono::Utc::now();
let formatted_time = time.format(FORMAT_STRING);
let out_str = format!(r#"const __FCE_SDK_BUILD_TIME: &str = {}"#, formatted_time);
out_str.parse().expect("time formatting should be correct")
}

View File

@ -2,7 +2,7 @@
name = "fce-timestamp-macro" name = "fce-timestamp-macro"
version = "0.5.0" # remember to update html_root_url version = "0.5.0" # remember to update html_root_url
edition = "2018" edition = "2018"
description = "Implementation of the `#[build_timestamp]` macro" description = "Definition of the `#[build_timestamp]` macro"
repository = "https://github.com/fluencelabs/rust-sdk/crates/timestamp-macro" repository = "https://github.com/fluencelabs/rust-sdk/crates/timestamp-macro"
authors = ["Fluence Labs"] authors = ["Fluence Labs"]
keywords = ["fluence", "sdk", "webassembly", "procedural_macros"] keywords = ["fluence", "sdk", "webassembly", "procedural_macros"]
@ -14,5 +14,4 @@ proc-macro = true
doctest = false doctest = false
[dependencies] [dependencies]
syn = { version = '1.0.64', features = ['full'] } fce-timestamp-macro-impl = { path = "../timestamp-macro-impl", version = "0.5.0" }
chrono = "0.4.19"

View File

@ -28,14 +28,7 @@
use proc_macro::TokenStream; use proc_macro::TokenStream;
const FORMAT_STRING: &str = "%H:%M:%S / %Y-%m-%d";
#[proc_macro] #[proc_macro]
pub fn build_timestamp(_: TokenStream) -> TokenStream { pub fn build_timestamp(_: TokenStream) -> TokenStream {
let time = chrono::Utc::now(); fce_timestamp_macro_impl::build_timestamp().into()
let formatted_time = time.format(FORMAT_STRING);
let out_str = format!(r#"const __FCE_SDK_BUILD_TIME: &str = {}"#, formatted_time);
out_str.parse().expect("time formatting should be correct")
} }