mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-07-30 20:58:45 +00:00
feat: split cmake var into name and value when it contains =
This commit is contained in:
parent
7e27614fb8
commit
af5c57f0f8
1 changed files with 21 additions and 16 deletions
|
@ -48,6 +48,21 @@ pub struct ProfileEditorInit {
|
||||||
pub profile: Profile,
|
pub profile: Profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This parses a var (either env var or cmake var) and if it contains
|
||||||
|
/// a '=' char, it assumes it's key and value, otherwise it's just going to
|
||||||
|
/// be the key and the value is gonna be an empty string
|
||||||
|
fn parse_var(input: &str) -> (String, String) {
|
||||||
|
if input.contains('=') {
|
||||||
|
let mut sp = input.split('=');
|
||||||
|
(
|
||||||
|
sp.next().unwrap().to_string(),
|
||||||
|
sp.next().unwrap().to_string(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(input.to_string(), "".to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[relm4::component(pub)]
|
#[relm4::component(pub)]
|
||||||
impl SimpleComponent for ProfileEditor {
|
impl SimpleComponent for ProfileEditor {
|
||||||
type Init = ProfileEditorInit;
|
type Init = ProfileEditorInit;
|
||||||
|
@ -428,33 +443,23 @@ impl SimpleComponent for ProfileEditor {
|
||||||
}
|
}
|
||||||
Self::Input::AddEnvVar(var) => {
|
Self::Input::AddEnvVar(var) => {
|
||||||
let mut prof = self.profile.borrow_mut();
|
let mut prof = self.profile.borrow_mut();
|
||||||
if !prof.environment.contains_key(&var) {
|
let (name, value) = parse_var(&var);
|
||||||
let (name, value) = if var.contains('=') {
|
if !prof.environment.contains_key(&name) {
|
||||||
let mut sp = var.split('=');
|
|
||||||
(
|
|
||||||
sp.next().unwrap().to_string(),
|
|
||||||
sp.next().unwrap().to_string(),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(var, "".to_string())
|
|
||||||
};
|
|
||||||
prof.environment.insert(name.clone(), value.clone());
|
prof.environment.insert(name.clone(), value.clone());
|
||||||
self.env_rows
|
self.env_rows
|
||||||
.guard()
|
.guard()
|
||||||
.push_back(EnvVarModelInit { name, value });
|
.push_back(EnvVarModelInit { name, value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Self::Input::AddXrServiceCmakeFlag(name) => {
|
Self::Input::AddXrServiceCmakeFlag(var) => {
|
||||||
let mut prof = self.profile.borrow_mut();
|
let mut prof = self.profile.borrow_mut();
|
||||||
|
let (name, value) = parse_var(&var);
|
||||||
if !prof.xrservice_cmake_flags.contains_key(&name) {
|
if !prof.xrservice_cmake_flags.contains_key(&name) {
|
||||||
prof.xrservice_cmake_flags
|
prof.xrservice_cmake_flags
|
||||||
.insert(name.clone(), "".to_string());
|
.insert(name.clone(), value.clone());
|
||||||
self.xrservice_cmake_flags_rows
|
self.xrservice_cmake_flags_rows
|
||||||
.guard()
|
.guard()
|
||||||
.push_back(EnvVarModelInit {
|
.push_back(EnvVarModelInit { name, value });
|
||||||
name,
|
|
||||||
value: "".to_string(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue