Repository navigation
C++: Add BMN extractor - #22688
C++: Add BMN extractor#22688
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Extraction failure propagation, overlay invalidation, source discovery, and dependency-installation issues can produce incomplete or misleading extraction results.
Review effort: Balanced
Findings: 2
Open (5)
Report extraction failure when commands cannot launch or succeed · New Handle deleted headers when computing overlay dependency changes · New Deduplicate package installation attempts before invoking installer · New Allow whitespace between # and include in preprocessing directives · New Recognize uppercase C and C++ source file extensions · New
What changed in this PR
Moves the C/C++ build-mode-none Rust extractor into the public CodeQL repository and integrates it with existing build, test, lint, and CI infrastructure.
Changes:
- Imports the extractor, unit tests, fixtures, and developer documentation.
- Adds Cargo and Bazel targets with a dedicated generated Rust dependency universe.
- Adds CI and repository-wide lint/dependency-update integration.
| File | Description |
|---|---|
.github/workflows/cpp-bmn.yml |
Adds Cargo and Bazel CI. |
.pre-commit-config.yaml |
Registers BMN linting. |
MODULE.bazel |
Registers BMN Rust repositories. |
lint |
Runs the BMN linter. |
cpp/extractor/bmn/.gitignore |
Ignores Cargo artifacts. |
cpp/extractor/bmn/BUILD.bazel |
Defines binary and test targets. |
cpp/extractor/bmn/Cargo.lock |
Locks Rust dependencies. |
cpp/extractor/bmn/Cargo.toml |
Defines the Rust package. |
cpp/extractor/bmn/FILE_FILTERING.md |
Documents file filtering. |
cpp/extractor/bmn/README.md |
Documents development workflows. |
cpp/extractor/bmn/lint |
Runs formatting and Clippy checks. |
cpp/extractor/bmn/src/compiler.rs |
Discovers and represents compilers. |
cpp/extractor/bmn/src/dependency_installation.rs |
Installs inferred packages. |
cpp/extractor/bmn/src/directory_tree.rs |
Models project files. |
cpp/extractor/bmn/src/environment.rs |
Reads extraction environment settings. |
cpp/extractor/bmn/src/extraction_command_runner.rs |
Executes extraction commands. |
cpp/extractor/bmn/src/file_filter.rs |
Implements source filtering. |
cpp/extractor/bmn/src/gnu_compiler_default_include_finder.rs |
Discovers compiler include paths. |
cpp/extractor/bmn/src/include_finder.rs |
Resolves include dependencies. |
cpp/extractor/bmn/src/include_scanner.rs |
Parses include directives. |
cpp/extractor/bmn/src/logger.rs |
Configures logging. |
cpp/extractor/bmn/src/main.rs |
Orchestrates extraction. |
cpp/extractor/bmn/src/overlays.rs |
Selects overlay dependencies. |
cpp/extractor/bmn/src/package_database.rs |
Queries package metadata. |
cpp/extractor/bmn/src/path_utils.rs |
Provides path utilities. |
cpp/extractor/bmn/src/project_definitions.rs |
Discovers project sources. |
cpp/extractor/bmn/src/telemetry.rs |
Emits extraction telemetry. |
cpp/extractor/bmn/src/test_utils.rs |
Provides test helpers. |
cpp/extractor/bmn/src/timing.rs |
Records operation timings. |
cpp/extractor/bmn/tests/resources/** |
Adds 24 extractor test fixtures. |
misc/bazel/3rdparty/BUILD.bazel |
Defines dependency generation. |
misc/bazel/3rdparty/cpp_bmn_deps_extension.bzl |
Exposes generated repositories. |
misc/bazel/3rdparty/cpp_bmn_deps/BUILD.bazel |
Configures crate vendoring. |
misc/bazel/3rdparty/cpp_bmn_deps/alias_rules.bzl |
Defines generated aliases. |
misc/bazel/3rdparty/cpp_bmn_deps/crates.bzl |
Registers vendored crates. |
misc/bazel/3rdparty/cpp_bmn_deps/defs.bzl |
Defines generated dependencies. |
misc/bazel/3rdparty/cpp_bmn_deps/BUILD.*.bazel |
Adds 163 generated crate targets. |
misc/bazel/3rdparty/update_cargo_deps.sh |
Includes BMN dependency updates. |
misc/bazel/3rdparty/update_cpp_bmn_deps.sh |
Regenerates BMN dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
607dcbb to
716347f
Compare
716347f to
a52b319
Compare
a52b319 to
71f94e2
Compare
andersfugmann
left a comment
There was a problem hiding this comment.
LGTM. Some minor comments, but feel free to merge at will
| @@ -0,0 +1 @@ | |||
| /target No newline at end of file | |||
There was a problem hiding this comment.
Nit: Missing newline at end of input
|
|
||
| on: | ||
| pull_request: | ||
| paths: |
There was a problem hiding this comment.
Consider using an YAML anchor to avoid duplication of the paths. E.g.
on:
pull_request:
paths: &bmn_paths
- "cpp/extractor/bmn/**"
- "misc/bazel/3rdparty/cpp_bmn_deps/**"
- "misc/bazel/3rdparty/cpp_bmn_deps_extension.bzl"
- "misc/bazel/3rdparty/update_cpp_bmn_deps.sh"
- "misc/bazel/3rdparty/BUILD.bazel"
- "misc/bazel/rust.bzl"
- "MODULE.bazel"
- ".github/workflows/cpp-bmn.yml"
push:
branches:
- main
- "rc/*"
paths: *bmn_paths
Adds the sources of the internal C++ BMN extractor. All files are verbatim copies from the internal semmle-code repository. These files are removed in semmle-code in the commit 6aaf2537b5bb96d5ae40368b6624ae30f3acab7a. To see the git history prior to the move, follow that commit.
Add a script for generating vendored dependencies for the C++ BMN extractor. The setup and approach is identical to what we already use for existing Rust-based extractors.
Check in the vendored dependencies. All files in this commit are auto-generated.
Add a Bazel target for the C/C++ BMN extractor. This required a change in `cpp/extractor/bmn/src/test_utils.rs` since using `$CARGO_MANIFEST_DIR` doesn't work when invoking that target from the internal repo.
The updated Rust toolchain introduced additional Clippy lints. This fixes the lints.
Run Cargo and Bazel checks when the build-mode-none extractor changes, integrate its Rust lint into pre-commit, and document the standalone development workflow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
71f94e2 to
6e828c6
Compare
|
Thanks for the review. I've force pushed to change the message of the first commit 2b9dee6 to mention when the same code was deleted in the internal repository. The other two suggestions are applied in two new commits. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 43bdfe7-dd96-4f00-8537-45b93bfc0d8a


This PR moves the C/C++ build-mode-none extractor to
cpp/extractor/bmnin this repo.This open sources the BMN extractor.
I recommend a per-commit review. The commit message on each commit should explain what's going on.
A dependent PR on the internal repo deletes the migrated implementation and adjust the build system. The PR also has a few other details, and they should be reviewed in tandem.