Skip to content

Commit

Permalink
Avoid printing duplicate messages for missing packages
Browse files Browse the repository at this point in the history
If a crate is missing, we print that it is so. But then we would also
print out the same as "resolved from an upstream source" which is not
relevant when the dependency is missing.

So just print one message or the other.

R=collinbaker@chromium.org

Bug: 1291994
Change-Id: Icad340cd4036e05966dfff1ad3dad668c9c78cd6
Cq-Include-Trybots: luci.chromium.try:android-rust-arm-dbg,android-rust-arm-rel,linux-rust-x64-dbg,linux-rust-x64-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3914568
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: Collin Baker <collinbaker@google.com>
Cr-Commit-Position: refs/heads/main@{#1050737}
  • Loading branch information
danakj authored and Chromium LUCI CQ committed Sep 23, 2022
1 parent 7e792b3 commit c53e2f8
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions tools/crates/gnrt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ fn generate_for_third_party(args: &clap::ArgMatches, paths: &paths::ChromiumPath
for edge in dep.dependency_path.iter() {
println!(" {edge}");
}
} else if !dep.is_local {
// Transitive deps may be requested with version requirements stricter than
// ours: e.g. 1.57 instead of just major version 1. If the version we have
// checked in, e.g. 1.56, has the same epoch but doesn't meet the version
// requirement, the symptom is Cargo will resolve the dependency to an
// upstream source instead of our local path. We must detect this case to
// ensure correctness.
has_error = true;
println!(
"Resolved {} {} to an upstream source. The requested version \
likely has the same epoch as the discovered crate but \
something has a more stringent version requirement.",
dep.package_name, dep.version
);
println!(" Resolved version: {}", dep.version);
}
}

Expand All @@ -167,23 +182,6 @@ fn generate_for_third_party(args: &clap::ArgMatches, paths: &paths::ChromiumPath
}
}

// Transitive deps may be requested with version requirements stricter than
// ours: e.g. 1.57 instead of just major version 1. If the version we have
// checked in, e.g. 1.56, has the same epoch but doesn't meet the version
// requirement, the symptom is Cargo will resolve the dependency to an
// upstream source instead of our local path. We must detect this case to
// ensure correctness.
for nonlocal_dep in dependencies.iter().filter(|dep| !dep.is_local) {
has_error = true;
println!(
"Resolved {} {} to an upstream source. The requested version \
likely has the same epoch as the discovered crate but \
something has a more stringent version requirement.",
nonlocal_dep.package_name, nonlocal_dep.version
);
println!(" Resolved version: {}", nonlocal_dep.version);
}

if has_error {
return ExitCode::FAILURE;
}
Expand Down Expand Up @@ -272,7 +270,6 @@ fn generate_for_std(_args: &clap::ArgMatches, paths: &paths::ChromiumPaths) -> E
// dependencies point to our Rust source package. Build rules will be
// generated for these crates separately from std, alloc, and core which
// need special treatment.
let mut req_crates = HashSet::<&StdVendoredCrate>::new();
let src_prefix = paths.root.join(paths.rust_src);
for dep in &dependencies {
// Skip workspace members. They are not third-party deps in this
Expand Down

0 comments on commit c53e2f8

Please sign in to comment.