use option_env! instead of rerun-if-env-changed

> As of 1.46, using env! and option_env! in source code will automatically detect changes and trigger rebuilds.
https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-env-changed
This commit is contained in:
llama 2025-11-20 20:27:48 +08:00
parent 74b61d2a1b
commit 9a6842057a
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3

View file

@ -8,7 +8,6 @@ mod python;
mod typescript;
mod write_strings;
use std::env;
use std::path::PathBuf;
use anki_io::create_dir_all;
@ -32,8 +31,7 @@ fn main() -> Result<()> {
python::write_py_interface(&modules)?;
// write strings.json file to requested path
println!("cargo:rerun-if-env-changed=STRINGS_JSON");
if let Ok(path) = env::var("STRINGS_JSON") {
if let Some(path) = option_env!("STRINGS_JSON") {
if !path.is_empty() {
let path = PathBuf::from(path);
let meta_json = serde_json::to_string_pretty(&modules).unwrap();