fn search_libclang_directories(runtime: bool) -> Result<Vec<(PathBuf, String, Vec<u32>)>, String> {
    let mut files = vec![format!(
        "{}clang{}",
        env::consts::DLL_PREFIX,
        env::consts::DLL_SUFFIX
    )];

    if cfg!(target_os = "linux") {
        // Some Linux distributions don't create a `libclang.so` symlink, so we
        // need to look for versioned files (e.g., `libclang-3.9.so`).
        files.push("libclang-*.so".into());

        // Some Linux distributions don't create a `libclang.so` symlink and
        // don't have versioned files as described above, so we need to look for
        // suffix versioned files (e.g., `libclang.so.1`). However, `ld` cannot
        // link to these files, so this will only be included when linking at
        // runtime.
        if runtime {
            files.push("libclang.so.*".into());
            files.push("libclang-*.so.*".into());
        }
    }

    if cfg!(any(
        target_os = "freebsd",
        target_os = "haiku",
        target_os = "netbsd",
        target_os = "openbsd",
    )) {
        // Some BSD distributions don't create a `libclang.so` symlink either,
        // but use a different naming scheme for versioned files (e.g.,
        // `libclang.so.7.0`).
        files.push("libclang.so.*".into());
    }

    if cfg!(target_os = "windows") {
        // The official LLVM build uses `libclang.dll` on Windows instead of
        // `clang.dll`. However, unofficial builds such as MinGW use `clang.dll`.
        files.push("libclang.dll".into());
    }

    // Find and validate `libclang` shared libraries and collect the versions.
    let mut valid = vec![];
    let mut invalid = vec![];
    for (directory, filename) in common::search_libclang_directories(&files, "LIBCLANG_PATH") {
        let path = directory.join(&filename);
        match validate_library(&path) {
            Ok(()) => {
                let version = parse_version(&filename);
                valid.push((directory, filename, version))
            }
            Err(message) => invalid.push(format!("({}: {})", path.display(), message)),
        }
    }

    if !valid.is_empty() {
        return Ok(valid);
    }

    let message = format!(
        "couldn't find any valid shared libraries matching: [{}], set the \
         `LIBCLANG_PATH` environment variable to a path where one of these files \
         can be found (invalid: [{}])",
        files
            .iter()
            .map(|f| format!("'{}'", f))
            .collect::<Vec<_>>()
            .join(", "),
        invalid.join(", "),
    );

    Err(message)
}
/// Finds `libclang` shared libraries and returns the paths to, filenames of,
/// and versions of those shared libraries.

Finds `libclang` shared libraries and returns the paths to, filenames of,
and versions of those shared libraries.
Finds ` libclang ` shared libraries and returns the paths to filenames of and versions of those shared libraries .
fn search_libclang_directories(runtime: bool) -> Result<Vec<(PathBuf, String, Vec<u32>)>, String> {
    let mut files = vec![format!(
        "{}clang{}",
        env::consts::DLL_PREFIX,
        env::consts::DLL_SUFFIX
    )];
    if cfg!(target_os = "linux") {
        // Some Linux distributions don't create a `libclang.so` symlink, so we
        // need to look for versioned files (e.g., `libclang-3.9.so`).
        files.push("libclang-*.so".into());
        // Some Linux distributions don't create a `libclang.so` symlink and
        // don't have versioned files as described above, so we need to look for
        // suffix versioned files (e.g., `libclang.so.1`). However, `ld` cannot
        // link to these files, so this will only be included when linking at
        // runtime.
        if runtime {
            files.push("libclang.so.*".into());
            files.push("libclang-*.so.*".into());
        }
    }
    if cfg!(any(
        target_os = "freebsd",
        target_os = "haiku",
        target_os = "netbsd",
        target_os = "openbsd",
    )) {
        // Some BSD distributions don't create a `libclang.so` symlink either,
        // but use a different naming scheme for versioned files (e.g.,
        // `libclang.so.7.0`).
        files.push("libclang.so.*".into());
    }
    if cfg!(target_os = "windows") {
        // The official LLVM build uses `libclang.dll` on Windows instead of
        // `clang.dll`. However, unofficial builds such as MinGW use `clang.dll`.
        files.push("libclang.dll".into());
    }
    // Find and validate `libclang` shared libraries and collect the versions.
    let mut valid = vec![];
    let mut invalid = vec![];
    for (directory, filename) in common::search_libclang_directories(&files, "LIBCLANG_PATH") {
        let path = directory.join(&filename);
        match validate_library(&path) {
            Ok(()) => {
                let version = parse_version(&filename);
                valid.push((directory, filename, version))
            }
            Err(message) => invalid.push(format!("({}: {})", path.display(), message)),
        }
    }
    if !valid.is_empty() {
        return Ok(valid);
    }
    let message = format!(
        "couldn't find any valid shared libraries matching: [{}], set the \
         `LIBCLANG_PATH` environment variable to a path where one of these files \
         can be found (invalid: [{}])",
        files
            .iter()
            .map(|f| format!("'{}'", f))
            .collect::<Vec<_>>()
            .join(", "),
        invalid.join(", "),
    );
    Err(message)
}
fn search_libclang_directories ( runtime : bool ) -> Result < Vec < ( PathBuf , String , Vec < u32 > ) > , String > { let mut files = vec ! [ format ( " " env consts DLL_PREFIX env consts DLL_SUFFIX ) ] ; if cfg ! ( target_os " " ) { // Some Linux distributions don't create a `libclang.so` symlink, so we
 // need to look for versioned files (e.g., `libclang-3.9.so`).
 files . push ( " " . into ( ) ) ; // Some Linux distributions don't create a `libclang.so` symlink and
 // don't have versioned files as described above, so we need to look for
 // suffix versioned files (e.g., `libclang.so.1`). However, `ld` cannot
 // link to these files, so this will only be included when linking at
 // runtime.
 if runtime { files . push ( " " . into ( ) ) ; files . push ( " " . into ( ) ) ; } } if cfg ! ( any ( target_os " " target_os " " target_os " " target_os " " ) ) { // Some BSD distributions don't create a `libclang.so` symlink either,
 // but use a different naming scheme for versioned files (e.g.,
 // `libclang.so.7.0`).
 files . push ( " " . into ( ) ) ; } if cfg ! ( target_os " " ) { // The official LLVM build uses `libclang.dll` on Windows instead of
 // `clang.dll`. However, unofficial builds such as MinGW use `clang.dll`.
 files . push ( " " . into ( ) ) ; } // Find and validate `libclang` shared libraries and collect the versions.
 let mut valid = vec ! [ ] ; let mut invalid = vec ! [ ] ; for ( directory , filename ) in common :: search_libclang_directories ( & files , " " ) { let path = directory . join ( & filename ) ; match validate_library ( & path ) { Ok ( ( ) ) => { let version = parse_version ( & filename ) ; valid . push ( ( directory , filename , version ) ) } Err ( message ) => invalid . push ( format ! ( " " path display ( ) message ) ) , } } if ! valid . is_empty ( ) { return Ok ( valid ) ; } let message = format ! ( " \
 \
 " files iter ( ) map ( f format ( " " f ) ) collect Vec ( ) join ( " " ) invalid join ( " " ) ) ; Err ( message ) }
Finds `libclang` shared libraries and returns the paths to, filenames of,
and versions of those shared libraries.
Finds ` libclang ` shared libraries and returns the paths to filenames of and versions of those shared libraries .
runtime
bool