Browse Source

Remove chrono dependency in some crates (#2890)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Ngo Iok Ui (Wu Yu Wei) 3 years ago
parent
commit
1805d05867

+ 9 - 44
tooling/bench/Cargo.lock

@@ -8,12 +8,6 @@ version = "1.0.53"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0"
 
-[[package]]
-name = "autocfg"
-version = "1.0.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
-
 [[package]]
 name = "bitflags"
 version = "1.3.2"
@@ -26,19 +20,6 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
-[[package]]
-name = "chrono"
-version = "0.4.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
-dependencies = [
- "libc",
- "num-integer",
- "num-traits",
- "time",
- "winapi",
-]
-
 [[package]]
 name = "fastrand"
 version = "1.7.0"
@@ -70,22 +51,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
 
 [[package]]
-name = "num-integer"
-version = "0.1.44"
+name = "num_threads"
+version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
+checksum = "97ba99ba6393e2c3734791401b66902d981cb03bf190af674ca69949b6d5fb15"
 dependencies = [
- "autocfg",
- "num-traits",
-]
-
-[[package]]
-name = "num-traits"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
-dependencies = [
- "autocfg",
+ "libc",
 ]
 
 [[package]]
@@ -177,10 +148,10 @@ name = "tauri_bench"
 version = "0.1.0"
 dependencies = [
  "anyhow",
- "chrono",
  "serde",
  "serde_json",
  "tempfile",
+ "time",
 ]
 
 [[package]]
@@ -199,13 +170,13 @@ dependencies = [
 
 [[package]]
 name = "time"
-version = "0.1.44"
+version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
+checksum = "004cbc98f30fa233c61a38bc77e96a9106e65c88f2d3bef182ae952027e5753d"
 dependencies = [
+ "itoa",
  "libc",
- "wasi",
- "winapi",
+ "num_threads",
 ]
 
 [[package]]
@@ -214,12 +185,6 @@ version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
 
-[[package]]
-name = "wasi"
-version = "0.10.0+wasi-snapshot-preview1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
-
 [[package]]
 name = "winapi"
 version = "0.3.9"

+ 1 - 1
tooling/bench/Cargo.toml

@@ -12,7 +12,7 @@ repository = "https://github.com/tauri-apps/wry"
 
 [dependencies]
 anyhow = "1.0.40"
-chrono = "0.4.19"
+time = { version = "0.3", features = ["formatting"] }
 tempfile = "3.2.0"
 serde_json = "1.0"
 serde = { version = "1.0", features = [ "derive" ] }

+ 4 - 1
tooling/bench/src/run_benchmark.rs

@@ -264,8 +264,11 @@ fn main() -> Result<()> {
 
   env::set_current_dir(&utils::bench_root_path())?;
 
+  let format =
+    time::format_description::parse("[year]-[month]-[day]T[hour]:[minute]:[second]Z").unwrap();
+  let now = time::OffsetDateTime::now_utc();
   let mut new_data = utils::BenchResult {
-    created_at: chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true),
+    created_at: format!("{}", now.format(&format).unwrap()),
     sha1: utils::run_collect(&["git", "rev-parse", "HEAD"])
       .0
       .trim()

+ 1 - 1
tooling/bench/src/utils.rs

@@ -41,7 +41,7 @@ pub fn get_target() -> &'static str {
   #[cfg(target_os = "linux")]
   return "x86_64-unknown-linux-gnu";
   #[cfg(target_os = "windows")]
-  return unimplemented!();
+  unimplemented!();
 }
 
 pub fn target_dir() -> PathBuf {

+ 1 - 1
tooling/bundler/Cargo.toml

@@ -50,7 +50,7 @@ sha2 = "0.10"
 hex = "0.4"
 
 [target."cfg(target_os = \"macos\")".dependencies]
-chrono = "0.4"
+time = { version = "0.3", features = ["formatting"] }
 dirs-next = "2.0"
 
 [target."cfg(any(target_os = \"macos\", target_os = \"windows\"))".dependencies]

+ 5 - 1
tooling/bundler/src/bundle/macos/app.rs

@@ -180,7 +180,11 @@ fn create_info_plist(
   bundle_icon_file: Option<PathBuf>,
   settings: &Settings,
 ) -> crate::Result<()> {
-  let build_number = chrono::Utc::now().format("%Y%m%d.%H%M%S");
+  let format = time::format_description::parse("[year][month][day].[hour][minute][second]")
+    .map_err(|e| time::error::Error::from(e))?;
+  let build_number = time::OffsetDateTime::now_utc()
+    .format(&format)
+    .map_err(|e| time::error::Error::from(e))?;
 
   let bundle_plist_path = bundle_dir.join("Info.plist");
   let file = &mut common::create_file(&bundle_plist_path)?;

+ 4 - 0
tooling/bundler/src/error.rs

@@ -96,6 +96,10 @@ pub enum Error {
   /// Failed to sign application.
   #[error("failed to sign app: {0}")]
   Sign(String),
+  /// time error.
+  #[cfg(target_os = "macos")]
+  #[error("`{0}`")]
+  TimeError(#[from] time::error::Error),
 }
 
 /// Convenient type alias of Result type.