anki/rslib/i18n/build/main.rs
Damien Elmes 9701055eb5 Add support for using n2 instead of ninja
Provides better visibility into what the build is currently doing.
Motivated by slow node.js downloads making the build appear stuck.

You can test this out by running ./tools/install-n2 then building
normally. Please report any problems, and 'cargo uninstall n2' to get
back to the old behaviour. It works on Windows, but prints a new line
each second instead of redrawing the same area.

A couple of changes were required for compatibility:

- n2 doesn't resolve $variable names inside other variables, so the
resolution needs to be done by our build generator.
- Our inputs and outputs in build.ninja need to be listed in a deterministic
order to avoid unwanted rebuilds. I've made a few other tweaks so the
build file should now be fully-deterministic.
2023-06-15 17:17:56 +10:00

33 lines
899 B
Rust

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
mod check;
mod extract;
mod gather;
mod write_strings;
use anki_io::write_file_if_changed;
use anyhow::Result;
use check::check;
use extract::get_modules;
use gather::get_ftl_data;
use write_strings::write_strings;
// fixme: check all variables are present in translations as well?
fn main() -> Result<()> {
// generate our own requirements
let map = get_ftl_data();
check(&map);
let modules = get_modules(&map);
write_strings(&map, &modules);
// 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();
write_file_if_changed(path, meta_json)?;
}
Ok(())
}