Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(sys): early return if probe failed
  • Loading branch information
weihanglo committed Dec 22, 2025
commit d9a1e8b4220a3d71b47d608f2bfe1874d104d8f7
18 changes: 10 additions & 8 deletions libgit2-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ use std::process::Command;
/// Tries to use system libgit2 and emits necessary build script instructions.
fn try_system_libgit2() -> Result<pkg_config::Library, pkg_config::Error> {
let mut cfg = pkg_config::Config::new();
match cfg.range_version("1.9.2".."1.10.0").probe("libgit2") {
Ok(lib) => {
for include in &lib.include_paths {
println!("cargo:root={}", include.display());
}
Ok(lib)
}
let range_version = "1.9.2".."1.10.0";

let lib = match cfg.range_version(range_version).probe("libgit2") {
Ok(lib) => lib,
Err(e) => {
println!("cargo:warning=failed to probe system libgit2: {e}");
Err(e)
return Err(e);
}
};

for include in &lib.include_paths {
println!("cargo:root={}", include.display());
}
Ok(lib)
}

fn main() {
Expand Down