mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-22 20:44:50 +00:00
feat: cmake rust helper
This commit is contained in:
parent
4fb3d37551
commit
a2b5057931
4 changed files with 37 additions and 9 deletions
35
src/build_tools/cmake.rs
Normal file
35
src/build_tools/cmake.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use std::collections::HashMap;
|
||||
use crate::runner::Runner;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Cmake {
|
||||
pub build_dir: String,
|
||||
pub source_dir: String,
|
||||
pub vars: Option<HashMap<String, String>>,
|
||||
pub env: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl Cmake {
|
||||
pub fn get_prepare_runner(&self) -> Runner {
|
||||
let mut args = vec![
|
||||
"-B".into(), self.build_dir.clone(),
|
||||
"-G".into(), "Ninja".into(),
|
||||
];
|
||||
if self.vars.is_some() {
|
||||
for (k, v) in self.vars.as_ref().unwrap() {
|
||||
if k.contains(" ") {
|
||||
panic!("Cmake vars cannot contain spaces!");
|
||||
}
|
||||
args.push(format!("-D{k}=\"{v}\"", k=k, v=v));
|
||||
}
|
||||
}
|
||||
args.push(self.source_dir.clone());
|
||||
Runner::new(self.env.clone(), "cmake".into(), args)
|
||||
}
|
||||
|
||||
pub fn get_build_runner(&self) -> Runner {
|
||||
Runner::new(self.env.clone(), "cmake".into(), vec![
|
||||
"--build".into(), self.build_dir.clone()
|
||||
])
|
||||
}
|
||||
}
|
1
src/build_tools/mod.rs
Normal file
1
src/build_tools/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod cmake;
|
|
@ -32,6 +32,7 @@ pub mod runner;
|
|||
pub mod runner_pipeline;
|
||||
pub mod ui;
|
||||
pub mod xr_devices;
|
||||
pub mod build_tools;
|
||||
|
||||
fn restore_steam_xr_files() {
|
||||
let active_runtime = get_current_active_runtime();
|
||||
|
|
|
@ -103,15 +103,6 @@ pub enum Msg {
|
|||
}
|
||||
|
||||
impl App {
|
||||
fn get_profile_by_name(&self, name: &String) -> Option<&Profile> {
|
||||
for profile in &self.profiles {
|
||||
if &profile.name == name {
|
||||
return Some(profile);
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
pub fn get_selected_profile(&self) -> Profile {
|
||||
self.config.get_selected_profile(&self.profiles)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue