fix: rely on system packages for onnxruntime

This commit is contained in:
Gabriele Musco 2025-07-18 07:33:07 +02:00
commit bdb19b5738
4 changed files with 19 additions and 61 deletions

View file

@ -2,57 +2,6 @@
set -ev
PREFIX=$1
CACHE_DIR=$2
if [[ -z $PREFIX ]] || [[ -z $CACHE_DIR ]]; then
echo "Usage: $0 PREFIX CACHE_DIR"
exit 1
fi
ONNX_RELEASES=$(curl -sSL "https://api.github.com/repos/microsoft/onnxruntime/releases")
NUM_RELEASES=$(echo "$ONNX_RELEASES" | jq -r '[ select (.[]!=null) ] | length')
for (( IDX=0; IDX<NUM_RELEASES; IDX++ )); do
ASSETS_LEN=$(echo "$ONNX_RELEASES" | jq -r ".[$IDX].assets_url" | xargs -n 1 curl -sSL | jq -r '[ select (.[]!=null) ] | length')
if [[ $ASSETS_LEN -gt 0 ]]; then
ONNX_VER=$(echo "$ONNX_RELEASES" | jq -r ".[$IDX].tag_name" | tr -d v)
break
fi
done
if [[ -z $ONNX_VER ]]; then
echo "Failed to find a suitable ONNX Runtime release."
exit 1
fi
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

View file

@ -1,11 +1,8 @@
use std::collections::VecDeque;
use crate::{
constants::pkg_data_dir, paths::get_cache_dir, profile::Profile, termcolor::TermColor,
ui::job_worker::job::WorkerJob,
};
use crate::{constants::pkg_data_dir, termcolor::TermColor, ui::job_worker::job::WorkerJob};
pub fn get_build_mercury_jobs(profile: &Profile) -> VecDeque<WorkerJob> {
pub fn get_build_mercury_jobs() -> VecDeque<WorkerJob> {
let mut jobs = VecDeque::new();
jobs.push_back(WorkerJob::new_printer(
"Building Mercury...",
@ -17,10 +14,7 @@ pub fn get_build_mercury_jobs(profile: &Profile) -> VecDeque<WorkerJob> {
.join("scripts/build_mercury.sh")
.to_string_lossy()
.to_string(),
Some(vec![
profile.prefix.to_string_lossy().to_string(),
get_cache_dir().to_string_lossy().to_string(),
]),
None,
));
jobs

View file

@ -7,6 +7,21 @@ use std::collections::HashMap;
fn mercury_deps() -> Vec<Dependency> {
vec![
dep_opencv(),
Dependency {
name: "onnxruntime-dev".into(),
dep_type: DepType::Include,
filename: "onnxruntime/onnxruntime_c_api.h".into(),
packages: HashMap::from([
(LinuxDistro::Arch, "onnxruntime".into()),
(LinuxDistro::Debian, "libonnxruntime-dev".into()),
(LinuxDistro::Fedora, "onnxruntime-devel".into()),
// alpine doesn't seem to have the package
// (LinuxDistro::Alpine, "".into()),
(LinuxDistro::Gentoo, "sci-ml/onnx".into()),
// opensuse doesn't seem to have the package
// (LinuxDistro::Suse, "".into()),
]),
},
Dependency {
name: "jq".into(),
dep_type: DepType::Executable,

View file

@ -548,7 +548,7 @@ impl AsyncComponent for App {
jobs.extend(get_build_basalt_jobs(&profile, clean_build));
}
if profile.features.mercury_enabled {
jobs.extend(get_build_mercury_jobs(&profile));
jobs.extend(get_build_mercury_jobs());
}
jobs.extend(match profile.xrservice_type {
XRServiceType::Monado => get_build_monado_jobs(&profile, clean_build),