Lines Matching refs:path
5 use std::path::{Path, PathBuf};
22 /// The path to this `clang` executable.
23 pub path: PathBuf,
35 fn new(path: impl AsRef<Path>, args: &[String]) -> Self {
37 path: path.as_ref().into(),
38 version: parse_version(path.as_ref()),
39 c_search_paths: parse_search_paths(path.as_ref(), "c", args),
40 cpp_search_paths: parse_search_paths(path.as_ref(), "c++", args),
48 /// a path is supplied, that is the first directory searched. Then, the
59 pub fn find(path: Option<&Path>, args: &[String]) -> Option<Clang> {
60 if let Ok(path) = env::var("CLANG_PATH") {
61 let p = Path::new(&path);
80 if let Some(path) = path {
81 paths.push(path.into());
84 if let Ok(path) = run_llvm_config(&["--bindir"]) {
85 if let Some(line) = path.lines().next() {
91 if let Ok((path, _)) = run("xcodebuild", &["-find", "clang"]) {
92 if let Some(line) = path.lines().next() {
98 if let Ok(path) = env::var("PATH") {
99 paths.extend(env::split_paths(&path));
108 for path in &paths {
109 if let Some(path) = find(path, patterns) {
110 return Some(Clang::new(path, args));
120 for path in paths {
121 if let Some(path) = find(&path, patterns) {
122 return Some(Clang::new(path, args));
147 if let Some(path) = glob::glob(&pattern).ok()?.filter_map(|p| p.ok()).next() {
148 if path.is_file() && is_executable(&path).unwrap_or(false) {
149 return Some(path);
158 fn is_executable(path: &Path) -> io::Result<bool> {
162 let path = CString::new(path.as_os_str().as_bytes())?;
163 unsafe { Ok(libc::access(path.as_ptr(), libc::X_OK) == 0) }
186 fn run_clang(path: &Path, arguments: &[&str]) -> (String, String) {
187 run(&path.to_string_lossy().into_owned(), arguments).unwrap()
207 fn parse_version(path: &Path) -> Option<CXVersion> {
208 let output = run_clang(path, &["--version"]).0;
222 fn parse_search_paths(path: &Path, language: &str, args: &[String]) -> Option<Vec<PathBuf>> {
225 let output = run_clang(path, &clang_args).1;