From 031e8de99f6591b67b53d92337adc3ea80721c63 Mon Sep 17 00:00:00 2001 From: Empire Date: Mon, 27 Nov 2023 01:07:07 +0100 Subject: [PATCH] use vergen --- rust/Cargo.toml | 4 +++- rust/build.rs | 4 +++- rust/src/main.rs | 5 ++--- rust/src/webserver/webserver.rs | 5 ++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 3416fc5..1965284 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -66,14 +66,16 @@ esp-idf-hal = "0.42.5" esp-idf-sys = { version = "0.33.7", features = ["binstart", "native"] } esp-ota = "0.2.0" esp_idf_build = "0.1.3" -build-time = "0.1.2" chrono = { version = "0.4.23", default-features = false , features = ["iana-time-zone"] } chrono-tz = {version="0.8.0", default-features = false , features = [ "filter-by-regex" ]} embedded-hal = "0.2.7" shift-register-driver = "0.1.1" one-wire-bus = "0.1.1" anyhow = { version = "1.0.75", features = ["std", "backtrace"] } +schemars = "0.8.16" + #?bq34z100 required [build-dependencies] embuild = "0.31.3" +vergen = { version = "8.2.6", features = ["build", "git", "gitcl"] } \ No newline at end of file diff --git a/rust/build.rs b/rust/build.rs index 112ec3f..a72435f 100644 --- a/rust/build.rs +++ b/rust/build.rs @@ -1,3 +1,5 @@ +use vergen::EmitBuilder; fn main() { embuild::espidf::sysenv::output(); -} + let _ = EmitBuilder::builder().all_git().emit(); +} \ No newline at end of file diff --git a/rust/src/main.rs b/rust/src/main.rs index 178fe2d..8dae440 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -1,5 +1,4 @@ use chrono::{Datelike, Timelike, NaiveDateTime}; -use build_time::build_time_utc; use chrono_tz::Europe::Berlin; use esp_idf_hal::delay::Delay; @@ -26,8 +25,8 @@ fn main() -> Result<()>{ log::info!("Startup Rust"); - let utc_build_time = build_time_utc!(); - println!("Version was build {}", utc_build_time); + let git_hash = env!("VERGEN_GIT_DESCRIBE"); + println!("Version useing git has {}", git_hash); let mut board = PlantHal::create()?; diff --git a/rust/src/webserver/webserver.rs b/rust/src/webserver/webserver.rs index bf150b1..039fad7 100644 --- a/rust/src/webserver/webserver.rs +++ b/rust/src/webserver/webserver.rs @@ -1,6 +1,5 @@ //offer ota and config mode -use build_time::build_time_utc; use embedded_svc::http::Method; use esp_idf_svc::http::server::EspHttpServer; use esp_ota::OtaUpdate; @@ -20,9 +19,9 @@ pub fn httpd(initial_config:bool) -> EspHttpServer<'static> { return Ok(()) }).unwrap(); server - .fn_handler("/buildtime",Method::Get, |request| { + .fn_handler("/version",Method::Get, |request| { let mut response = request.into_ok_response()?; - response.write(build_time_utc!().as_bytes())?; + response.write(env!("VERGEN_GIT_DESCRIBE").as_bytes())?; return Ok(()) }).unwrap(); server