| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
If you don't have the semmle-code repo you may need to install Bazel manually, e.g. from https://github.com/bazelbuild/bazelisk.
This approach uses a released codeql version and is simpler to use for QL development. From anywhere under your semmle-code or codeql directory you can run:
bazel run @codeql//rust:installYou can use shorter versions of the above command:
bazel run //rust:install # if under the `codeql` checkout
bazel run rust:install # if at the root of the `codeql` checkout
bazel run :install # if at the `rust` directory of the `codeql` checkoutYou now need to create a per-user CodeQL configuration file and specify the option:
--search-path PATH/TO/semmle-code/ql
(wherever the codeql checkout is on your system)
You can now use the Rust extractor e.g. to run Rust tests from the command line or in VSCode.
This approach allows you to build a Rust extractor with a CLI built from source. From your semmle-code directory run:
./build target/intree/codeql-rustYou can now invoke it directly, for example to run some tests:
./target/intree/codeql-rust/codeql test run ql/rust/ql/test/PATH/TO/TEST/TODO
If you make changes to either
you'll need to regenerate code. You can do so running
bazel run @codeql//rust/codegenSometimes, especially if resolving conflicts on generated files, you might need to run
bazel run @codeql//rust/codegen -- --forcefor code generation to succeed.
Here's a rundown of the typical actions to perform to do a rust-analyzer (and other dependencies) update. A one-time setup consists in installing cargo-edit with cargo install cargo-edit. On Ubuntu that also requires sudo apt install libssl-dev pkg-config.
From the root of the codeql repo checkout, run a Cargo upgrade:
cargo upgrade --incompatible --pinned
Look at a diff of the Cargo.toml files: if all ra_ap_ prefixed dependencies have been updated to the same number, go on to the next step. Otherwise, it means the latest rust-analyzer update has not been fully rolled out to all its crates in crates.io. All ra_ap_ versions must agree! Downgrade by hand to the minimum one you see, and run a cargo update after that to fix the Cargo.lock file.
Commit the changes, skipping pre-commit hooks if you have them enabled:
git commit -am 'Cargo: upgrade dependencies' --no-verify
Regenerate vendored bazel files (these allow faster builds, particularly on CI where it has to start from scratch each time), commit the changes:
misc/bazel/3rdparty/update_tree_sitter_extractors_deps.sh git add . git commit -am 'Bazel: regenerate vendored cargo dependencies' --no-verify
Run codegen
bazel run //rust/codegen
Take note whether rust/schema/ast.py was changed. That might need tweaks, new tests and/or downgrade/upgrade scripts down the line.
Try compiling
bazel run //rust:install
If you had to do any changes, commit them. If you updated the rust toolchain, running rust/lint.py might reformat or apply new lints to the code.
Check with CI if everything is in order.
Run DCA with database caching disabled. Iterate on the code if needed.
If in step 5 the schema was updated, add upgrade/downgrade scripts and a change note. This is best done last to reduce the chance of merge conflicts (none of the other testing depends on having upgrade and downgrade scripts in place). See Upgrading a language database schema.
| Back | FazBrowse Home | New Git URL |