| load("@bazel_skylib//:bzl_library.bzl", "bzl_library") |
| load("//rust:defs.bzl", "rust_binary", "rust_clippy", "rust_library", "rust_test") |
| load("//tools/private:tool_utils.bzl", "aspect_repository") |
| load(":env_file.bzl", "env_file") |
| load(":opt_transition.bzl", "opt_executable") |
| |
| rust_binary( |
| name = "discover_bazel_rust_project", |
| srcs = ["bin/discover_rust_project.rs"], |
| edition = "2018", |
| rustc_env = { |
| "ASPECT_REPOSITORY": aspect_repository(), |
| }, |
| visibility = ["//visibility:public"], |
| deps = [ |
| ":gen_rust_project_lib", |
| "//tools/rust_analyzer/3rdparty/crates:anyhow", |
| "//tools/rust_analyzer/3rdparty/crates:camino", |
| "//tools/rust_analyzer/3rdparty/crates:clap", |
| "//tools/rust_analyzer/3rdparty/crates:env_logger", |
| "//tools/rust_analyzer/3rdparty/crates:log", |
| "//tools/rust_analyzer/3rdparty/crates:serde_json", |
| ], |
| ) |
| |
| rust_binary( |
| name = "gen_rust_project", |
| srcs = ["bin/gen_rust_project.rs"], |
| edition = "2018", |
| rustc_env = { |
| "ASPECT_REPOSITORY": aspect_repository(), |
| }, |
| visibility = ["//visibility:public"], |
| deps = [ |
| ":gen_rust_project_lib", |
| "//tools/rust_analyzer/3rdparty/crates:anyhow", |
| "//tools/rust_analyzer/3rdparty/crates:camino", |
| "//tools/rust_analyzer/3rdparty/crates:clap", |
| "//tools/rust_analyzer/3rdparty/crates:env_logger", |
| "//tools/rust_analyzer/3rdparty/crates:log", |
| "//tools/rust_analyzer/3rdparty/crates:serde_json", |
| ], |
| ) |
| |
| rust_binary( |
| name = "validate", |
| srcs = ["bin/validate.rs"], |
| data = [ |
| "//rust/toolchain:current_rust_analyzer_toolchain", |
| ], |
| edition = "2021", |
| rustc_env = { |
| "RUST_ANALYZER_RLOCATIONPATH": "$(RUST_ANALYZER_RLOCATIONPATH)", |
| }, |
| toolchains = ["//rust/toolchain:current_rust_analyzer_toolchain"], |
| visibility = ["//visibility:public"], |
| deps = [ |
| "//rust/runfiles", |
| "//tools/rust_analyzer/3rdparty/crates:clap", |
| "//tools/rust_analyzer/3rdparty/crates:env_logger", |
| "//tools/rust_analyzer/3rdparty/crates:log", |
| ], |
| ) |
| |
| rust_binary( |
| name = "flycheck", |
| srcs = ["bin/flycheck.rs"], |
| edition = "2021", |
| visibility = ["//visibility:public"], |
| deps = [ |
| ":gen_rust_project_lib", |
| "//tools/rust_analyzer/3rdparty/crates:anyhow", |
| "//tools/rust_analyzer/3rdparty/crates:camino", |
| "//tools/rust_analyzer/3rdparty/crates:clap", |
| "//tools/rust_analyzer/3rdparty/crates:env_logger", |
| "//tools/rust_analyzer/3rdparty/crates:log", |
| "//tools/rust_analyzer/3rdparty/crates:serde_json", |
| ], |
| ) |
| |
| rust_test( |
| name = "flycheck_test", |
| crate = ":flycheck", |
| ) |
| |
| opt_executable( |
| name = "discover_bazel_rust_project_opt", |
| src = ":discover_bazel_rust_project", |
| visibility = ["//visibility:private"], |
| ) |
| |
| opt_executable( |
| name = "flycheck_opt", |
| src = ":flycheck", |
| visibility = ["//visibility:private"], |
| ) |
| |
| rust_binary( |
| name = "launcher", |
| srcs = ["bin/launcher.rs"], |
| edition = "2021", |
| visibility = ["//visibility:public"], |
| deps = [ |
| "//tools/rust_analyzer/3rdparty/crates:serde_json", |
| ], |
| ) |
| |
| rust_test( |
| name = "launcher_test", |
| crate = ":launcher", |
| ) |
| |
| opt_executable( |
| name = "launcher_opt", |
| src = ":launcher", |
| visibility = ["//visibility:private"], |
| ) |
| |
| rust_binary( |
| name = "setup", |
| srcs = ["bin/setup.rs"], |
| data = [ |
| ":discover_bazel_rust_project_opt", |
| ":flycheck_opt", |
| ":launcher_opt", |
| "//rust/toolchain:current_rust_analyzer_toolchain", |
| "//rust/toolchain:current_rustfmt_toolchain", |
| ], |
| edition = "2021", |
| rustc_env = { |
| "LAUNCHER_RLOCATIONPATH": "$(rlocationpath :launcher_opt)", |
| "RUSTFMT_RLOCATIONPATH": "$(RUSTFMT_RLOCATIONPATH)", |
| "RUST_ANALYZER_PROC_MACRO_SRV_RLOCATIONPATH": "$(RUST_ANALYZER_PROC_MACRO_SRV_RLOCATIONPATH)", |
| "RUST_ANALYZER_RLOCATIONPATH": "$(RUST_ANALYZER_RLOCATIONPATH)", |
| }, |
| toolchains = [ |
| "//rust/toolchain:current_rust_analyzer_toolchain", |
| "//rust/toolchain:current_rustfmt_toolchain", |
| ], |
| visibility = ["//visibility:public"], |
| deps = [ |
| ":gen_rust_project_lib", |
| "//rust/runfiles", |
| "//tools/rust_analyzer/3rdparty/crates:anyhow", |
| "//tools/rust_analyzer/3rdparty/crates:camino", |
| "//tools/rust_analyzer/3rdparty/crates:clap", |
| "//tools/rust_analyzer/3rdparty/crates:env_logger", |
| "//tools/rust_analyzer/3rdparty/crates:jsonc-parser", |
| "//tools/rust_analyzer/3rdparty/crates:log", |
| "//tools/rust_analyzer/3rdparty/crates:serde_json", |
| ], |
| ) |
| |
| rust_test( |
| name = "setup_test", |
| crate = ":setup", |
| ) |
| |
| env_file( |
| name = "toolchain_info_env", |
| src = "//rust/private:rust_analyzer_detect_sysroot", |
| key = "RUST_ANALYZER_TOOLCHAIN_JSON", |
| ) |
| |
| rust_library( |
| name = "gen_rust_project_lib", |
| srcs = glob( |
| ["**/*.rs"], |
| exclude = ["bin"], |
| ), |
| compile_data = [ |
| "//rust/private:rust_analyzer_detect_sysroot", |
| ], |
| edition = "2018", |
| rustc_env_files = [ |
| ":toolchain_info_env", |
| ], |
| deps = [ |
| "//rust/runfiles", |
| "//tools/rust_analyzer/3rdparty/crates:anyhow", |
| "//tools/rust_analyzer/3rdparty/crates:camino", |
| "//tools/rust_analyzer/3rdparty/crates:clap", |
| "//tools/rust_analyzer/3rdparty/crates:log", |
| "//tools/rust_analyzer/3rdparty/crates:serde", |
| "//tools/rust_analyzer/3rdparty/crates:serde_json", |
| ], |
| ) |
| |
| rust_test( |
| name = "gen_rust_project_lib_test", |
| crate = ":gen_rust_project_lib", |
| deps = [ |
| "//tools/rust_analyzer/3rdparty/crates:itertools", |
| ], |
| ) |
| |
| rust_clippy( |
| name = "gen_rust_project_clippy", |
| testonly = True, |
| visibility = ["//visibility:private"], |
| deps = [ |
| ":gen_rust_project", |
| ], |
| ) |
| |
| bzl_library( |
| name = "bzl_lib", |
| srcs = [], |
| visibility = ["//visibility:public"], |
| deps = ["//tools/rust_analyzer/3rdparty:bzl_lib"], |
| ) |