Rust: add option to extract dependencies as source files

This commit is contained in:
Arthur Baars
2025-05-26 18:21:35 +02:00
parent a519eabd4d
commit 765afdbae0
3 changed files with 22 additions and 2 deletions

View File

@@ -82,3 +82,11 @@ options:
title: Skip path resolution
description: >
Skip path resolution. This is experimental, while we move path resolution from the extractor to the QL library.
type: string
pattern: "^(false|true)$"
extract_dependencies_as_source:
title: Extract dependencies as source code
description: >
Extract the full source code of dependencies instead of only extracting signatures.
type: string
pattern: "^(false|true)$"

View File

@@ -67,6 +67,7 @@ pub struct Config {
pub extra_includes: Vec<PathBuf>,
pub proc_macro_server: Option<PathBuf>,
pub skip_path_resolution: bool,
pub extract_dependencies_as_source: bool,
}
impl Config {

View File

@@ -277,6 +277,16 @@ fn main() -> anyhow::Result<()> {
} else {
ResolvePaths::Yes
};
let library_mode = if cfg.extract_dependencies_as_source {
SourceKind::Source
} else {
SourceKind::Library
};
let library_resolve_paths = if cfg.extract_dependencies_as_source {
resolve_paths
} else {
ResolvePaths::No
};
let mut processed_files: HashSet<PathBuf, RandomState> =
HashSet::from_iter(files.iter().cloned());
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
@@ -312,12 +322,13 @@ fn main() -> anyhow::Result<()> {
.source_root(db)
.is_library
{
tracing::info!("file: {}", file.display());
extractor.extract_with_semantics(
file,
&semantics,
vfs,
ResolvePaths::No,
SourceKind::Library,
library_resolve_paths,
library_mode,
);
extractor.archiver.archive(file);
}