Skip to content

Commit d018c02

Browse files
authored
Merge pull request #19583 from github/aibaars/lib-as-source
Rust: add option to extract dependencies as source files
2 parents ef1ddd0 + ac724d2 commit d018c02

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

rust/codeql-extractor.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ options:
8282
title: Skip path resolution
8383
description: >
8484
Skip path resolution. This is experimental, while we move path resolution from the extractor to the QL library.
85+
type: string
86+
pattern: "^(false|true)$"
87+
extract_dependencies_as_source:
88+
title: Extract dependencies as source code
89+
description: >
90+
Extract the full source code of dependencies instead of only extracting signatures.
91+
type: string
92+
pattern: "^(false|true)$"

rust/extractor/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ pub struct Config {
6767
pub extra_includes: Vec<PathBuf>,
6868
pub proc_macro_server: Option<PathBuf>,
6969
pub skip_path_resolution: bool,
70+
pub extract_dependencies_as_source: bool,
7071
}
7172

7273
impl Config {

rust/extractor/src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ fn main() -> anyhow::Result<()> {
277277
} else {
278278
ResolvePaths::Yes
279279
};
280+
let (library_mode, library_resolve_paths) = if cfg.extract_dependencies_as_source {
281+
(SourceKind::Source, resolve_paths)
282+
} else {
283+
(SourceKind::Library, ResolvePaths::No)
284+
};
280285
let mut processed_files: HashSet<PathBuf, RandomState> =
281286
HashSet::from_iter(files.iter().cloned());
282287
for (manifest, files) in map.values().filter(|(_, files)| !files.is_empty()) {
@@ -312,12 +317,13 @@ fn main() -> anyhow::Result<()> {
312317
.source_root(db)
313318
.is_library
314319
{
320+
tracing::info!("file: {}", file.display());
315321
extractor.extract_with_semantics(
316322
file,
317323
&semantics,
318324
vfs,
319-
ResolvePaths::No,
320-
SourceKind::Library,
325+
library_resolve_paths,
326+
library_mode,
321327
);
322328
extractor.archiver.archive(file);
323329
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy