diff --git a/kythe/rust/extractor/src/bin/save_analysis.rs b/kythe/rust/extractor/src/bin/save_analysis.rs index a5dbd4cb83..fd458d771c 100644 --- a/kythe/rust/extractor/src/bin/save_analysis.rs +++ b/kythe/rust/extractor/src/bin/save_analysis.rs @@ -12,7 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -use anyhow::Result; +use anyhow::{Context, Result}; +use std::fs::File; +use std::io::{self, BufRead}; use std::path::{Path, PathBuf}; /// Generates a save analysis in `output_dir` @@ -55,5 +57,47 @@ fn generate_arguments(arguments: Vec, output_dir: &Path) -> Result Result<()> { + let pwd = std::env::current_dir().context("Couldn't determine pwd")?; + for line in io::BufReader::new(File::open(path)?).lines() { + let line_string = line.context("Failed to read line of env file")?; + let split: Vec<&str> = line_string.trim().split('=').collect(); + let value = split[1].replace("${pwd}", pwd.to_str().unwrap()); + std::env::set_var(split[0], value); + } + Ok(()) +} + +/// Process a compiler argument file passed to the process wrapper +/// +/// * `path` - The path of the compiler argument file +fn process_arg_file(path: &Path) -> Result> { + io::BufReader::new(File::open(path)?) + .lines() + .map(|line| line.context("Failed to read line of arg file")) + .collect() +}