mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add submenu context generation to manifest format
adding a key of "submenu" will automatically create the corresponding integer argument of submenu contexts for the app. NB: you should try to only create 1 and re-use it. Menus are resource hungry, and will rapidly eat through your connection and thread table.
This commit is contained in:
parent
85a43b0a7d
commit
4eac32ba60
1 changed files with 26 additions and 1 deletions
|
|
@ -1663,6 +1663,7 @@ use std::string::String;
|
||||||
struct AppManifest {
|
struct AppManifest {
|
||||||
context_name: String,
|
context_name: String,
|
||||||
menu_name: HashMap<String, HashMap<String, String>>,
|
menu_name: HashMap<String, HashMap<String, String>>,
|
||||||
|
submenu: Option::<u8>,
|
||||||
}
|
}
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
struct Locales {
|
struct Locales {
|
||||||
|
|
@ -1720,14 +1721,38 @@ fn generate_app_menus(apps: &Vec<String>) {
|
||||||
manifest.context_name,
|
manifest.context_name,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
if let Some(menu_count) = manifest.submenu {
|
||||||
|
for i in 0..menu_count {
|
||||||
|
writeln!(
|
||||||
|
gam_tokens,
|
||||||
|
"pub const APP_MENU_{}_{}: &'static str = \"{} Submenu {}\";",
|
||||||
|
i,
|
||||||
|
app_name.to_uppercase(),
|
||||||
|
manifest.context_name,
|
||||||
|
i,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
writeln!(
|
writeln!(
|
||||||
gam_tokens,
|
gam_tokens,
|
||||||
"\npub const EXPECTED_APP_CONTEXTS: &[&'static str] = &["
|
"\npub const EXPECTED_APP_CONTEXTS: &[&'static str] = &["
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
for (app_name, _manifest) in working_set.iter() {
|
for (app_name, manifest) in working_set.iter() {
|
||||||
writeln!(gam_tokens, " APP_NAME_{},", app_name.to_uppercase(),).unwrap();
|
writeln!(gam_tokens, " APP_NAME_{},", app_name.to_uppercase(),).unwrap();
|
||||||
|
if let Some(menu_count) = manifest.submenu {
|
||||||
|
for i in 0..menu_count {
|
||||||
|
writeln!(
|
||||||
|
gam_tokens,
|
||||||
|
" APP_MENU_{}_{},",
|
||||||
|
i,
|
||||||
|
app_name.to_uppercase(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
writeln!(gam_tokens, "];").unwrap();
|
writeln!(gam_tokens, "];").unwrap();
|
||||||
overwrite_if_changed(&gam_tokens, "services/gam/src/apps.rs");
|
overwrite_if_changed(&gam_tokens, "services/gam/src/apps.rs");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue