diff --git a/.cargo/config.toml b/.cargo/config.toml index e5c67dcfb..ed1dcf7e6 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,4 @@ [env] -# STRINGS_JSON = { value = "out/rslib/i18n/strings.json", relative = true } STRINGS_PY = { value = "out/pylib/anki/_fluent.py", relative = true } STRINGS_JS = { value = "out/ts/lib/ftl.js", relative = true } STRINGS_DTS = { value = "out/ts/lib/ftl.d.ts", relative = true } diff --git a/rslib/i18n/build.rs b/rslib/i18n/build.rs index 0f2478158..4baa6a709 100644 --- a/rslib/i18n/build.rs +++ b/rslib/i18n/build.rs @@ -8,7 +8,8 @@ mod python; mod typescript; mod write_strings; -use std::path::Path; +use std::env; +use std::path::PathBuf; use anki_io::create_dir_all; use anki_io::write_file_if_changed; @@ -32,10 +33,13 @@ fn main() -> Result<()> { // write strings.json file to requested path println!("cargo:rerun-if-env-changed=STRINGS_JSON"); - if let Some(path) = option_env!("STRINGS_JSON") { - let meta_json = serde_json::to_string_pretty(&modules).unwrap(); - create_dir_all(Path::new(path).parent().unwrap())?; - write_file_if_changed(path, meta_json)?; + if let Ok(path) = env::var("STRINGS_JSON") { + if !path.is_empty() { + let path = PathBuf::from(path); + let meta_json = serde_json::to_string_pretty(&modules).unwrap(); + create_dir_all(path.parent().unwrap())?; + write_file_if_changed(path, meta_json)?; + } } Ok(()) }