-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Changed bsp4j dep to Rust integreted * Replaced bsp4 dependency with our implementation (temp) * Added mock implementation for Rust endpoints * Updated to use new interface * Updated to use even newer interface * initial * add * add * sending proper env * sending proper env v2 * dupa * now works * Added hello-world to .bazelignore as bazel configuration in hello-world wasn't working with bazel-bsp querrign * temporarty changes with buildifier * Add aspect for fetching rust-specific data * Borrow some ideas from `rust_analyzer.bzl` to extract more rust-specific info * Fix protos, add comments * Add field, simplify * Add helpful comments. * hardcoded rust-bazel-bsp-sample data * Proto-related fix in serializing RustCrateInfo * Collect Rust data from protos * Moved creating RustWorkspaceResult to proper place * Solved failing test compilation. Added temp solution for temp solution for mock project * fixed xewar->mikolaj * Extract output directory of build script using `BuildInfo` provider * Fix tudny mistakes * Modify rust plugin to use module list * added dep packges - to be consulted about their usage * started to remove mocking. New BSP model. Package collection. Targets merging. etc. * added more missing version (heuristic). Added comments * fixed missing version * added raw dependencies * todo docs * checking if dep has CrateInfo provider * aspect: extract version from `ctx.rule.attr` * Removed cycles. Dependent targets can be in the same package. * Treat all Rust targets as rootTargets `BazelProjectMapper` now treats all Rust targets as rootTargets, regardless of the workspace/external origin. * Pass external Rust targets in `Project` class Rust targets are now passed in `rustExternalModules` field in `Project` data class. This reverts previous commit. * BazelPathsResolver: Support for external targets in `labelToDirectoryUri` * cometics * solved missing package path * added version in env, DEP proper name and package root hack * Pass full URI for `crate_root` * added all depth dependency packaging for Rust * sending all targets related to package (updated BSP version), refactored externalRustModules * RustPackage id should not be a BuildTargetIdentifier * proc_macros are now discovered and treated like normal library * sending proper rust target kind * added proc macros artifacts * Added Rust toolchain * Rust: added stdlib path and proc-macro-srv path to metadata scraped from bazel * Rust: added cargo binary path to target info * Added stdlib info to RustWorkspace result * Sending stdlib info in rust workspace result * sending toolchain as seperate endpoint * fixed toolchain paths' * fixed proc macro * removed DepInfo * Added projectview.bazelproject to .gitignore * added stdlib version to Rust info * PR feedback: it'd be nice to write it using map and filter * PR feedback: both methods are kinda similar; let's keep imports without wildcard * PR feedback: block to expr * PR feedback: $ in strings * PR feedback: new line * PR feedback: no wildcard * PR feedback: new line * PR feedback: a lot of nested things - it'd be nice to extract part of it to separate methods * PR feedback: it can be top-level private class * PR feedback: block to expr * PR feedback: if u r using ! then u can just use maxBy instead of maxByOrNull * PR feedback: prob we dont need it - it's a private methods and should know on what data we call ut * PR feedback: refactored rustPackages function * PR feedback: safe casting * PR feedback: inner classes are now private * PR feedback: aspect typo * moved Rust workspace resolving methods to another class * PR feedback: distributed dependency resolver to methods * Remove unnecessary returns and comments * Use when instead of if-else * Move some things around * Move nested code to separate methods * Added simple rust project and started rust e2e test class * removed hello-world * Add a basic `LanguagePluginService` test for Rust * updated bsp version to include sysroot in rust toolchain * Setting CARGO_BAZEL_REPIN in every bazel call to enable bazel lock files refreshing * Printing custom env varaibles when calling bazel * Changes 'env' to 'processEnv' * Extracting toolchain host for Rust targets * removed DEBUG flag from aspect * this SHOULD (i don't know if it does) create missing proc-macros dynlibs * Add basic unit tests for `RustWorkspaceResolver` * Add a test for `RustWorkspaceResolver` with multiple targets and deps * Rename methods * Update labels and host in `RustWorkspaceResolverTest` * Fix some issues with the data in `RustWorkspaceResolverTest` * Change bsp to use rustcInfo * Add `RustLanguagePluginTest` * PR feedback: Use map instead of mapNotNull * PR feedback: Use data class instead of typealias * Move common testing code to a separate file * Add raw dependencies testing * removed debug info in from aspects.bzl * Change BSP to use new interface * Add aspects for rust and update bsp version * Update bsp version and fix target resolution for rust * Do not filter rust test build targets * Sync with the newest BSP Rust extension * Update BSP version and fix server tests * Fix after merging upstream * Delete RustToolchain request * Add basic onReadStdin and onReadStderr handling * Resolve PR issues amd refactor code * Fix after merge with master * Fix naming * Add `rustExternalModules` to `modules` in `Project` * README update * First fixed to e2e tests * Fix e2e tests * Fix formatting * Fix CI * Move `expectedTargetIdentifiers` and `expectedWorkspaceBuildTargetsResult` to `BazelBspTestBaseScenario` * Add e2e RustWorkspaceRequest test * Fix after merging master * Fix Rust e2e test * Fix .bazelrc * Fix `main function not found` error for integration tests * Resolve PR issues part 1 * Fix buildifier * Fix after merge * Update testkit version * Make `findAllRelatedRustTargets` tailrec * Remove empty file * Resolve PR issues --------- Co-authored-by: Mikołaj Komar <mikokomar@op.pl> Co-authored-by: Perlik <mp429581@students.mimuw.edu.pl> Co-authored-by: Przemysław Kusiak <przemyslaw.r.kusiak@gmail.com> Co-authored-by: juliapodrazka <juliapodrazka@poczta.onet.pl> Co-authored-by: Julia Podrażka <73885839+julia-podrazka@users.noreply.github.com>
- Loading branch information
1 parent
e7ae683
commit ec66172
Showing
55 changed files
with
2,203 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ Bazel. | |
- Scala | ||
- Python | ||
- Thrift | ||
- Rust (coming soon!) | ||
- Rust | ||
|
||
## Installation | ||
|
||
|
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 |
---|---|---|
|
@@ -33,6 +33,7 @@ COMPILE_DEPS = [ | |
"jars", | ||
"exports", | ||
"associates", | ||
"proc_macro_deps", | ||
] | ||
|
||
PRIVATE_COMPILE_DEPS = [ | ||
|
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,80 @@ | ||
load("@rules_rust//rust:rust_common.bzl", "BuildInfo", "CrateInfo") | ||
load("//aspects:utils/utils.bzl", "create_proto", "create_struct", "filter", "flatmap") | ||
|
||
# This is supposed to be enum, but Starlark does not support enums. | ||
# See bsp_target_info.proto:RustCrateLocation. | ||
WORKSPACE_DIR = 0 | ||
EXEC_ROOT = 1 | ||
|
||
RUST_TOOLCHAIN_TYPE = "@rules_rust//rust:toolchain_type" | ||
|
||
def collect_proc_macro_artifacts(target, kind, ext): | ||
if not hasattr(target, "actions") or kind != "proc-macro": | ||
return [] | ||
|
||
def is_proc_macro_output_with_ext(output): | ||
return output.path.endswith(ext) | ||
|
||
return filter( | ||
is_proc_macro_output_with_ext, | ||
flatmap( | ||
lambda _action: _action.outputs.to_list(), | ||
target.actions, | ||
), | ||
) | ||
|
||
def extract_rust_crate_info(target, ctx, **kwargs): | ||
if CrateInfo not in target: | ||
return None, None | ||
|
||
if RUST_TOOLCHAIN_TYPE not in ctx.toolchains: | ||
return None, None | ||
|
||
crate_info = target[CrateInfo] | ||
build_info = None if not BuildInfo in target else target[BuildInfo] | ||
toolchain = ctx.toolchains[RUST_TOOLCHAIN_TYPE] | ||
|
||
crate_root_path = crate_info.root.path | ||
|
||
def is_same_crate(dep): | ||
if CrateInfo not in dep: | ||
return False | ||
|
||
return dep[CrateInfo].root.path == crate_root_path | ||
|
||
crate_is_from_workspace = not crate_info.root.path.startswith("external/") | ||
crate_is_generated = not crate_info.root.is_source | ||
crate_is_in_exec_root = not crate_is_from_workspace or crate_is_generated | ||
|
||
deps = [ | ||
dep[CrateInfo].root.path | ||
for dep in (ctx.rule.attr.deps + ctx.rule.attr.proc_macro_deps) | ||
if not is_same_crate(dep) and CrateInfo in dep | ||
] | ||
|
||
proc_macro_artifacts = collect_proc_macro_artifacts(target, crate_info.type, toolchain.dylib_ext) | ||
proc_macro_artifacts_paths = [artifact.path for artifact in proc_macro_artifacts] | ||
|
||
# To obtain crate root file, find directory corresponding to | ||
# `crate_location` and concatenate it with `crate_id` (relative crate root | ||
# file path); this has be done in bazel-bsp | ||
# (see rules_rust/tools/rust_analyzer/rust_project.rs:write_rust_project). | ||
rust_crate_struct = create_struct( | ||
# The `crate-id` field must be unique. The deduplication has to be done | ||
# in bazel-bsp | ||
# (see rules_rust/tools/rust_analyzer/aquery.rs:consolidate_crate_specs). | ||
crate_id = crate_info.root.path, | ||
location = EXEC_ROOT if crate_is_in_exec_root else WORKSPACE_DIR, | ||
from_workspace = crate_is_from_workspace, | ||
name = crate_info.name, | ||
kind = crate_info.type, | ||
edition = crate_info.edition, | ||
out_dir = "" if build_info == None else build_info.out_dir.path, | ||
crate_features = ctx.rule.attr.crate_features, | ||
dependencies_crate_ids = deps, | ||
crate_root = crate_info.root.path, | ||
version = ctx.rule.attr.version, | ||
proc_macro_artifacts = proc_macro_artifacts_paths, | ||
) | ||
|
||
return create_proto(target, ctx, rust_crate_struct, "rust_crate_info"), None |
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
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
Oops, something went wrong.