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.
This commit is contained in:
bunnie 2022-02-07 17:38:07 +08:00
parent b86f1bcf3f
commit 4abb6548cd
3 changed files with 8 additions and 2 deletions

View file

@ -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"]

View file

@ -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!("****************************************************************");

View file

@ -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
}