Skip to content

Commit c2c5434

Browse files
committed
modifying build.rs
1 parent 872561e commit c2c5434

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

build.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ fn main() {
6161

6262
struct FromPkgConfig {
6363
name: String,
64+
65+
#[allow(unused)]
6466
atleast_version: String,
6567
}
6668

@@ -83,20 +85,23 @@ fn find_library(from_pkg_config: FromPkgConfig, from_env: FromEnv) -> Result<Vec
8385

8486
#[cfg(not(target_os = "windows"))]
8587
fn find_library_internal(from_pkg_config: &FromPkgConfig) -> Result<Vec<PathBuf>, String> {
86-
match pkg_config::Config::new()
88+
let name = from_pkg_config.name.as_str();
89+
90+
let library = pkg_config::Config::new()
8791
.atleast_version(from_pkg_config.atleast_version.as_str())
88-
.probe(from_pkg_config.name.as_str()) {
89-
Ok(lib) => Ok(lib.include_paths),
90-
Err(e) => {
91-
Err(format!("Failed to find library from pkg_config: {}", e))
92-
}
93-
}
92+
.probe(name)
93+
.map_err(|e| format!("Failed to find library '{}' from pkg_config: {}", name, e))?;
94+
95+
Ok(library.include_paths)
9496
}
9597

98+
9699
#[cfg(target_os = "windows")]
97100
fn find_library_internal(from_pkg_config: &FromPkgConfig) -> Result<Vec<PathBuf>, String> {
98-
let library = vcpkg::find_package(from_pkg_config.name.as_str())
99-
.map_err(|e| Err(String::from(format!("can't find library '{}' using vcpkg", from_pkg_config.name.as_str()))))?;
101+
let name = from_pkg_config.name.as_str();
102+
103+
let library = vcpkg::find_package(name)
104+
.map_err(|e| format!("Failed to find library '{}' from pkg_config: {}", name, e))?;
100105

101106
Ok(library.include_paths)
102107
}

0 commit comments

Comments
 (0)