mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
fix SVD spec toggle trigger
this fix makes it so that 1) you always get a correct build when the SVD spec is toggled 2) you don't always rebuild when nothing has changed (2) is with the caveat that the no-change flag is only clean after your second build (i.e. your third run will be fast). I'm not quite sure why but I think it's because the "changes" to the config file tracker are computed throughout the first build and the second build still sees that file as recently changed, so, it'll trigger a rebuild (could also just be a race condition because the timestamp of the rebuild is at the same second that the file was regenerated, so conservatively you'd rebuild the next time).
This commit is contained in:
parent
ecab0ba045
commit
3a6f69a4ad
3 changed files with 57 additions and 4 deletions
15
utralib/Cargo.lock
generated
15
utralib/Cargo.lock
generated
|
|
@ -1,5 +1,7 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ansi_term"
|
name = "ansi_term"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
|
|
@ -11,9 +13,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.33"
|
version = "1.0.65"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
|
checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atty"
|
name = "atty"
|
||||||
|
|
@ -47,6 +49,12 @@ dependencies = [
|
||||||
"vec_map",
|
"vec_map",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "convert_case"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.17"
|
version = "0.1.17"
|
||||||
|
|
@ -86,9 +94,12 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "svd2utra"
|
name = "svd2utra"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d43b83067e415e08dc4c31f88f58b0445a5ff18d3bc8e73e75900205db968ea"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
"convert_case",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,18 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
fn out_dir() -> PathBuf {
|
||||||
|
PathBuf::from(env::var_os("OUT_DIR").unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(feature="precursor-c809403")]
|
#[cfg(feature="precursor-c809403")]
|
||||||
let svd_filename = "precursor/soc-c809403.svd";
|
let svd_filename = "precursor/soc-c809403.svd";
|
||||||
#[cfg(feature="precursor-c809403-perflib")]
|
#[cfg(feature="precursor-c809403-perflib")]
|
||||||
let svd_filename = "precursor/soc-perf-c809403.svd";
|
let svd_filename = "precursor/soc-perf-c809403.svd";
|
||||||
|
|
||||||
|
let last_config = out_dir().join("../../LAST_CONFIG");
|
||||||
|
println!("cargo:rerun-if-changed={}", last_config.canonicalize().unwrap().display());
|
||||||
let svd_file_path = std::path::Path::new(&svd_filename);
|
let svd_file_path = std::path::Path::new(&svd_filename);
|
||||||
println!("cargo:rerun-if-changed={}", svd_file_path.canonicalize().unwrap().display());
|
println!("cargo:rerun-if-changed={}", svd_file_path.canonicalize().unwrap().display());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -786,20 +786,55 @@ fn build_hw_image(
|
||||||
loader_features: Option<&[&str]>,
|
loader_features: Option<&[&str]>,
|
||||||
kernel_features: Option<&[&str]>,
|
kernel_features: Option<&[&str]>,
|
||||||
) -> Result<(), DynError> {
|
) -> Result<(), DynError> {
|
||||||
|
// ------ configure UTRA generation feature flags ------
|
||||||
let mut svd_feat = vec!["--features"];
|
let mut svd_feat = vec!["--features"];
|
||||||
let mut svd_path = String::from("utralib/");
|
let mut svd_path = String::from("utralib/");
|
||||||
|
let svd_filename: String;
|
||||||
let svd_file: Option<&[&str]> = match svd {
|
let svd_file: Option<&[&str]> = match svd {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
svd_path.push_str(&s);
|
svd_path.push_str(&s);
|
||||||
|
svd_filename = s.to_string();
|
||||||
svd_feat.push(&svd_path);
|
svd_feat.push(&svd_path);
|
||||||
Some(&svd_feat)
|
Some(&svd_feat)
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
svd_path.push_str(SOC_SVD_VERSION);
|
svd_path.push_str(SOC_SVD_VERSION);
|
||||||
|
svd_filename = SOC_SVD_VERSION.to_string();
|
||||||
svd_feat.push(&svd_path);
|
svd_feat.push(&svd_path);
|
||||||
Some(&svd_feat)
|
Some(&svd_feat)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// LAST_CONFIG tracks the last SVD configuration. It's used by utralib to track if it
|
||||||
|
// should rebuild itself based on a change in SVD configs. Note that for some reason
|
||||||
|
// it takes two consecutive builds with the same SVD config before the build system
|
||||||
|
// figures out that it doesn't need to rebuild everything. After then, it behaves as expected.
|
||||||
|
let stream = if debug { "debug" } else { "release" };
|
||||||
|
let last_config = format!("target/{}/{}/build/LAST_CONFIG", PROGRAM_TARGET, stream);
|
||||||
|
let changed = match OpenOptions::new()
|
||||||
|
.read(true)
|
||||||
|
.open(&last_config) {
|
||||||
|
Ok(mut file) => {
|
||||||
|
let mut contents = String::new();
|
||||||
|
file.read_to_string(&mut contents).unwrap();
|
||||||
|
if contents != svd_filename {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => true
|
||||||
|
};
|
||||||
|
if changed {
|
||||||
|
let mut file = OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(&last_config).unwrap();
|
||||||
|
write!(file, "{}", svd_filename).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
// concatenate the passed in feature flags with the computed utra feature flags
|
||||||
let mut kernel_features_finalized = Vec::<&str>::new();
|
let mut kernel_features_finalized = Vec::<&str>::new();
|
||||||
let mut loader_features_finalized = Vec::<&str>::new();
|
let mut loader_features_finalized = Vec::<&str>::new();
|
||||||
if let Some(svd) = svd_file {
|
if let Some(svd) = svd_file {
|
||||||
|
|
@ -826,7 +861,6 @@ fn build_hw_image(
|
||||||
let kernelkey_file = kkey.unwrap_or_else(|| "devkey/dev.key".into());
|
let kernelkey_file = kkey.unwrap_or_else(|| "devkey/dev.key".into());
|
||||||
|
|
||||||
// ------ build the kernel ------
|
// ------ build the kernel ------
|
||||||
println!("kernel_features_finalized: {:?}", kernel_features_finalized);
|
|
||||||
let kernel = build_kernel(debug, Some(&kernel_features_finalized))?;
|
let kernel = build_kernel(debug, Some(&kernel_features_finalized))?;
|
||||||
|
|
||||||
// ------ build the services ------
|
// ------ build the services ------
|
||||||
|
|
@ -870,7 +904,6 @@ fn build_hw_image(
|
||||||
// these settings will generate the most compact code (but also the hardest to debug)
|
// these settings will generate the most compact code (but also the hardest to debug)
|
||||||
std::env::set_var("CARGO_PROFILE_RELEASE_LTO", "true");
|
std::env::set_var("CARGO_PROFILE_RELEASE_LTO", "true");
|
||||||
std::env::set_var("CARGO_PROFILE_RELEASE_CODEGEN_UNITS", "1");
|
std::env::set_var("CARGO_PROFILE_RELEASE_CODEGEN_UNITS", "1");
|
||||||
println!("loader_features_finalized: {:?}", loader_features_finalized);
|
|
||||||
let mut loader = build(
|
let mut loader = build(
|
||||||
&["loader"],
|
&["loader"],
|
||||||
debug,
|
debug,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue