(zilch lang rust): recursively resolve pkg-config paths
This commit is contained in:
parent
de31b96fc8
commit
1a0fbbe7c7
1 changed files with 46 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use std::{
|
||||
collections::HashMap,
|
||||
env::{var, var_os},
|
||||
fs::{File, create_dir},
|
||||
fs::{File, create_dir, exists, read_to_string},
|
||||
io::{Read, Write},
|
||||
os::unix::process::CommandExt,
|
||||
process::Command,
|
||||
|
|
@ -73,5 +73,49 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
panic!("failed to exec: {:?}", cmd.exec())
|
||||
let mut pkg_config_path = Vec::new();
|
||||
if let Ok(paths) = var("_zilch_pkgconfig") {
|
||||
if !paths.is_empty() {
|
||||
let mut paths_to_check = Vec::new();
|
||||
for path in paths.split(':') {
|
||||
paths_to_check.push(path.to_string());
|
||||
}
|
||||
|
||||
while let Some(path) = paths_to_check.pop() {
|
||||
let pkgconfig_path = format!("{}/lib/pkgconfig", path);
|
||||
if exists(&pkgconfig_path).ok() == Some(true)
|
||||
&& !pkg_config_path.contains(&pkgconfig_path)
|
||||
{
|
||||
pkg_config_path.push(pkgconfig_path);
|
||||
}
|
||||
|
||||
let pkgconfig_path = format!("{}/share/pkgconfig", path);
|
||||
if exists(&pkgconfig_path).ok() == Some(true)
|
||||
&& !pkg_config_path.contains(&pkgconfig_path)
|
||||
{
|
||||
pkg_config_path.push(pkgconfig_path);
|
||||
}
|
||||
|
||||
if let Ok(file) =
|
||||
read_to_string(format!("{}/nix-support/propagated-build-inputs", path))
|
||||
{
|
||||
for path in file.split(' ') {
|
||||
if !path.is_empty() {
|
||||
paths_to_check.push(path.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmd.env("PKG_CONFIG_PATH", pkg_config_path.join(":"));
|
||||
let status = cmd.status().unwrap();
|
||||
|
||||
if !status.success() {
|
||||
panic!(
|
||||
"Failed to execute.\nstdout: {}",
|
||||
std::fs::read_to_string(var_os("out").unwrap()).unwrap()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue