mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-20 11:35:48 +00:00
feat: add support for mercury
This commit is contained in:
parent
c27fc65c62
commit
b0eda9993d
9 changed files with 126 additions and 50 deletions
57
scripts/build_mercury.sh
Executable file
57
scripts/build_mercury.sh
Executable file
|
@ -0,0 +1,57 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ev
|
||||
|
||||
PREFIX=$1
|
||||
|
||||
CACHE_DIR=$2
|
||||
|
||||
if [[ -z $PREFIX ]] || [[ -z $CACHE_DIR ]]; then
|
||||
echo "Usage: $0 PREFIX CACHE_DIR"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ONNX_VER=$(curl -sSL "https://api.github.com/repos/microsoft/onnxruntime/releases/latest" | jq -r .tag_name | tr -d v)
|
||||
SYS_ARCH=$(uname -m)
|
||||
|
||||
if [[ $SYS_ARCH == x*64 ]]; then
|
||||
ARCH="x64"
|
||||
elif [[ $SYS_ARCH == arm64 ]] || [[ $ARCH == aarch64 ]]; then
|
||||
ARCH="aarch64"
|
||||
else
|
||||
echo "CPU architecture '$SYS_ARCH' is not supported"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ONNX="onnxruntime-linux-${ARCH}-${ONNX_VER}"
|
||||
ONNX_URL="https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_VER}/${ONNX}.tgz"
|
||||
|
||||
mkdir -p "$CACHE_DIR"
|
||||
|
||||
curl -sSL "$ONNX_URL" -o "${CACHE_DIR}/onnxruntime.tgz"
|
||||
|
||||
tar xf "${CACHE_DIR}/onnxruntime.tgz" --directory="${CACHE_DIR}"
|
||||
|
||||
mkdir -p "${PREFIX}/lib"
|
||||
mkdir -p "${PREFIX}/include"
|
||||
|
||||
cp -r "${CACHE_DIR}/${ONNX}/include/"* "${PREFIX}/include/"
|
||||
cp -r "${CACHE_DIR}/${ONNX}/lib/"* "${PREFIX}/lib/"
|
||||
|
||||
if [[ -z $XDG_DATA_HOME ]]; then
|
||||
DATA_HOME=$HOME/.local/share
|
||||
else
|
||||
DATA_HOME=$XDG_DATA_HOME
|
||||
fi
|
||||
|
||||
if [[ ! -d "$DATA_HOME/monado/hand-tracking-models" ]]; then
|
||||
git clone "https://gitlab.freedesktop.org/monado/utilities/hand-tracking-models" "$DATA_HOME/monado/hand-tracking-models"
|
||||
# Some weird distros aren't configured to automagically do the LFS things; do them just in case.
|
||||
cd "$DATA_HOME/monado/hand-tracking-models"
|
||||
git lfs install
|
||||
git lfs fetch
|
||||
git lfs pull
|
||||
fi
|
||||
|
||||
cd "$DATA_HOME/monado/hand-tracking-models"
|
||||
git pull
|
|
@ -2,5 +2,6 @@ install_data('_clone_or_pull.sh', install_dir: pkgdatadir / 'scripts')
|
|||
install_data('build_basalt.sh', install_dir: pkgdatadir / 'scripts')
|
||||
install_data('build_libsurvive.sh', install_dir: pkgdatadir / 'scripts')
|
||||
install_data('build_monado.sh', install_dir: pkgdatadir / 'scripts')
|
||||
install_data('build_mercury.sh', install_dir: pkgdatadir / 'scripts')
|
||||
install_data('build_opencomposite.sh', install_dir: pkgdatadir / 'scripts')
|
||||
install_data('build_wivrn.sh', install_dir: pkgdatadir / 'scripts')
|
||||
|
|
14
src/builders/build_mercury.rs
Normal file
14
src/builders/build_mercury.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use crate::{constants::PKG_DATA_DIR, file_utils::get_cache_dir, profile::Profile, runner::Runner};
|
||||
|
||||
pub fn get_build_mercury_runner(profile: Profile) -> Runner {
|
||||
let args = vec![profile.prefix, get_cache_dir()];
|
||||
let runner = Runner::new(
|
||||
None,
|
||||
format!(
|
||||
"{sysdata}/scripts/build_mercury.sh",
|
||||
sysdata = PKG_DATA_DIR
|
||||
),
|
||||
args,
|
||||
);
|
||||
runner
|
||||
}
|
|
@ -3,3 +3,4 @@ pub mod build_libsurvive;
|
|||
pub mod build_opencomposite;
|
||||
pub mod build_basalt;
|
||||
pub mod build_wivrn;
|
||||
pub mod build_mercury;
|
||||
|
|
38
src/dependencies/mercury_deps.rs
Normal file
38
src/dependencies/mercury_deps.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
use crate::depcheck::{Dependency, DepType, DependencyCheckResult, check_dependencies};
|
||||
|
||||
fn mercury_deps() -> Vec<Dependency> {
|
||||
vec![
|
||||
Dependency {
|
||||
name: "opencv".into(),
|
||||
dep_type: DepType::SharedObject,
|
||||
filename: "libopencv_core.so".into(),
|
||||
},
|
||||
Dependency {
|
||||
name: "opencv-dev".into(),
|
||||
dep_type: DepType::Include,
|
||||
filename: "opencv4/opencv2/core/base.hpp".into(),
|
||||
},
|
||||
Dependency {
|
||||
name: "opencv-dev".into(),
|
||||
dep_type: DepType::Include,
|
||||
filename: "opencv4/opencv2/core/base.hpp".into(),
|
||||
},
|
||||
Dependency {
|
||||
name: "git-lfs".into(),
|
||||
dep_type: DepType::Executable,
|
||||
filename: "git-lfs".into(),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
pub fn check_mercury_deps() -> Vec<DependencyCheckResult> {
|
||||
check_dependencies(mercury_deps())
|
||||
}
|
||||
|
||||
pub fn get_missing_mercury_deps() -> Vec<Dependency> {
|
||||
check_mercury_deps()
|
||||
.iter()
|
||||
.filter(|res| !res.found)
|
||||
.map(|res| res.dependency.clone())
|
||||
.collect()
|
||||
}
|
|
@ -4,3 +4,4 @@ pub mod basalt_deps;
|
|||
pub mod wivrn_deps;
|
||||
pub mod adb_dep;
|
||||
pub mod pkexec_dep;
|
||||
pub mod mercury_deps;
|
||||
|
|
|
@ -47,7 +47,6 @@ impl Display for XRServiceType {
|
|||
pub enum ProfileFeatureType {
|
||||
Libsurvive,
|
||||
Basalt,
|
||||
Mercury,
|
||||
}
|
||||
|
||||
impl ProfileFeatureType {
|
||||
|
@ -55,13 +54,12 @@ impl ProfileFeatureType {
|
|||
match s.trim().to_lowercase().as_str() {
|
||||
"libsurvive" => Self::Libsurvive,
|
||||
"basalt" => Self::Basalt,
|
||||
"mercury" => Self::Mercury,
|
||||
_ => panic!("Unknown profile feature type"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn iter() -> Iter<'static, ProfileFeatureType> {
|
||||
[Self::Libsurvive, Self::Basalt, Self::Mercury].iter()
|
||||
[Self::Libsurvive, Self::Basalt].iter()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +68,6 @@ impl Display for ProfileFeatureType {
|
|||
f.write_str(match self {
|
||||
Self::Libsurvive => "Libsurvive",
|
||||
Self::Basalt => "Basalt",
|
||||
Self::Mercury => "Mercury",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +95,7 @@ impl Default for ProfileFeature {
|
|||
pub struct ProfileFeatures {
|
||||
pub libsurvive: ProfileFeature,
|
||||
pub basalt: ProfileFeature,
|
||||
pub mercury: ProfileFeature,
|
||||
pub mercury_enabled: bool,
|
||||
}
|
||||
|
||||
impl Default for ProfileFeatures {
|
||||
|
@ -112,10 +109,7 @@ impl Default for ProfileFeatures {
|
|||
feature_type: ProfileFeatureType::Basalt,
|
||||
..Default::default()
|
||||
},
|
||||
mercury: ProfileFeature {
|
||||
feature_type: ProfileFeatureType::Mercury,
|
||||
..Default::default()
|
||||
},
|
||||
mercury_enabled: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,10 +155,7 @@ impl Default for Profile {
|
|||
feature_type: ProfileFeatureType::Basalt,
|
||||
..Default::default()
|
||||
},
|
||||
mercury: ProfileFeature {
|
||||
feature_type: ProfileFeatureType::Mercury,
|
||||
..Default::default()
|
||||
},
|
||||
mercury_enabled: false,
|
||||
},
|
||||
environment: HashMap::new(),
|
||||
prefix: format!(
|
||||
|
@ -246,14 +237,6 @@ impl Profile {
|
|||
.as_ref()
|
||||
.unwrap_or(&"".to_string())
|
||||
.is_empty())
|
||||
&& (!self.features.mercury.enabled
|
||||
|| !self
|
||||
.features
|
||||
.mercury
|
||||
.path
|
||||
.as_ref()
|
||||
.unwrap_or(&"".to_string())
|
||||
.is_empty())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,11 +259,10 @@ mod tests {
|
|||
profile.features.libsurvive.path.as_deref(),
|
||||
Some("/home/user/libsurvive")
|
||||
);
|
||||
assert_eq!(profile.features.mercury.path, None);
|
||||
assert_eq!(profile.features.basalt.path, None);
|
||||
assert_eq!(profile.features.libsurvive.enabled, true);
|
||||
assert_eq!(profile.features.basalt.enabled, false);
|
||||
assert_eq!(profile.features.mercury.enabled, false);
|
||||
assert_eq!(profile.features.mercury_enabled, false);
|
||||
assert!(profile
|
||||
.environment
|
||||
.contains_key("XRT_COMPOSITOR_SCALE_PERCENTAGE"));
|
||||
|
@ -312,10 +294,7 @@ mod tests {
|
|||
feature_type: ProfileFeatureType::Basalt,
|
||||
..Default::default()
|
||||
},
|
||||
mercury: ProfileFeature {
|
||||
feature_type: ProfileFeatureType::Mercury,
|
||||
..Default::default()
|
||||
},
|
||||
mercury_enabled: false,
|
||||
},
|
||||
environment: env,
|
||||
prefix: String::from("/home/user/rex2prefix"),
|
||||
|
|
|
@ -5,6 +5,7 @@ use super::libsurvive_setup_window::LibsurviveSetupWindow;
|
|||
use super::main_view::MainViewMsg;
|
||||
use crate::builders::build_basalt::get_build_basalt_runner;
|
||||
use crate::builders::build_libsurvive::get_build_libsurvive_runner;
|
||||
use crate::builders::build_mercury::get_build_mercury_runner;
|
||||
use crate::builders::build_monado::get_build_monado_runner;
|
||||
use crate::builders::build_opencomposite::get_build_opencomposite_runner;
|
||||
use crate::builders::build_wivrn::get_build_wivrn_runner;
|
||||
|
@ -13,6 +14,7 @@ use crate::constants::APP_NAME;
|
|||
use crate::depcheck::check_dependency;
|
||||
use crate::dependencies::basalt_deps::get_missing_basalt_deps;
|
||||
use crate::dependencies::libsurvive_deps::get_missing_libsurvive_deps;
|
||||
use crate::dependencies::mercury_deps::get_missing_mercury_deps;
|
||||
use crate::dependencies::monado_deps::get_missing_monado_deps;
|
||||
use crate::dependencies::pkexec_dep::pkexec_dep;
|
||||
use crate::dependencies::wivrn_deps::get_missing_wivrn_deps;
|
||||
|
@ -292,10 +294,10 @@ impl SimpleComponent for App {
|
|||
missing_deps.extend(get_missing_basalt_deps());
|
||||
runners.push(get_build_basalt_runner(profile.clone()));
|
||||
}
|
||||
// if profile.features.mercury.enabled {
|
||||
// missing_deps.extend(get_missing_mercury_deps());
|
||||
// runners.push(get_build_mercury_runner(profile.clone()));
|
||||
// }
|
||||
if profile.features.mercury_enabled {
|
||||
missing_deps.extend(get_missing_mercury_deps());
|
||||
runners.push(get_build_mercury_runner(profile.clone()));
|
||||
}
|
||||
runners.push(match profile.xrservice_type {
|
||||
XRServiceType::Monado => get_build_monado_runner(profile.clone()),
|
||||
XRServiceType::Wivrn => get_build_wivrn_runner(profile.clone()),
|
||||
|
|
|
@ -160,7 +160,7 @@ impl SimpleComponent for ProfileEditor {
|
|||
name: "Mercury".into(),
|
||||
description: Some("Camera based hand tracking".into()),
|
||||
key: "mercury_enabled".into(),
|
||||
value: p.features.mercury.enabled,
|
||||
value: p.features.mercury_enabled,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -187,11 +187,6 @@ impl SimpleComponent for ProfileEditor {
|
|||
key: "basalt_path".into(),
|
||||
value: p.features.basalt.path,
|
||||
});
|
||||
guard.push_back(PathModelInit {
|
||||
name: "Mercury Path".into(),
|
||||
key: "mercury_path".into(),
|
||||
value: p.features.mercury.path,
|
||||
});
|
||||
guard.push_back(PathModelInit {
|
||||
name: "Install Prefix".into(),
|
||||
key: "prefix".into(),
|
||||
|
@ -222,11 +217,6 @@ impl SimpleComponent for ProfileEditor {
|
|||
name: "Basalt Repo".into(),
|
||||
value: p.features.basalt.repo.unwrap_or("".into()),
|
||||
});
|
||||
guard.push_back(EntryModelInit {
|
||||
key: "mercury_repo".into(),
|
||||
name: "Mercury Repo".into(),
|
||||
value: p.features.mercury.repo.unwrap_or("".into()),
|
||||
});
|
||||
}
|
||||
|
||||
self.set_profile(Some(prof.clone()));
|
||||
|
@ -273,7 +263,6 @@ impl SimpleComponent for ProfileEditor {
|
|||
}
|
||||
"libsurvive_path" => prof.features.libsurvive.path = value,
|
||||
"basalt_path" => prof.features.basalt.path = value,
|
||||
"mercury_path" => prof.features.mercury.path = value,
|
||||
"prefix" => prof.prefix = value.unwrap_or("".to_string()),
|
||||
_ => panic!("Unknown profile path key"),
|
||||
}
|
||||
|
@ -283,7 +272,7 @@ impl SimpleComponent for ProfileEditor {
|
|||
match key.as_str() {
|
||||
"libsurvive_enabled" => prof.features.libsurvive.enabled = value,
|
||||
"basalt_enabled" => prof.features.basalt.enabled = value,
|
||||
"mercury_enabled" => prof.features.mercury.enabled = value,
|
||||
"mercury_enabled" => prof.features.mercury_enabled = value,
|
||||
"pull_on_build" => prof.pull_on_build = value,
|
||||
_ => panic!("Unknown profile switch key"),
|
||||
}
|
||||
|
@ -316,12 +305,6 @@ impl SimpleComponent for ProfileEditor {
|
|||
s => Some(s.to_string()),
|
||||
}
|
||||
}
|
||||
"mercury_repo" => {
|
||||
prof.features.mercury.repo = match value.trim() {
|
||||
"" => None,
|
||||
s => Some(s.to_string()),
|
||||
}
|
||||
}
|
||||
_ => panic!("Unknown profile text key"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue