• Home
  • Raw
  • Download

Lines Matching +full:env +full:- +full:paths

1 // SPDX-License-Identifier: Apache-2.0
7 use std::{env, io};
35 fn new(path: impl AsRef<Path>, args: &[String]) -> Self { in new()
49 /// directory returned by `llvm-config --bindir` is searched. On macOS
50 /// systems, `xcodebuild -find clang` will next be queried. Last, the
53 /// ## Cross-compilation
55 /// If target arguments are provided (e.g., `-target` followed by a target
56 /// like `x86_64-unknown-linux-gnu`) then this method will prefer a
57 /// target-prefixed instance of `clang` (e.g.,
58 /// `x86_64-unknown-linux-gnu-clang` for the above example).
59 pub fn find(path: Option<&Path>, args: &[String]) -> Option<Clang> { in find()
60 if let Ok(path) = env::var("CLANG_PATH") { in find()
67 // Determine the cross-compilation target, if any. in find()
71 if args[i] == "-target" && i + 1 < args.len() { in find()
76 // Collect the paths to search for a `clang` executable in. in find()
78 let mut paths = vec![]; in find() localVariable
81 paths.push(path.into()); in find()
84 if let Ok(path) = run_llvm_config(&["--bindir"]) { in find()
86 paths.push(line.into()); in find()
91 if let Ok((path, _)) = run("xcodebuild", &["-find", "clang"]) { in find()
93 paths.push(line.into()); in find()
98 if let Ok(path) = env::var("PATH") { in find()
99 paths.extend(env::split_paths(&path)); in find()
102 // First, look for a target-prefixed `clang` executable. in find()
105 let default = format!("{}-clang{}", target, env::consts::EXE_SUFFIX); in find()
106 let versioned = format!("{}-clang-[0-9]*{}", target, env::consts::EXE_SUFFIX); in find()
108 for path in &paths { in find()
117 let default = format!("clang{}", env::consts::EXE_SUFFIX); in find()
118 let versioned = format!("clang-[0-9]*{}", env::consts::EXE_SUFFIX); in find()
120 for path in paths { in find()
136 fn find(directory: &Path, patterns: &[&str]) -> Option<PathBuf> { in find()
158 fn is_executable(path: &Path) -> io::Result<bool> { in is_executable()
167 fn is_executable(_: &Path) -> io::Result<bool> { in is_executable()
173 fn run(executable: &str, arguments: &[&str]) -> Result<(String, String), String> { in run()
186 fn run_clang(path: &Path, arguments: &[&str]) -> (String, String) { in run_clang()
190 /// Runs `llvm-config`, returning the `stdout` output if successful.
191 fn run_llvm_config(arguments: &[&str]) -> Result<String, String> { in run_llvm_config()
192 let config = env::var("LLVM_CONFIG_PATH").unwrap_or_else(|_| "llvm-config".to_string()); in run_llvm_config()
196 /// Parses a version number if possible, ignoring trailing non-digit characters.
197 fn parse_version_number(number: &str) -> Option<c_int> { in parse_version_number()
207 fn parse_version(path: &Path) -> Option<CXVersion> { in parse_version()
208 let output = run_clang(path, &["--version"]).0; in parse_version()
221 /// Parses the search paths from the output of a `clang` executable if possible.
222 fn parse_search_paths(path: &Path, language: &str, args: &[String]) -> Option<Vec<PathBuf>> { in parse_search_paths()
223 let mut clang_args = vec!["-E", "-x", language, "-", "-v"]; in parse_search_paths()
228 let paths = output[start..end].replace("(framework directory)", ""); in parse_search_paths() localVariable
230 paths in parse_search_paths()