mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
parent
c22f6022fc
commit
fb9c934ef2
10 changed files with 84 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -118,6 +118,7 @@ dependencies = [
|
||||||
"unicase",
|
"unicase",
|
||||||
"unicode-normalization",
|
"unicode-normalization",
|
||||||
"utime",
|
"utime",
|
||||||
|
"which",
|
||||||
"zip",
|
"zip",
|
||||||
"zstd",
|
"zstd",
|
||||||
]
|
]
|
||||||
|
|
|
@ -579,6 +579,15 @@ alias(
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
alias(
|
||||||
|
name = "which",
|
||||||
|
actual = "@raze__which__4_3_0//:which",
|
||||||
|
tags = [
|
||||||
|
"cargo-raze",
|
||||||
|
"manual",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
alias(
|
alias(
|
||||||
name = "zip",
|
name = "zip",
|
||||||
actual = "@raze__zip__0_6_2//: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(
|
alias(
|
||||||
name = "zip",
|
name = "zip",
|
||||||
actual = "@raze__zip__0_6_2//:zip",
|
actual = "@raze__zip__0_6_2//:zip",
|
||||||
|
|
|
@ -31,6 +31,7 @@ cargo_build_script(
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//rslib/cargo:prost_build",
|
"//rslib/cargo:prost_build",
|
||||||
|
"//rslib/cargo:which",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ required-features = ["bench"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
prost-build = "0.11.1"
|
prost-build = "0.11.1"
|
||||||
|
which = "4.3.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.9.1"
|
env_logger = "0.9.1"
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
// Copyright: Ankitects Pty Ltd and contributors
|
// Copyright: Ankitects Pty Ltd and contributors
|
||||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
// 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 {}
|
struct CustomGenerator {}
|
||||||
|
|
||||||
|
@ -71,6 +75,7 @@ fn service_generator() -> Box<dyn prost_build::ServiceGenerator> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_backend_proto_rs() {
|
pub fn write_backend_proto_rs() {
|
||||||
|
maybe_add_protobuf_to_path();
|
||||||
let proto_dir = if let Ok(proto) = env::var("PROTO_TOP") {
|
let proto_dir = if let Ok(proto) = env::var("PROTO_TOP") {
|
||||||
PathBuf::from(proto).parent().unwrap().to_owned()
|
PathBuf::from(proto).parent().unwrap().to_owned()
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,3 +127,24 @@ pub fn write_backend_proto_rs() {
|
||||||
.compile_protos(paths.as_slice(), &[proto_dir])
|
.compile_protos(paths.as_slice(), &[proto_dir])
|
||||||
.unwrap();
|
.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(
|
alias(
|
||||||
name = "zip",
|
name = "zip",
|
||||||
actual = "@raze__zip__0_6_2//: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(
|
alias(
|
||||||
name = "zip",
|
name = "zip",
|
||||||
actual = "@raze__zip__0_6_2//: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(
|
alias(
|
||||||
name = "zip",
|
name = "zip",
|
||||||
actual = "@raze__zip__0_6_2//: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(
|
alias(
|
||||||
name = "zip",
|
name = "zip",
|
||||||
actual = "@raze__zip__0_6_2//:zip",
|
actual = "@raze__zip__0_6_2//:zip",
|
||||||
|
|
Loading…
Reference in a new issue