Skip to content

Commit

Permalink
fix(rust_extractor): change argument processing due to rules_rust cha…
Browse files Browse the repository at this point in the history
…nge (#4996)

* fix(rust_extractor): change argument processing due to rules_rust change

* fix(rust_extractor): change the extra_action generator to account for the new arg processing

* chore(rust_extractor): add todo regarding vname configuration support
  • Loading branch information
wcalandro committed Jul 29, 2021
1 parent 6889771 commit 3044115
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions kythe/extractors/BUILD
Expand Up @@ -198,6 +198,8 @@ extractor_action(
data = ["//external:vnames_config"],
env = {
"LD_LIBRARY_PATH": "external/rust_linux_x86_64/lib:external/rust_darwin_x86_64/lib",
# TODO(wcalandro): Remove this once the extractor has support for VName configuration
"KYTHE_CORPUS": "kythe.io",
},
extractor = "@io_kythe//kythe/rust/extractor",
mnemonics = [
Expand Down
6 changes: 4 additions & 2 deletions kythe/rust/extractor/src/bin/save_analysis.rs
Expand Up @@ -38,10 +38,12 @@ fn generate_arguments(arguments: Vec<String>, output_dir: &Path) -> Result<Vec<S
.position(|arg| arg == "--")
.ok_or_else(|| anyhow!("Could not find the start of the rustc arguments"))?;

// Keep the "--" argument and replace it with an empty string because
// The rust compiler executable path is the argument directly after "--"
// We keep the path argument and replace it with an empty string because
// `kythe_rust_extractor::generate_analysis` requires the first argument in
// `arguments` to be an empty string
let mut rustc_arguments = arguments.split_at(argument_position).1.to_vec();
let mut rustc_arguments = arguments.split_at(argument_position + 1).1.to_vec();

rustc_arguments[0] = String::from("");

// Change the original compiler output to the temporary directory
Expand Down
1 change: 1 addition & 0 deletions kythe/rust/extractor/tests/integration_test.rs
Expand Up @@ -43,6 +43,7 @@ fn main() -> Result<()> {
let sysroot = std::env::var("SYSROOT").expect("SYSROOT variable missing");
let arguments: Vec<String> = vec![
"--".to_string(),
"rustc".to_string(),
rust_test_source.clone(),
format!("-L{}", sysroot),
"--crate-name=test_crate".to_string(),
Expand Down
1 change: 1 addition & 0 deletions tools/rust/extra_action/src/main.rs
Expand Up @@ -84,6 +84,7 @@ fn main() -> Result<()> {
};
let arguments: Vec<String> = vec![
"--".to_string(),
"rustc".to_string(),
// Only the main source file gets passed to the compiler
main_source_file.to_string(),
format!("-L{}", matches.value_of("sysroot").unwrap()),
Expand Down

0 comments on commit 3044115

Please sign in to comment.