From cde56555d43a55ddb6890bad9d3141ee3319a219 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 17 Jul 2023 15:14:33 +0800 Subject: [PATCH] Pull utralib and svd2utra from local repo; downgrade crates.io check In order to reduce friction of bringing on new platforms and experimenting in utralib and svd2utra, xous-core now by default pulls these libraries from the local repository. Differences between the local version and the published version for just these two packages are now downgraded to warnings, instead of hard errors. This is because a difference does not indicate that crates.io has had a modification we didn't expect; it simply means we forgot to publish the package and we should eventually do so once we have stabilized changes, so that others who rely upon it can have the updated version. But, with this patch, at least if we are experimenting with utralib or svd2utra we don't have to publish a patch to bump revisions on every major package every single time for a build to succeed. I think this is an OK trade-off, but happy to roll this decision back if it affects @eupn / @jeandudey negatively. --- Cargo.lock | 17 +++-------------- Cargo.toml | 8 ++++---- xtask/src/verifier.rs | 19 ++++++++++++++++--- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b0390ba2..93cf73cbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4129,15 +4129,6 @@ dependencies = [ "quick-xml", ] -[[package]] -name = "svd2utra" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba87b81de81a553ec5904993a676aa29d1583a4f6ab96e03f8b44e4d6c05a61" -dependencies = [ - "quick-xml", -] - [[package]] name = "syn" version = "1.0.103" @@ -4378,7 +4369,7 @@ dependencies = [ "log", "pem", "ring", - "svd2utra 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "svd2utra", "xmas-elf", "xous-semver", ] @@ -4849,10 +4840,8 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "utralib" version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e69095d8616b8ff89850fb3693710ceab2923b4d094844c701ca5141563683" dependencies = [ - "svd2utra 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "svd2utra", ] [[package]] @@ -5616,7 +5605,7 @@ dependencies = [ "rustc_version 0.4.0", "serde", "serde_json", - "svd2utra 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", + "svd2utra", "tempfile", "ureq", "zip", diff --git a/Cargo.toml b/Cargo.toml index 4560c8357..73fb63706 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -166,10 +166,10 @@ rev="4296c2e7904898766cf7d8d589759a129794783b" # use the commitref because we're ####################################################### ### Selectively patch in these crates, or more, as needed depending on your dev activity -# [patch.crates-io.utralib] -# path = "./utralib" -# [patch.crates-io.svd2utra] -# path = "./svd2utra" +[patch.crates-io.utralib] +path = "./utralib" +[patch.crates-io.svd2utra] +path = "./svd2utra" # [patch.crates-io.xous] # path = "./xous-rs" # [patch.crates-io.xous-ipc] diff --git a/xtask/src/verifier.rs b/xtask/src/verifier.rs index 6ce460aa6..8fbe847da 100644 --- a/xtask/src/verifier.rs +++ b/xtask/src/verifier.rs @@ -18,17 +18,25 @@ pub fn check_project_consistency() -> Result<(), DynError> { "xous-api-names@0.9.45", "xous-api-susres@0.9.43", "xous-api-ticktimer@0.9.43", + ]; + // utra/svd2utra changes are downgraded to warnings because these now prefer to pull + // from the local patch version, so any inconsistency simply indicates we forgot to + // publish the packages, rather than something nefarious has happened. + let warn_pkgs = [ // this set is only updated if the utralib changes "utralib@0.1.20", "svd2utra@0.1.18", ]; for pkg in check_pkgs { - verify(pkg.into())?; + verify(pkg.into(), true)?; + } + for pkg in warn_pkgs { + verify(pkg.into(), false)?; } Ok(()) } -pub fn verify(spec: CrateSpec) -> Result<(), DynError> { +pub fn verify(spec: CrateSpec, hard_failure: bool) -> Result<(), DynError> { if let CrateSpec::CratesIo(name, version, _xip) = spec { let mut cache_path = Path::new(&env::var("CARGO_HOME").unwrap()).to_path_buf(); cache_path.push("registry"); @@ -86,7 +94,12 @@ pub fn verify(spec: CrateSpec) -> Result<(), DynError> { println!("Comparing {} <-> {}", src_path.as_os_str().to_str().unwrap(), cache_path.as_os_str().to_str().unwrap()); match compare_dirs(src_path, &cache_path) { Ok(true) => Ok(()), - Ok(false) => Err("Crates.io downloaded data does not match local source".into()), + Ok(false) => if hard_failure { + Err("Crates.io downloaded data does not match local source".into())} + else { + println!("**WARNING**: Local package does not match the published source. Third parties downloading from crates.io will be inconsistent with this build."); + Ok(()) + }, _ => Err("Error matching local source to crates.io cache files".into()), } } else {