-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rust_analyzer rule to generate a rust-project.json (#505)
This PR builds on the work in #384 to add a rust_analyzer rule which generates a rust-project.json. This file allows rust-analyzer to function without cargo by describing the code structure, layout, and dependency graph.
- Loading branch information
Showing
49 changed files
with
3,281 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Rust rules | ||
* [rust_analyzer](#rust_analyzer) | ||
* [rust_analyzer_aspect](#rust_analyzer_aspect) | ||
|
||
<a id="#rust_analyzer"></a> | ||
|
||
## rust_analyzer | ||
|
||
<pre> | ||
rust_analyzer(<a href="#rust_analyzer-name">name</a>, <a href="#rust_analyzer-targets">targets</a>) | ||
</pre> | ||
|
||
Produces a rust-project.json for the given targets. Configure rust-analyzer to load the generated file via the linked projects mechanism. | ||
|
||
**ATTRIBUTES** | ||
|
||
|
||
| Name | Description | Type | Mandatory | Default | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="rust_analyzer-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | | ||
| <a id="rust_analyzer-targets"></a>targets | List of all targets to be included in the index | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Rust rules | ||
* [rust_clippy](#rust_clippy) | ||
* [rust_clippy_aspect](#rust_clippy_aspect) | ||
|
||
<a id="#rust_clippy"></a> | ||
|
||
## rust_clippy | ||
|
||
<pre> | ||
rust_clippy(<a href="#rust_clippy-name">name</a>, <a href="#rust_clippy-deps">deps</a>) | ||
</pre> | ||
|
||
Executes the clippy checker on a specific target. | ||
|
||
Similar to `rust_clippy_aspect`, but allows specifying a list of dependencies within the build system. | ||
|
||
For example, given the following example targets: | ||
|
||
```python | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load("@rules_rust//rust:rust.bzl", "rust_library", "rust_test") | ||
|
||
rust_library( | ||
name = "hello_lib", | ||
srcs = ["src/lib.rs"], | ||
) | ||
|
||
rust_test( | ||
name = "greeting_test", | ||
srcs = ["tests/greeting.rs"], | ||
deps = [":hello_lib"], | ||
) | ||
``` | ||
|
||
Rust clippy can be set as a build target with the following: | ||
|
||
```python | ||
rust_clippy( | ||
name = "hello_library_clippy", | ||
testonly = True, | ||
deps = [ | ||
":hello_lib", | ||
":greeting_test", | ||
], | ||
) | ||
``` | ||
|
||
|
||
**ATTRIBUTES** | ||
|
||
|
||
| Name | Description | Type | Mandatory | Default | | ||
| :------------- | :------------- | :------------- | :------------- | :------------- | | ||
| <a id="rust_clippy-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | | | ||
| <a id="rust_clippy-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.