mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
xtask: add --no-timestamp option
Add a --no-timestamp build option to skip rebuilding `ticktimer`. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
7d8ff07caf
commit
fa98b865df
1 changed files with 66 additions and 31 deletions
|
|
@ -35,8 +35,15 @@ impl std::fmt::Display for BuildError {
|
||||||
|
|
||||||
impl std::error::Error for BuildError {}
|
impl std::error::Error for BuildError {}
|
||||||
|
|
||||||
|
// Filter out all arguments, which start with "-"
|
||||||
|
fn get_packages() -> Vec<String> {
|
||||||
|
let mut args = env::args();
|
||||||
|
args.nth(1);
|
||||||
|
args.filter(|x| !x.starts_with("-")).collect()
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
generate_version(); // really brute force way to try and get a version into the build system.
|
generate_version(env::args().filter(|x| x == "--no-timestamp").count() == 0); // really brute force way to try and get a version into the build system.
|
||||||
|
|
||||||
let hw_pkgs = [
|
let hw_pkgs = [
|
||||||
// core OS services
|
// core OS services
|
||||||
|
|
@ -163,7 +170,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let lkey = args.nth(3);
|
let lkey = args.nth(3);
|
||||||
let kkey = args.nth(4);
|
let kkey = args.nth(4);
|
||||||
match task.as_deref() {
|
match task.as_deref() {
|
||||||
Some("install-toolkit") => {
|
Some("install-toolkit") | Some("install-toolchain") => {
|
||||||
let arg = env::args().nth(2);
|
let arg = env::args().nth(2);
|
||||||
ensure_compiler(
|
ensure_compiler(
|
||||||
&Some(PROGRAM_TARGET),
|
&Some(PROGRAM_TARGET),
|
||||||
|
|
@ -175,7 +182,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
let mut apps: Vec<String> = args.collect();
|
let mut apps: Vec<String> = get_packages();
|
||||||
if apps.len() == 0 {
|
if apps.len() == 0 {
|
||||||
// add the standard demo apps if none are specified
|
// add the standard demo apps if none are specified
|
||||||
println!("No apps specified, adding default apps...");
|
println!("No apps specified, adding default apps...");
|
||||||
|
|
@ -192,7 +199,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
let mut apps: Vec<String> = args.collect();
|
let mut apps: Vec<String> = get_packages();
|
||||||
if apps.len() == 0 {
|
if apps.len() == 0 {
|
||||||
// add the standard demo apps if none are specified
|
// add the standard demo apps if none are specified
|
||||||
println!("No apps specified, adding default apps...");
|
println!("No apps specified, adding default apps...");
|
||||||
|
|
@ -255,7 +262,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
//let mut pkgs = gfx_dev_pkgs.to_vec();
|
//let mut pkgs = gfx_dev_pkgs.to_vec();
|
||||||
let apps: Vec<String> = args.collect();
|
let apps: Vec<String> = get_packages();
|
||||||
for app in &apps {
|
for app in &apps {
|
||||||
pkgs.push(app);
|
pkgs.push(app);
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +293,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let pkgs = base_pkgs.to_vec();
|
let pkgs = base_pkgs.to_vec();
|
||||||
let args: Vec<String> = args.collect();
|
let args: Vec<String> = get_packages();
|
||||||
let mut extra_packages = vec![];
|
let mut extra_packages = vec![];
|
||||||
for program in &args {
|
for program in &args {
|
||||||
extra_packages.push(program.as_str());
|
extra_packages.push(program.as_str());
|
||||||
|
|
@ -305,7 +312,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
//let mut pkgs = hw_pkgs.to_vec();
|
//let mut pkgs = hw_pkgs.to_vec();
|
||||||
let mut pkgs = gfx_dev_pkgs.to_vec();
|
let mut pkgs = gfx_dev_pkgs.to_vec();
|
||||||
pkgs.push("ffi-test");
|
pkgs.push("ffi-test");
|
||||||
let args: Vec<String> = args.collect();
|
let args: Vec<String> = get_packages();
|
||||||
let mut extra_packages = vec![];
|
let mut extra_packages = vec![];
|
||||||
for program in &args {
|
for program in &args {
|
||||||
extra_packages.push(program.as_str());
|
extra_packages.push(program.as_str());
|
||||||
|
|
@ -331,7 +338,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
pkgs.push("com");
|
pkgs.push("com");
|
||||||
pkgs.push("llio");
|
pkgs.push("llio");
|
||||||
pkgs.push("dns");
|
pkgs.push("dns");
|
||||||
let args: Vec<String> = args.collect();
|
let args: Vec<String> = get_packages();
|
||||||
let mut extra_packages = vec![];
|
let mut extra_packages = vec![];
|
||||||
for program in &args {
|
for program in &args {
|
||||||
extra_packages.push(program.as_str());
|
extra_packages.push(program.as_str());
|
||||||
|
|
@ -365,7 +372,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
let mut apps: Vec<String> = args.collect();
|
let mut apps: Vec<String> = get_packages();
|
||||||
if apps.len() == 0 {
|
if apps.len() == 0 {
|
||||||
// add the standard demo apps if none are specified
|
// add the standard demo apps if none are specified
|
||||||
println!("No apps specified, adding default apps...");
|
println!("No apps specified, adding default apps...");
|
||||||
|
|
@ -381,7 +388,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
}
|
||||||
Some("hosted-ci") => {
|
Some("hosted-ci") => {
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
let mut apps: Vec<String> = args.collect();
|
let mut apps: Vec<String> = get_packages();
|
||||||
apps.push("ball".to_string());
|
apps.push("ball".to_string());
|
||||||
apps.push("repl".to_string());
|
apps.push("repl".to_string());
|
||||||
for app in &apps {
|
for app in &apps {
|
||||||
|
|
@ -394,7 +401,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
let mut apps: Vec<String> = args.collect();
|
let mut apps: Vec<String> = get_packages();
|
||||||
if apps.len() == 0 {
|
if apps.len() == 0 {
|
||||||
// add the standard demo apps if none are specified
|
// add the standard demo apps if none are specified
|
||||||
println!("No apps specified, adding default apps...");
|
println!("No apps specified, adding default apps...");
|
||||||
|
|
@ -411,7 +418,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut args = env::args();
|
let mut args = env::args();
|
||||||
args.nth(1);
|
args.nth(1);
|
||||||
let mut pkgs = hw_pkgs.to_vec();
|
let mut pkgs = hw_pkgs.to_vec();
|
||||||
let apps: Vec<String> = args.collect();
|
let apps = get_packages();
|
||||||
for app in &apps {
|
for app in &apps {
|
||||||
pkgs.push(app);
|
pkgs.push(app);
|
||||||
}
|
}
|
||||||
|
|
@ -604,6 +611,8 @@ Various debug configurations:
|
||||||
ffi-test builds an image for testing C-FFI bindings and integration
|
ffi-test builds an image for testing C-FFI bindings and integration
|
||||||
tts builds an image with text to speech support via externally linked C executable
|
tts builds an image with text to speech support via externally linked C executable
|
||||||
install-toolkit installs Xous toolkit with no prompt, useful in CI. Specify `--force` to remove existing toolchains
|
install-toolkit installs Xous toolkit with no prompt, useful in CI. Specify `--force` to remove existing toolchains
|
||||||
|
|
||||||
|
Note: By default, the `ticktimer` will get rebuilt every time. You can skip this by appending `--no-timestamp` to the command.
|
||||||
"
|
"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -990,6 +999,11 @@ fn run(
|
||||||
|
|
||||||
if !dry_run {
|
if !dry_run {
|
||||||
println!("Building and running kernel...");
|
println!("Building and running kernel...");
|
||||||
|
print!(" Command: cargo");
|
||||||
|
for arg in &args {
|
||||||
|
print!(" {}", arg);
|
||||||
|
}
|
||||||
|
println!();
|
||||||
let status = Command::new(cargo())
|
let status = Command::new(cargo())
|
||||||
.current_dir(dir)
|
.current_dir(dir)
|
||||||
.args(&args)
|
.args(&args)
|
||||||
|
|
@ -1496,7 +1510,7 @@ fn whycheproof_import() -> Result<(), DynError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////// Versioning infrastructure
|
////////////////////////// Versioning infrastructure
|
||||||
fn generate_version() {
|
fn generate_version(add_timestamp: bool) {
|
||||||
let output = if cfg!(target_os = "windows") {
|
let output = if cfg!(target_os = "windows") {
|
||||||
Command::new("cmd")
|
Command::new("cmd")
|
||||||
.args(["/C", "git describe --tags"])
|
.args(["/C", "git describe --tags"])
|
||||||
|
|
@ -1512,25 +1526,33 @@ fn generate_version() {
|
||||||
let gitver = output.stdout;
|
let gitver = output.stdout;
|
||||||
let semver = String::from_utf8_lossy(&gitver);
|
let semver = String::from_utf8_lossy(&gitver);
|
||||||
|
|
||||||
let mut vfile = OpenOptions::new()
|
let version_file = "services/ticktimer-server/src/version.rs";
|
||||||
.read(true)
|
|
||||||
.write(true)
|
// Read the existing file to see if it needs to be updated.
|
||||||
.create(true)
|
let mut existing_data = Vec::new();
|
||||||
.truncate(true)
|
if let Ok(mut f) = std::fs::File::open(version_file) {
|
||||||
.open("services/ticktimer-server/src/version.rs")
|
f.read_to_end(&mut existing_data).ok();
|
||||||
.expect("Can't open our version file for writing");
|
}
|
||||||
print_header(&mut vfile);
|
|
||||||
#[cfg(not(feature = "no-timestamp"))]
|
let mut new_data = Vec::new();
|
||||||
let now = Local::now();
|
print_header(&mut new_data);
|
||||||
#[cfg(not(feature = "no-timestamp"))]
|
if add_timestamp {
|
||||||
|
let now = Local::now();
|
||||||
|
write!(
|
||||||
|
new_data,
|
||||||
|
"#[allow(dead_code)]\npub const TIMESTAMP: &'static str = \"{}\";\n",
|
||||||
|
now.to_rfc2822()
|
||||||
|
)
|
||||||
|
.expect("couldn't add our timestamp");
|
||||||
|
} else {
|
||||||
|
write!(
|
||||||
|
new_data,
|
||||||
|
"#[allow(dead_code)]\npub const TIMESTAMP: &'static str = \"unavailable\";\n"
|
||||||
|
)
|
||||||
|
.expect("couldn't add our timestamp");
|
||||||
|
}
|
||||||
write!(
|
write!(
|
||||||
vfile,
|
new_data,
|
||||||
"#[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",
|
"pub const SEMVER: &'static str = \"{}\";\n",
|
||||||
semver
|
semver
|
||||||
.strip_suffix("\r\n")
|
.strip_suffix("\r\n")
|
||||||
|
|
@ -1538,6 +1560,19 @@ fn generate_version() {
|
||||||
.unwrap_or(&semver)
|
.unwrap_or(&semver)
|
||||||
)
|
)
|
||||||
.expect("couldn't add our semver");
|
.expect("couldn't add our semver");
|
||||||
|
|
||||||
|
if existing_data != new_data {
|
||||||
|
let mut vfile = OpenOptions::new()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(version_file)
|
||||||
|
.expect("Can't open our version file for writing");
|
||||||
|
vfile
|
||||||
|
.write_all(&mut new_data)
|
||||||
|
.expect("couldn't write new timestamp to version.rs");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_header<U: Write>(out: &mut U) {
|
fn print_header<U: Write>(out: &mut U) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue