mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #19583 from github/aibaars/lib-as-source
Rust: add option to extract dependencies as source files
This commit is contained in:
@@ -82,3 +82,11 @@ options:
|
|||||||
title: Skip path resolution
|
title: Skip path resolution
|
||||||
description: >
|
description: >
|
||||||
Skip path resolution. This is experimental, while we move path resolution from the extractor to the QL library.
|
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)$"
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ pub struct Config {
|
|||||||
pub extra_includes: Vec<PathBuf>,
|
pub extra_includes: Vec<PathBuf>,
|
||||||
pub proc_macro_server: Option<PathBuf>,
|
pub proc_macro_server: Option<PathBuf>,
|
||||||
pub skip_path_resolution: bool,
|
pub skip_path_resolution: bool,
|
||||||
|
pub extract_dependencies_as_source: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
|
|||||||
@@ -277,6 +277,11 @@ fn main() -> anyhow::Result<()> {
|
|||||||
} else {
|
} else {
|
||||||
ResolvePaths::Yes
|
ResolvePaths::Yes
|
||||||
};
|
};
|
||||||
|
let (library_mode, library_resolve_paths) = if cfg.extract_dependencies_as_source {
|
||||||
|
(SourceKind::Source, resolve_paths)
|
||||||
|
} else {
|
||||||
|
(SourceKind::Library, ResolvePaths::No)
|
||||||
|
};
|
||||||
let mut processed_files: HashSet<PathBuf, RandomState> =
|
let mut processed_files: HashSet<PathBuf, RandomState> =
|
||||||
HashSet::from_iter(files.iter().cloned());
|
HashSet::from_iter(files.iter().cloned());
|
||||||
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
|
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
|
||||||
@@ -312,12 +317,13 @@ fn main() -> anyhow::Result<()> {
|
|||||||
.source_root(db)
|
.source_root(db)
|
||||||
.is_library
|
.is_library
|
||||||
{
|
{
|
||||||
|
tracing::info!("file: {}", file.display());
|
||||||
extractor.extract_with_semantics(
|
extractor.extract_with_semantics(
|
||||||
file,
|
file,
|
||||||
&semantics,
|
&semantics,
|
||||||
vfs,
|
vfs,
|
||||||
ResolvePaths::No,
|
library_resolve_paths,
|
||||||
SourceKind::Library,
|
library_mode,
|
||||||
);
|
);
|
||||||
extractor.archiver.archive(file);
|
extractor.archiver.archive(file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user