mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add command line feature flags back to xtask; detect & track language changes
This commit is contained in:
parent
b1eecb4cca
commit
c52c02013e
2 changed files with 47 additions and 1 deletions
|
|
@ -134,6 +134,19 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
builder.add_apps(&extra_apps);
|
||||
let extra_services = get_flag("--service")?;
|
||||
builder.add_services(&extra_services);
|
||||
// extract features, and especially track language features
|
||||
let features = get_flag("--feature")?;
|
||||
let mut language_set = false;
|
||||
for feature in features {
|
||||
builder.add_feature(&feature);
|
||||
if feature.starts_with("xous/lang-") {
|
||||
track_language_changes(&feature)?;
|
||||
language_set = true;
|
||||
}
|
||||
}
|
||||
if !language_set { // the default language is english
|
||||
track_language_changes("en")?;
|
||||
}
|
||||
|
||||
// ---- now process the verb plus position dependent arguments ----
|
||||
let mut args = env::args();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use std::{
|
||||
fs::File,
|
||||
fs::{File, OpenOptions},
|
||||
io::{Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
|
|
@ -375,3 +375,36 @@ pub(crate) fn whycheproof_import() -> Result<(), crate::DynError> {
|
|||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
pub(crate) fn track_language_changes(last_lang: &str) -> Result<(), crate::DynError> {
|
||||
let last_config = format!("target/{}/LAST_LANG", TARGET_TRIPLE);
|
||||
std::fs::create_dir_all(format!("target/{}/", TARGET_TRIPLE)).unwrap();
|
||||
let mut contents = String::new();
|
||||
|
||||
let changed = match OpenOptions::new()
|
||||
.read(true)
|
||||
.open(&last_config) {
|
||||
Ok(mut file) => {
|
||||
file.read_to_string(&mut contents).unwrap();
|
||||
if contents != last_lang {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
_ => true
|
||||
};
|
||||
if changed {
|
||||
println!("Locale language changed to {}", last_lang);
|
||||
let mut file = OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.open(&last_config).unwrap();
|
||||
write!(file, "{}", last_lang).unwrap();
|
||||
generate_locales()?
|
||||
} else {
|
||||
println!("No change to the target locale language of {}", contents);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Reference in a new issue