mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
don't pass BUILDINFO into build script
It was causing the build script to be recompiled each time a commit was made, even though buildinfo.txt was not changing.
This commit is contained in:
parent
019a65efc1
commit
ebeae9a5a0
3 changed files with 18 additions and 12 deletions
|
@ -14,13 +14,12 @@ cargo_build_script(
|
||||||
"PROTOC": "$(location @com_google_protobuf//:protoc)",
|
"PROTOC": "$(location @com_google_protobuf//:protoc)",
|
||||||
"RSLIB_FTL_ROOT": "$(location @rslib_ftl//:l10n.toml)",
|
"RSLIB_FTL_ROOT": "$(location @rslib_ftl//:l10n.toml)",
|
||||||
"EXTRA_FTL_ROOT": "$(location @extra_ftl//:l10n.toml)",
|
"EXTRA_FTL_ROOT": "$(location @extra_ftl//:l10n.toml)",
|
||||||
"BUILDINFO": "$(location //:buildinfo.txt)",
|
"BAZEL": "1",
|
||||||
},
|
},
|
||||||
crate_root = "build/main.rs",
|
crate_root = "build/main.rs",
|
||||||
data = [
|
data = [
|
||||||
"//ftl",
|
"//ftl",
|
||||||
"backend.proto",
|
"backend.proto",
|
||||||
"//:buildinfo.txt",
|
|
||||||
"@com_google_protobuf//:protoc",
|
"@com_google_protobuf//:protoc",
|
||||||
# bazel requires us to list these out separately
|
# bazel requires us to list these out separately
|
||||||
"@rslib_ftl//:l10n.toml",
|
"@rslib_ftl//:l10n.toml",
|
||||||
|
@ -50,6 +49,10 @@ _anki_features = [
|
||||||
"translations",
|
"translations",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
_anki_rustc_env = {
|
||||||
|
"BUILDINFO": "$(location //:buildinfo.txt)",
|
||||||
|
}
|
||||||
|
|
||||||
rust_library(
|
rust_library(
|
||||||
name = "anki",
|
name = "anki",
|
||||||
srcs = glob([
|
srcs = glob([
|
||||||
|
@ -61,6 +64,7 @@ rust_library(
|
||||||
"//rslib/cargo:serde_derive",
|
"//rslib/cargo:serde_derive",
|
||||||
"//rslib/cargo:serde_repr",
|
"//rslib/cargo:serde_repr",
|
||||||
],
|
],
|
||||||
|
rustc_env = _anki_rustc_env,
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
":build_script",
|
":build_script",
|
||||||
|
@ -121,6 +125,7 @@ rust_test(
|
||||||
data = glob([
|
data = glob([
|
||||||
"tests/support/**",
|
"tests/support/**",
|
||||||
]),
|
]),
|
||||||
|
rustc_env = _anki_rustc_env,
|
||||||
deps = ["//rslib/cargo:env_logger"],
|
deps = ["//rslib/cargo:env_logger"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,14 @@ fn main() {
|
||||||
mergeftl::write_ftl_files_and_fluent_rs();
|
mergeftl::write_ftl_files_and_fluent_rs();
|
||||||
protobuf::write_backend_proto_rs();
|
protobuf::write_backend_proto_rs();
|
||||||
|
|
||||||
// copy or mock buildinfo in out_dir
|
// when building with cargo (eg for rust analyzer), generate a dummy BUILDINFO
|
||||||
let buildinfo = if let Ok(buildinfo) = std::env::var("BUILDINFO") {
|
if std::env::var("BAZEL").is_err() {
|
||||||
std::fs::read_to_string(&buildinfo).expect("buildinfo missing")
|
let buildinfo_out =
|
||||||
} else {
|
std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).join("buildinfo.txt");
|
||||||
"".to_string()
|
std::fs::write(&buildinfo_out, "").unwrap();
|
||||||
};
|
println!(
|
||||||
let buildinfo_out =
|
"cargo:rustc-env=BUILDINFO={}",
|
||||||
std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).join("buildinfo.txt");
|
buildinfo_out.to_str().expect("buildinfo")
|
||||||
std::fs::write(&buildinfo_out, buildinfo).unwrap();
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use lazy_static::lazy_static;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
fn buildinfo(key: &str) -> &'static str {
|
fn buildinfo(key: &str) -> &'static str {
|
||||||
let buildinfo = include_str!(concat!(env!("OUT_DIR"), "/buildinfo.txt"));
|
let buildinfo = include_str!(env!("BUILDINFO"));
|
||||||
for line in buildinfo.split('\n') {
|
for line in buildinfo.split('\n') {
|
||||||
let mut it = line.split(' ');
|
let mut it = line.split(' ');
|
||||||
if it.next().unwrap() == key {
|
if it.next().unwrap() == key {
|
||||||
|
|
Loading…
Reference in a new issue