From 4abb6548cd5596a1b929c18b43b51c49857decda Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 7 Feb 2022 17:38:07 +0800 Subject: [PATCH] add a feature to turn off timestamps specifying "no-timestamp" causes the build to be reproducible on the same machine. of course, introducing the timestamp makes the build no longer reproducible but it's very helpful for debugging. --- services/ticktimer-server/Cargo.toml | 3 ++- services/ticktimer-server/src/main.rs | 1 + xtask/src/main.rs | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/ticktimer-server/Cargo.toml b/services/ticktimer-server/Cargo.toml index eb85ca9c9..cf9b43411 100644 --- a/services/ticktimer-server/Cargo.toml +++ b/services/ticktimer-server/Cargo.toml @@ -25,7 +25,8 @@ utralib = {path = "../../utralib"} [features] debug-print = [] watchdog = [] -# generally you want to disable watchdog if you're doing development +no-timestamp = [] # turns off embedded timestamp for reproducible builds +# you may want to remove the watchdog feature if you're debugging a crash, as it will force the system to reboot automatically default = ["watchdog"] # default = [] # default = ["debug-print"] diff --git a/services/ticktimer-server/src/main.rs b/services/ticktimer-server/src/main.rs index 0fe3a7bb3..a9f231440 100644 --- a/services/ticktimer-server/src/main.rs +++ b/services/ticktimer-server/src/main.rs @@ -475,6 +475,7 @@ fn xmain() -> ! { log::info!("****************************************************************"); log::info!("Welcome to Xous {}", version::SEMVER); + #[cfg(not(feature="no-timestamp"))] log::info!("Built on {}", version::TIMESTAMP); log::info!("****************************************************************"); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index d69eb1f69..ad568beda 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1119,8 +1119,10 @@ fn generate_version() { .truncate(true) .open("services/ticktimer-server/src/version.rs").expect("Can't open our version file for writing"); print_header(&mut vfile); + #[cfg(not(feature="no-timestamp"))] let now = Local::now(); - write!(vfile, "pub const TIMESTAMP: &'static str = \"{}\";\n", now.to_rfc2822()).expect("couldn't add our timestamp"); + #[cfg(not(feature="no-timestamp"))] + write!(vfile, "#[allow(dead_code)]\npub const TIMESTAMP: &'static str = \"{}\";\n", now.to_rfc2822()).expect("couldn't add our timestamp"); write!(vfile, "pub const SEMVER: &'static str = \"{}\";\n", semver .strip_suffix("\r\n") @@ -1139,7 +1141,9 @@ pub(crate) fn get_version() -> crate::api::VersionString { version: xous_ipc::String::new() }; v.version.append(SEMVER).ok(); + #[cfg(not(feature="no-timestamp"))] v.version.append("\n").ok(); + #[cfg(not(feature="no-timestamp"))] v.version.append(TIMESTAMP).ok(); v }