move versioning infrastructure to a feature flag

this enables more smooth packaging of the ticktimer crate
This commit is contained in:
bunnie 2022-10-14 16:22:46 +08:00
parent 4d52bb40f0
commit 6ee5375934
2 changed files with 26 additions and 7 deletions

View file

@ -21,9 +21,10 @@ rkyv = {version = "0.4.3", default-features = false, features = ["const_generics
num-derive = {version = "0.3.3", default-features = false} num-derive = {version = "0.3.3", default-features = false}
num-traits = {version = "0.2.14", default-features = false} num-traits = {version = "0.2.14", default-features = false}
xous-semver = "0.1.2" xous-semver = "0.1.2"
utralib = {version = "0.1.3", optional = true, default-features = false } utralib = {version = "0.1.3", optional = true, default-features = false }
[build-dependencies]
chrono = "0.4"
[features] [features]
precursor = ["utralib/precursor", "xous/precursor", "susres/precursor"] precursor = ["utralib/precursor", "xous/precursor", "susres/precursor"]
@ -31,7 +32,7 @@ hosted = ["utralib/hosted", "susres/hosted"]
renode = ["utralib/renode", "xous/renode", "susres/renode"] renode = ["utralib/renode", "xous/renode", "susres/renode"]
debug-print = [] debug-print = []
watchdog = [] watchdog = []
no-timestamp = [] # turns off embedded timestamp for reproducible builds timestamp = []
# you may want to remove the watchdog feature if you're debugging a crash, as it will force the system to reboot automatically # 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 = ["watchdog"]
# default = [] # default = []

View file

@ -3,6 +3,7 @@
#![cfg_attr(target_os = "none", no_main)] #![cfg_attr(target_os = "none", no_main)]
use xous_api_ticktimer::*; use xous_api_ticktimer::*;
#[cfg(feature="timestamp")]
mod version; mod version;
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
@ -523,11 +524,20 @@ fn main() -> ! {
log::set_max_level(log::LevelFilter::Info); log::set_max_level(log::LevelFilter::Info);
info!("my PID is {}", xous::process::id()); info!("my PID is {}", xous::process::id());
log::info!("****************************************************************"); #[cfg(feature="timestamp")]
log::info!("Welcome to Xous {}", version::SEMVER); {
#[cfg(not(feature = "no-timestamp"))] log::info!("****************************************************************");
log::info!("Built on {}", version::TIMESTAMP); log::info!("Welcome to Xous {}", version::SEMVER);
log::info!("****************************************************************"); log::info!("Built on {}", version::TIMESTAMP);
log::info!("****************************************************************");
}
#[cfg(not(feature="timestamp"))]
{
log::info!("****************************************************************");
log::info!("Welcome to Xous");
log::info!("Reproducible build without timestamps");
log::info!("****************************************************************");
}
let ticktimer_server = xous::create_server_with_address(b"ticktimer-server") let ticktimer_server = xous::create_server_with_address(b"ticktimer-server")
.expect("Couldn't create Ticktimer server"); .expect("Couldn't create Ticktimer server");
@ -673,7 +683,15 @@ fn main() -> ! {
msg.body.memory_message_mut().unwrap(), msg.body.memory_message_mut().unwrap(),
) )
}; };
#[cfg(feature="timestamp")]
buf.replace(version::get_version()).unwrap(); buf.replace(version::get_version()).unwrap();
#[cfg(not(feature="timestamp"))]
{
let v = crate::api::VersionString {
version: xous_ipc::String::from_str("--no-timestamp requested for build")
};
buf.replace(v).unwrap();
}
} }
Some(api::Opcode::LockMutex) => { Some(api::Opcode::LockMutex) => {
let pid = msg.sender.pid(); let pid = msg.sender.pid();