Skip to content

Commit 4f6fda0

Browse files
author
Paolo Tranquilli
committed
Rust: allow to specify the target directory
1 parent fc8d8bb commit 4f6fda0

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

rust/extractor/macros/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ pub fn extractor_cli_config(_attr: TokenStream, item: TokenStream) -> TokenStrea
2121
#id: bool,
2222
};
2323
}
24+
if p.path.segments.len() == 1 && p.path.segments[0].ident == "Option" {
25+
return quote! {
26+
#[arg(long)]
27+
#id: #ty,
28+
};
29+
}
2430
}
2531
if id == &format_ident!("verbose") {
2632
quote! {

rust/extractor/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct Config {
3737
pub scratch_dir: PathBuf,
3838
pub trap_dir: PathBuf,
3939
pub source_archive_dir: PathBuf,
40+
pub target_dir: Option<PathBuf>,
4041
pub extract_dependencies: bool,
4142
pub verbose: u8,
4243
pub compression: Compression,

rust/extractor/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ fn main() -> anyhow::Result<()> {
130130
}
131131
extractor.extract_without_semantics(file, "no manifest found");
132132
}
133+
let target_dir = &cfg
134+
.target_dir
135+
.unwrap_or_else(|| cfg.scratch_dir.join("target"));
133136
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
134-
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, &cfg.scratch_dir) {
137+
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, target_dir) {
135138
let semantics = Semantics::new(db);
136139
for file in files {
137140
let Some(id) = path_to_file_id(file, vfs) else {

rust/extractor/src/rust_analyzer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ pub struct ParseResult<'a> {
4545
impl<'a> RustAnalyzer<'a> {
4646
pub fn load_workspace(
4747
project: &ProjectManifest,
48-
scratch_dir: &Path,
48+
target_dir: &Path,
4949
) -> Option<(RootDatabase, Vfs)> {
5050
let config = CargoConfig {
5151
sysroot: Some(RustLibSource::Discover),
52-
target_dir: ra_ap_paths::Utf8PathBuf::from_path_buf(scratch_dir.to_path_buf())
53-
.map(|x| x.join("target"))
54-
.ok(),
52+
target_dir: ra_ap_paths::Utf8PathBuf::from_path_buf(target_dir.to_path_buf()).ok(),
5553
..Default::default()
5654
};
5755
let progress = |t| (log::trace!("progress: {}", t));

0 commit comments

Comments
 (0)