Skip to content

Commit

Permalink
Apply light cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee committed Nov 15, 2023
1 parent 6f1a12c commit 044c1fd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pgrx-pg-sys/build/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ pub(crate) fn detect_include_paths_for(
clang_sys::get_library().expect("libclang should have been loaded?").path().to_owned();
eprintln!("found libclang at {}", libclang_path.display());
// libclang will probably be in a dynamic library directory,
// which means it will probably be adjacent to its headers
// which means it will probably be adjacent to its headers, e.g.
// - "/usr/lib/libclang-${CLANG_MAJOR}.so.${CLANG_MAJOR}.${CLANG_MINOR}"
// - "/usr/lib/clang/${CLANG_MAJOR}/include"
let clang_major_fmt = clang_major.to_string();
let mut paths = vec![];
let mut libclang_ancestors = libclang_path.ancestors();
while let Some(ancestor) = libclang_ancestors.next() {
// by adjacent, that does not mean it is always immediately so, e.g.
// - "/usr/lib/x86_64-linux-gnu/libclang-${CLANG_MAJOR}.so.${CLANG_MAJOR}.${CLANG_MINOR}.${CLANG_SUBMINOR}"
// - "/usr/lib/clang/${CLANG_MAJOR}/include"
// so, crawl back up the ancestral tree
for ancestor in libclang_path.ancestors() {
paths = WalkDir::new(ancestor)
.min_depth(1)
.max_depth(6)
Expand Down Expand Up @@ -92,6 +97,7 @@ pub(crate) fn detect_include_paths_for(
}
})
.collect::<Vec<_>>();

if paths.len() > 0 {
paths.sort();
paths.dedup();
Expand Down

0 comments on commit 044c1fd

Please sign in to comment.