mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 14:49:04 +00:00
feat!: getting runners output consumes it; profiles include an install prefix; runner pipeline for building; can link local libsurvive when building monado
This commit is contained in:
parent
377992c2cc
commit
7745b364e3
11 changed files with 166 additions and 33 deletions
|
@ -4,11 +4,25 @@ set -ev
|
||||||
|
|
||||||
REPO_DIR=$1
|
REPO_DIR=$1
|
||||||
|
|
||||||
|
PREFIX=$2
|
||||||
|
|
||||||
|
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]]; then
|
||||||
|
echo "Usage: $0 REPO_DIR PREFIX"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR"
|
"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR"
|
||||||
|
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_api_example=OFF -DCMAKE_SKIP_INSTALL_RPATH=YES -Wno-dev ..
|
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DENABLE_api_example=OFF \
|
||||||
|
-DCMAKE_SKIP_INSTALL_RPATH=YES \
|
||||||
|
-Wno-dev \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
|
||||||
|
-DCMAKE_INSTALL_LIBDIR="${PREFIX}/lib" \
|
||||||
|
..
|
||||||
make clean
|
make clean
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
make install
|
||||||
|
|
|
@ -6,11 +6,23 @@ set -ev
|
||||||
|
|
||||||
REPO_DIR=$1
|
REPO_DIR=$1
|
||||||
|
|
||||||
"$(dirname -- "$0")/_clone_or_pull.sh" "https://github.com/cntools/libsurvive" "$REPO_DIR"
|
PREFIX=$2
|
||||||
|
|
||||||
|
if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]]; then
|
||||||
|
echo "Usage: $0 REPO_DIR PREFIX"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$(dirname -- "$0")/_clone_or_pull.sh" "https://gitlab.freedesktop.org/monado/monado" "$REPO_DIR"
|
||||||
|
|
||||||
cd "$REPO_DIR"
|
cd "$REPO_DIR"
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||||
|
-DCMAKE_LIBDIR="${PREFIX}/lib" \
|
||||||
|
-DCMAKE_INSTALL_PREFIX="${PREFIX}" \
|
||||||
|
..
|
||||||
make clean
|
make clean
|
||||||
make -j$(nproc)
|
make -j$(nproc)
|
||||||
|
make install
|
||||||
|
|
|
@ -5,9 +5,12 @@ pub fn get_build_libsurvive_runner(profile: Profile) -> Runner {
|
||||||
let runner = Runner::new(
|
let runner = Runner::new(
|
||||||
None,
|
None,
|
||||||
"./scripts/build_libsurvive.sh".into(),
|
"./scripts/build_libsurvive.sh".into(),
|
||||||
vec![profile
|
vec![
|
||||||
|
profile
|
||||||
.libsurvive_path
|
.libsurvive_path
|
||||||
.expect_dialog("Missing libsurvive path for given profile")],
|
.expect_dialog("Missing libsurvive path for given profile"),
|
||||||
|
profile.prefix,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,8 @@ pub fn get_build_monado_runner(profile: Profile) -> Runner {
|
||||||
None,
|
None,
|
||||||
"./scripts/build_monado.sh".into(),
|
"./scripts/build_monado.sh".into(),
|
||||||
vec![
|
vec![
|
||||||
profile.monado_path
|
profile.monado_path,
|
||||||
|
profile.prefix,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
runner
|
runner
|
||||||
|
|
|
@ -13,6 +13,7 @@ pub mod profile;
|
||||||
pub mod profiles;
|
pub mod profiles;
|
||||||
pub mod runner;
|
pub mod runner;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
pub mod runner_pipeline;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let app = RelmApp::new(APP_ID);
|
let app = RelmApp::new(APP_ID);
|
||||||
|
|
|
@ -16,6 +16,8 @@ pub struct Profile {
|
||||||
pub basalt_enabled: bool,
|
pub basalt_enabled: bool,
|
||||||
pub mercury_enabled: bool,
|
pub mercury_enabled: bool,
|
||||||
pub environment: HashMap<String, String>,
|
pub environment: HashMap<String, String>,
|
||||||
|
/** Install prefix */
|
||||||
|
pub prefix: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Profile {
|
impl Display for Profile {
|
||||||
|
@ -47,6 +49,7 @@ mod tests {
|
||||||
assert_eq!(profile.name, "Demo profile");
|
assert_eq!(profile.name, "Demo profile");
|
||||||
assert_eq!(profile.monado_path, "/home/user/monado");
|
assert_eq!(profile.monado_path, "/home/user/monado");
|
||||||
assert_eq!(profile.openovr_path, "/home/user/openovr");
|
assert_eq!(profile.openovr_path, "/home/user/openovr");
|
||||||
|
assert_eq!(profile.prefix, "/home/user/rex2prefix");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
profile.libsurvive_path.as_deref(),
|
profile.libsurvive_path.as_deref(),
|
||||||
Some("/home/user/libsurvive")
|
Some("/home/user/libsurvive")
|
||||||
|
@ -81,6 +84,7 @@ mod tests {
|
||||||
basalt_enabled: false,
|
basalt_enabled: false,
|
||||||
mercury_enabled: false,
|
mercury_enabled: false,
|
||||||
environment: env,
|
environment: env,
|
||||||
|
prefix: String::from("/home/user/rex2prefix")
|
||||||
};
|
};
|
||||||
let fpath = String::from("./target/testout/testprofile.json");
|
let fpath = String::from("./target/testout/testprofile.json");
|
||||||
dump_profile(p, &fpath);
|
dump_profile(p, &fpath);
|
||||||
|
|
|
@ -3,11 +3,13 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
pub fn valve_index_profile() -> Profile {
|
pub fn valve_index_profile() -> Profile {
|
||||||
let data_dir = get_data_dir();
|
let data_dir = get_data_dir();
|
||||||
|
let prefix = format!("{data}/prefixes/valve_index_default", data = data_dir);
|
||||||
let mut environment: HashMap<String, String> = HashMap::new();
|
let mut environment: HashMap<String, String> = HashMap::new();
|
||||||
environment.insert("XRT_COMPOSITOR_SCALE_PERCENTAGE".into(), "140".into());
|
environment.insert("XRT_COMPOSITOR_SCALE_PERCENTAGE".into(), "140".into());
|
||||||
environment.insert("XRT_COMPOSITOR_COMPUTE".into(), "1".into());
|
environment.insert("XRT_COMPOSITOR_COMPUTE".into(), "1".into());
|
||||||
environment.insert("SURVIVE_GLOBALSCENESOLVER".into(), "0".into());
|
environment.insert("SURVIVE_GLOBALSCENESOLVER".into(), "0".into());
|
||||||
environment.insert("SURVIVE_TIMECODE_OFFSET_MS".into(), "-6.94".into());
|
environment.insert("SURVIVE_TIMECODE_OFFSET_MS".into(), "-6.94".into());
|
||||||
|
environment.insert("LD_LIBRARY_PATH".into(), format!("{pfx}/lib", pfx = prefix));
|
||||||
Profile {
|
Profile {
|
||||||
name: format!("Valve Index - {name} Default", name = APP_NAME),
|
name: format!("Valve Index - {name} Default", name = APP_NAME),
|
||||||
monado_path: format!("{data}/monado", data = data_dir),
|
monado_path: format!("{data}/monado", data = data_dir),
|
||||||
|
@ -19,5 +21,6 @@ pub fn valve_index_profile() -> Profile {
|
||||||
basalt_enabled: false,
|
basalt_enabled: false,
|
||||||
mercury_enabled: false,
|
mercury_enabled: false,
|
||||||
environment,
|
environment,
|
||||||
|
prefix,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,11 +87,11 @@ impl Runner {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn monado_runner_from_profile(profile: Profile) -> Self {
|
pub fn monado_runner_from_profile(profile: Profile) -> Self {
|
||||||
let mut path = profile.monado_path;
|
Self::new(
|
||||||
if !path.starts_with("/usr") {
|
Some(profile.environment),
|
||||||
path += "/build/src/xrt/targets/service/monado-service";
|
format!("{pfx}/bin/monado-service", pfx = profile.prefix),
|
||||||
}
|
vec![],
|
||||||
Self::new(Some(profile.environment), path, vec![])
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(&mut self) {
|
pub fn start(&mut self) {
|
||||||
|
@ -157,14 +157,18 @@ impl Runner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_output(&mut self) -> String {
|
pub fn consume_output(&mut self) -> String {
|
||||||
self.receive_output();
|
self.receive_output();
|
||||||
self.output.concat()
|
let res = self.output.concat();
|
||||||
|
self.output.clear();
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rows(&mut self) -> Vec<String> {
|
pub fn consume_rows(&mut self) -> Vec<String> {
|
||||||
self.receive_output();
|
self.receive_output();
|
||||||
self.output.clone()
|
let res = self.output.clone();
|
||||||
|
self.output.clear();
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn save_log(path_s: String, log: &Vec<String>) -> Result<(), std::io::Error> {
|
fn save_log(path_s: String, log: &Vec<String>) -> Result<(), std::io::Error> {
|
||||||
|
@ -199,7 +203,7 @@ mod tests {
|
||||||
sleep(time::Duration::from_millis(10));
|
sleep(time::Duration::from_millis(10));
|
||||||
runner.terminate();
|
runner.terminate();
|
||||||
assert_eq!(runner.status(), RunnerStatus::Stopped);
|
assert_eq!(runner.status(), RunnerStatus::Stopped);
|
||||||
let out = runner.get_output();
|
let out = runner.consume_output();
|
||||||
assert_eq!(out, "REX2TEST: Lorem ipsum dolor\n");
|
assert_eq!(out, "REX2TEST: Lorem ipsum dolor\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +226,6 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_create_from_profile() {
|
fn can_create_from_profile() {
|
||||||
Runner::monado_runner_from_profile(
|
Runner::monado_runner_from_profile(load_profile(&"./test/files/profile.json".to_string()));
|
||||||
load_profile(&"./test/files/profile.json".to_string()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
79
src/runner_pipeline.rs
Normal file
79
src/runner_pipeline.rs
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
use std::{cell::RefCell, borrow::BorrowMut};
|
||||||
|
|
||||||
|
use crate::runner::{Runner, RunnerStatus};
|
||||||
|
|
||||||
|
pub struct RunnerPipeline {
|
||||||
|
runners: Vec<RefCell<Runner>>,
|
||||||
|
current_index: usize,
|
||||||
|
has_started: bool,
|
||||||
|
pub log: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RunnerPipeline {
|
||||||
|
pub fn new(runners: Vec<Runner>) -> Self {
|
||||||
|
let mut c_runners: Vec<RefCell<Runner>> = vec![];
|
||||||
|
for runner in runners {
|
||||||
|
c_runners.push(RefCell::new(runner));
|
||||||
|
}
|
||||||
|
Self {
|
||||||
|
runners: c_runners,
|
||||||
|
current_index: 0,
|
||||||
|
has_started: false,
|
||||||
|
log: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_current_runner(&self) -> Option<&RefCell<Runner>> {
|
||||||
|
self.runners.get(self.current_index)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start(&mut self) {
|
||||||
|
if self.has_started {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.has_started = true;
|
||||||
|
match self.get_current_runner() {
|
||||||
|
None => { return; },
|
||||||
|
Some(runner) => {
|
||||||
|
runner.borrow_mut().start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn update(&mut self) {
|
||||||
|
if !self.has_started {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.get_current_runner() {
|
||||||
|
None => {},
|
||||||
|
Some(c_runner) => {
|
||||||
|
let (status, log) = {
|
||||||
|
let mut runner = c_runner.borrow_mut();
|
||||||
|
(runner.status(), runner.consume_rows())
|
||||||
|
};
|
||||||
|
self.log.extend(log);
|
||||||
|
match status {
|
||||||
|
RunnerStatus::Running => {},
|
||||||
|
RunnerStatus::Stopped => {
|
||||||
|
self.current_index += 1;
|
||||||
|
match self.get_current_runner() {
|
||||||
|
None => {},
|
||||||
|
Some(c_runner) => {
|
||||||
|
c_runner.borrow_mut().start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_log(&self) -> String {
|
||||||
|
self.log.concat()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_running(&self) -> bool {
|
||||||
|
self.get_current_runner().is_some()
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use crate::builders::build_libsurvive::get_build_libsurvive_runner;
|
||||||
use crate::builders::build_monado::get_build_monado_runner;
|
use crate::builders::build_monado::get_build_monado_runner;
|
||||||
use crate::config::{get_config, save_config, Config};
|
use crate::config::{get_config, save_config, Config};
|
||||||
use crate::constants::APP_NAME;
|
use crate::constants::APP_NAME;
|
||||||
|
@ -8,6 +9,7 @@ use crate::dependencies::monado_deps::{check_monado_deps, get_missing_monado_dep
|
||||||
use crate::profile::Profile;
|
use crate::profile::Profile;
|
||||||
use crate::profiles::valve_index::valve_index_profile;
|
use crate::profiles::valve_index::valve_index_profile;
|
||||||
use crate::runner::{Runner, RunnerStatus};
|
use crate::runner::{Runner, RunnerStatus};
|
||||||
|
use crate::runner_pipeline::RunnerPipeline;
|
||||||
use crate::ui::build_window::BuildWindowMsg;
|
use crate::ui::build_window::BuildWindowMsg;
|
||||||
use crate::ui::debug_view::DebugViewInit;
|
use crate::ui::debug_view::DebugViewInit;
|
||||||
use crate::ui::main_view::{MainView, MainViewInit, MainViewOutMsg};
|
use crate::ui::main_view::{MainView, MainViewInit, MainViewOutMsg};
|
||||||
|
@ -45,7 +47,9 @@ pub struct App {
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
monado_runner: Option<Runner>,
|
monado_runner: Option<Runner>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
build_runner: Option<Runner>,
|
monado_log: Vec<String>,
|
||||||
|
#[tracker::do_not_track]
|
||||||
|
build_pipeline: Option<RunnerPipeline>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
profiles: Vec<Profile>,
|
profiles: Vec<Profile>,
|
||||||
}
|
}
|
||||||
|
@ -75,6 +79,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_monado(&mut self) {
|
pub fn start_monado(&mut self) {
|
||||||
|
self.monado_log.clear();
|
||||||
let mut runner = Runner::monado_runner_from_profile(self.get_selected_profile().clone());
|
let mut runner = Runner::monado_runner_from_profile(self.get_selected_profile().clone());
|
||||||
runner.start();
|
runner.start();
|
||||||
self.monado_runner = Some(runner);
|
self.monado_runner = Some(runner);
|
||||||
|
@ -131,22 +136,24 @@ impl SimpleComponent for App {
|
||||||
None => {}
|
None => {}
|
||||||
Some(runner) => match runner.status() {
|
Some(runner) => match runner.status() {
|
||||||
RunnerStatus::Running => {
|
RunnerStatus::Running => {
|
||||||
|
self.monado_log.extend(runner.consume_rows());
|
||||||
self.debug_view
|
self.debug_view
|
||||||
.sender()
|
.sender()
|
||||||
.emit(DebugViewMsg::LogUpdated(runner.get_rows()));
|
.emit(DebugViewMsg::LogUpdated(self.monado_log.clone()));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
match &mut self.build_runner {
|
match &mut self.build_pipeline {
|
||||||
None => {}
|
None => {}
|
||||||
Some(runner) => match runner.status() {
|
Some(pipeline) => match pipeline.is_running() {
|
||||||
RunnerStatus::Running => {
|
true => {
|
||||||
|
pipeline.update();
|
||||||
self.build_window
|
self.build_window
|
||||||
.sender()
|
.sender()
|
||||||
.emit(BuildWindowMsg::UpdateContent(runner.get_output()));
|
.emit(BuildWindowMsg::UpdateContent(pipeline.get_log()));
|
||||||
}
|
},
|
||||||
RunnerStatus::Stopped => {
|
false => {
|
||||||
self.build_window
|
self.build_window
|
||||||
.sender()
|
.sender()
|
||||||
.emit(BuildWindowMsg::UpdateCanClose(true));
|
.emit(BuildWindowMsg::UpdateCanClose(true));
|
||||||
|
@ -196,15 +203,20 @@ impl SimpleComponent for App {
|
||||||
Msg::BuildProfile => {
|
Msg::BuildProfile => {
|
||||||
let profile = self.get_selected_profile();
|
let profile = self.get_selected_profile();
|
||||||
let mut missing_deps = get_missing_monado_deps();
|
let mut missing_deps = get_missing_monado_deps();
|
||||||
|
let mut runners: Vec<Runner> = vec![];
|
||||||
if profile.libsurvive_enabled {
|
if profile.libsurvive_enabled {
|
||||||
missing_deps.extend(get_missing_libsurvive_deps());
|
missing_deps.extend(get_missing_libsurvive_deps());
|
||||||
|
runners.push(get_build_libsurvive_runner(profile.clone()));
|
||||||
}
|
}
|
||||||
// if profile.basalt_enabled {
|
// if profile.basalt_enabled {
|
||||||
// missing_deps.extend(get_missing_basalt_deps());
|
// missing_deps.extend(get_missing_basalt_deps());
|
||||||
|
// runners.push(get_build_basalt_runner(profile.clone()));
|
||||||
// }
|
// }
|
||||||
// if profile.mercury_enabled {
|
// if profile.mercury_enabled {
|
||||||
// missing_deps.extend(get_missing_mercury_deps());
|
// missing_deps.extend(get_missing_mercury_deps());
|
||||||
|
// runners.push(get_build_mercury_runner(profile.clone()));
|
||||||
// }
|
// }
|
||||||
|
runners.push(get_build_monado_runner(profile.clone()));
|
||||||
if !missing_deps.is_empty() {
|
if !missing_deps.is_empty() {
|
||||||
self.dependencies_dialog.set_body(
|
self.dependencies_dialog.set_body(
|
||||||
missing_deps
|
missing_deps
|
||||||
|
@ -221,15 +233,15 @@ impl SimpleComponent for App {
|
||||||
.sender()
|
.sender()
|
||||||
.send(BuildWindowMsg::Present)
|
.send(BuildWindowMsg::Present)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut runner = get_build_monado_runner(profile.clone());
|
let mut pipeline = RunnerPipeline::new(runners);
|
||||||
runner.start();
|
pipeline.start();
|
||||||
self.build_window
|
self.build_window
|
||||||
.sender()
|
.sender()
|
||||||
.emit(BuildWindowMsg::UpdateTitle("Building Monado".into()));
|
.emit(BuildWindowMsg::UpdateTitle("Building Monado".into()));
|
||||||
self.build_window
|
self.build_window
|
||||||
.sender()
|
.sender()
|
||||||
.emit(BuildWindowMsg::UpdateCanClose(false));
|
.emit(BuildWindowMsg::UpdateCanClose(false));
|
||||||
self.build_runner = Some(runner);
|
self.build_pipeline = Some(pipeline);
|
||||||
}
|
}
|
||||||
Msg::ProfileSelected(prof_name) => {
|
Msg::ProfileSelected(prof_name) => {
|
||||||
self.config.selected_profile_name = prof_name;
|
self.config.selected_profile_name = prof_name;
|
||||||
|
@ -284,7 +296,8 @@ impl SimpleComponent for App {
|
||||||
tracker: 0,
|
tracker: 0,
|
||||||
profiles,
|
profiles,
|
||||||
monado_runner: None,
|
monado_runner: None,
|
||||||
build_runner: None,
|
monado_log: vec![],
|
||||||
|
build_pipeline: None,
|
||||||
};
|
};
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
|
|
||||||
|
|
|
@ -12,5 +12,6 @@
|
||||||
"XRT_COMPOSITOR_SCALE_PERCENTAGE": "140",
|
"XRT_COMPOSITOR_SCALE_PERCENTAGE": "140",
|
||||||
"XRT_COMPOSITOR_COMPUTE": "1",
|
"XRT_COMPOSITOR_COMPUTE": "1",
|
||||||
"SURVIVE_GLOBALSCENESOLVER": "0"
|
"SURVIVE_GLOBALSCENESOLVER": "0"
|
||||||
}
|
},
|
||||||
|
"prefix": "/home/user/rex2prefix"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue