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.
This commit is contained in:
bunnie 2023-07-17 15:14:33 +08:00
parent e6463eaac9
commit cde56555d4
3 changed files with 23 additions and 21 deletions

17
Cargo.lock generated
View file

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

View file

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

View file

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