parent
c22f6022fc
commit
fb9c934ef2
|
@ -118,6 +118,7 @@ dependencies = [
|
|||
"unicase",
|
||||
"unicode-normalization",
|
||||
"utime",
|
||||
"which",
|
||||
"zip",
|
||||
"zstd",
|
||||
]
|
||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "which",
|
||||
actual = "@raze__which__4_3_0//:which",
|
||||
tags = [
|
||||
"cargo-raze",
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "zip",
|
||||
actual = "@raze__zip__0_6_2//:zip",
|
||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "which",
|
||||
actual = "@raze__which__4_3_0//:which",
|
||||
tags = [
|
||||
"cargo-raze",
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "zip",
|
||||
actual = "@raze__zip__0_6_2//:zip",
|
||||
|
|
|
@ -31,6 +31,7 @@ cargo_build_script(
|
|||
],
|
||||
deps = [
|
||||
"//rslib/cargo:prost_build",
|
||||
"//rslib/cargo:which",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ required-features = ["bench"]
|
|||
|
||||
[build-dependencies]
|
||||
prost-build = "0.11.1"
|
||||
which = "4.3.0"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = "0.9.1"
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
use std::{env, fmt::Write, path::PathBuf};
|
||||
use std::{
|
||||
env,
|
||||
fmt::Write,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
struct CustomGenerator {}
|
||||
|
||||
|
@ -71,6 +75,7 @@ fn service_generator() -> Box<dyn prost_build::ServiceGenerator> {
|
|||
}
|
||||
|
||||
pub fn write_backend_proto_rs() {
|
||||
maybe_add_protobuf_to_path();
|
||||
let proto_dir = if let Ok(proto) = env::var("PROTO_TOP") {
|
||||
PathBuf::from(proto).parent().unwrap().to_owned()
|
||||
} else {
|
||||
|
@ -122,3 +127,24 @@ pub fn write_backend_proto_rs() {
|
|||
.compile_protos(paths.as_slice(), &[proto_dir])
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// If PROTOC is not defined, and protoc is not on path, use the protoc
|
||||
/// fetched by Bazel so that Rust Analyzer does not fail.
|
||||
fn maybe_add_protobuf_to_path() {
|
||||
if std::env::var("PROTOC").is_ok() {
|
||||
return;
|
||||
}
|
||||
if which::which("protoc").is_ok() {
|
||||
return;
|
||||
}
|
||||
let base = Path::new("../.bazel/out/../external");
|
||||
let subpath = if cfg!(target_os = "windows") {
|
||||
"protoc_bin_windows/bin/protoc.exe"
|
||||
} else if cfg!(target_os = "macos") {
|
||||
"protoc_bin_macos/bin/protoc"
|
||||
} else {
|
||||
"protoc_bin_linux_x86_64/bin/protoc"
|
||||
};
|
||||
let path = base.join(subpath);
|
||||
std::env::set_var("PROTOC", path.to_str().unwrap());
|
||||
}
|
||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "which",
|
||||
actual = "@raze__which__4_3_0//:which",
|
||||
tags = [
|
||||
"cargo-raze",
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "zip",
|
||||
actual = "@raze__zip__0_6_2//:zip",
|
||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "which",
|
||||
actual = "@raze__which__4_3_0//:which",
|
||||
tags = [
|
||||
"cargo-raze",
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "zip",
|
||||
actual = "@raze__zip__0_6_2//:zip",
|
||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "which",
|
||||
actual = "@raze__which__4_3_0//:which",
|
||||
tags = [
|
||||
"cargo-raze",
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "zip",
|
||||
actual = "@raze__zip__0_6_2//:zip",
|
||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
|||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "which",
|
||||
actual = "@raze__which__4_3_0//:which",
|
||||
tags = [
|
||||
"cargo-raze",
|
||||
"manual",
|
||||
],
|
||||
)
|
||||
|
||||
alias(
|
||||
name = "zip",
|
||||
actual = "@raze__zip__0_6_2//:zip",
|
||||
|
|
Loading…
Reference in New Issue