codeql/ruby/extractor/codeql-extractor-fake-crate
Cornelius Riemenschneider 8c46b61e85 Ruby: Change how we pull in `shared/tree-sitter-extractor` dependency
Previously, we pulled in the shared tree-sitter extractor via a `git`
dependency in `Cargo.toml` to address a `rules_rust` limitation (no `path`
dependencies outside of the cargo workspace)). This was a problem,
as that means we're cloning `github/codeql` _again_ for the build, which is
quite slow.

I found another way that is faster, and still produces correct builds
for both `cargo`` and `rules_rust`:
* Cargo depends on a fake crate that has the same dependencies as the real crate (thanks to `sync-files.py`). Therefore, cargo pulls in the right dependencies into the lockfile, which bazel targets
* For local builds, we override the path to that dependency in a cargo config, so we're pulling in the correct code
* rules_rust only uses `path` dependencies for collecting transitive dependencies, it never pulls in the code from there. So far that, we manually provide a `BUILD.bazel` file for the shared extractor, and depend on that.
2024-05-24 15:37:35 +02:00
..
src
BUILD.bazel
Cargo.toml
README.md

README.md

We're presenting a fake crate in this workspace that ensures that the correct crate dependencies from the shared tree sitter extractor can be parsed by Bazel (which doesn't resolve path dependencies outside of the cargo workspace unfortunately).

The sync-identical-files script keeps this up-to-date. For local development and IDEs, we override the path to codeql-extractor using the .cargo/config.toml mechanism. Bazel doesn't actually do anything with path dependencies except to pull in their dependency tree, so we manually specify the dependency from the ruby extractor to the shared extractor in BUILD.bazel.