mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Rust: allow to specify the target directory
This commit is contained in:
@@ -21,6 +21,12 @@ pub fn extractor_cli_config(_attr: TokenStream, item: TokenStream) -> TokenStrea
|
||||
#id: bool,
|
||||
};
|
||||
}
|
||||
if p.path.segments.len() == 1 && p.path.segments[0].ident == "Option" {
|
||||
return quote! {
|
||||
#[arg(long)]
|
||||
#id: #ty,
|
||||
};
|
||||
}
|
||||
}
|
||||
if id == &format_ident!("verbose") {
|
||||
quote! {
|
||||
|
||||
@@ -37,6 +37,7 @@ pub struct Config {
|
||||
pub scratch_dir: PathBuf,
|
||||
pub trap_dir: PathBuf,
|
||||
pub source_archive_dir: PathBuf,
|
||||
pub target_dir: Option<PathBuf>,
|
||||
pub extract_dependencies: bool,
|
||||
pub verbose: u8,
|
||||
pub compression: Compression,
|
||||
|
||||
@@ -130,8 +130,11 @@ fn main() -> anyhow::Result<()> {
|
||||
}
|
||||
extractor.extract_without_semantics(file, "no manifest found");
|
||||
}
|
||||
let target_dir = &cfg
|
||||
.target_dir
|
||||
.unwrap_or_else(|| cfg.scratch_dir.join("target"));
|
||||
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
|
||||
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, &cfg.scratch_dir) {
|
||||
if let Some((ref db, ref vfs)) = RustAnalyzer::load_workspace(manifest, target_dir) {
|
||||
let semantics = Semantics::new(db);
|
||||
for file in files {
|
||||
let Some(id) = path_to_file_id(file, vfs) else {
|
||||
|
||||
@@ -45,13 +45,11 @@ pub struct ParseResult<'a> {
|
||||
impl<'a> RustAnalyzer<'a> {
|
||||
pub fn load_workspace(
|
||||
project: &ProjectManifest,
|
||||
scratch_dir: &Path,
|
||||
target_dir: &Path,
|
||||
) -> Option<(RootDatabase, Vfs)> {
|
||||
let config = CargoConfig {
|
||||
sysroot: Some(RustLibSource::Discover),
|
||||
target_dir: ra_ap_paths::Utf8PathBuf::from_path_buf(scratch_dir.to_path_buf())
|
||||
.map(|x| x.join("target"))
|
||||
.ok(),
|
||||
target_dir: ra_ap_paths::Utf8PathBuf::from_path_buf(target_dir.to_path_buf()).ok(),
|
||||
..Default::default()
|
||||
};
|
||||
let progress = |t| (log::trace!("progress: {}", t));
|
||||
|
||||
Reference in New Issue
Block a user