feat: basalt support

This commit is contained in:
Gabriele Musco 2023-08-03 21:19:18 +00:00
parent ecb4f08262
commit 7a88489ef3
4 changed files with 71 additions and 52 deletions

View file

@ -1,30 +0,0 @@
#!/bin/bash
set -ev
echo "Basalt is currently unsupported"
exit 1
#
# REPO_DIR=$1
#
# PREFIX=$2
#
# DO_PULL=$3
#
# REPO_URL=$4
#
# if [[ -z $REPO_DIR ]] || [[ -z $PREFIX ]] || [[ -z $DO_PULL ]]; then
# echo "Usage: $0 REPO_DIR PREFIX DO_PULL [REPO_URL]"
# exit 1
# fi
#
# if [[ -z $REPO_URL ]]; then
# REPO_URL="https://gitlab.freedesktop.org/mateosss/basalt"
# fi
#
# "$(dirname -- "$0")/_clone_or_pull.sh" "$REPO_URL" "$REPO_DIR" "$DO_PULL"
#
# cd "$REPO_DIR"
# rm -rf build
# mkdir -p build
# cd build

View file

@ -1,3 +1,2 @@
install_data('_clone_or_pull.sh', install_dir: pkgdatadir / 'scripts')
install_data('build_basalt.sh', install_dir: pkgdatadir / 'scripts')
install_data('build_mercury.sh', install_dir: pkgdatadir / 'scripts')

View file

@ -1,23 +1,73 @@
use crate::{constants::pkg_data_dir, profile::Profile, runner::Runner};
use crate::{
build_tools::{cmake::Cmake, git::Git},
constants::pkg_data_dir,
file_utils::rm_rf,
profile::Profile,
runner::Runner,
};
use std::{collections::HashMap, path::Path};
pub fn get_build_basalt_runner(profile: &Profile) -> Runner {
let mut args = vec![
profile
.features.basalt.path.clone()
.expect("Missing basalt path for given profile"),
profile.prefix.clone(),
match profile.pull_on_build {
true => "1".into(),
false => "0".into(),
pub fn get_build_basalt_runners(profile: &Profile, clean_build: bool) -> Vec<Runner> {
let mut runners: Vec<Runner> = vec![];
let git = Git {
repo: match profile.features.basalt.repo.as_ref() {
Some(r) => r.clone(),
None => "https://gitlab.freedesktop.org/mateosss/basalt.git".into(),
},
];
if profile.features.basalt.repo.is_some() {
args.push(profile.features.basalt.repo.as_ref().unwrap().clone());
}
let runner = Runner::new(
None,
format!("{sysdata}/scripts/build_basalt.sh", sysdata = pkg_data_dir()),
args,
dir: profile.features.basalt.path.as_ref().unwrap().clone(),
};
match git.clone_or_pull(profile) {
Some(r) => runners.push(r),
None => {}
};
let build_dir = format!("{}/build", profile.features.basalt.path.as_ref().unwrap());
let mut cmake_vars: HashMap<String, String> = HashMap::new();
cmake_vars.insert("CMAKE_BUILD_TYPE".into(), "Release".into());
cmake_vars.insert("CMAKE_INSTALL_PREFIX".into(), profile.prefix.clone());
cmake_vars.insert("BUILD_TESTS".into(), "OFF".into());
cmake_vars.insert("BASALT_INSTANTIATIONS_DOUBLE".into(), "OFF".into());
cmake_vars.insert(
"CMAKE_INSTALL_LIBDIR".into(),
format!("{}/lib", profile.prefix),
);
runner
let cmake = Cmake {
env: None,
vars: Some(cmake_vars),
source_dir: profile.features.basalt.path.as_ref().unwrap().clone(),
build_dir: build_dir.clone(),
};
if !Path::new(&build_dir).is_dir() || clean_build {
rm_rf(&build_dir);
runners.push(cmake.get_prepare_runner());
}
runners.push(cmake.get_build_runner());
runners.push(cmake.get_install_runner());
runners.push(Runner::new(
None,
"mkdir".into(),
vec![
"-p".into(),
format!(
"{}/share/basalt/thirdparty/basalt-headers/thirdparty",
profile.prefix
),
],
));
runners.push(Runner::new(
None,
"cp".into(),
vec![
"-Ra".into(),
format!(
"{}/basalt/thirdparty/basalt-headers/thirdparty/eigen",
profile.features.basalt.path.as_ref().unwrap().clone()
),
format!("{}/share/basalt/thirdparty", profile.prefix),
],
));
runners
}

View file

@ -4,7 +4,7 @@ use super::build_window::{BuildStatus, BuildWindow};
use super::debug_view::{DebugView, DebugViewMsg};
use super::libsurvive_setup_window::LibsurviveSetupWindow;
use super::main_view::MainViewMsg;
use crate::builders::build_basalt::get_build_basalt_runner;
use crate::builders::build_basalt::get_build_basalt_runners;
use crate::builders::build_libsurvive::get_build_libsurvive_runners;
use crate::builders::build_mercury::get_build_mercury_runner;
use crate::builders::build_monado::get_build_monado_runners;
@ -383,7 +383,7 @@ impl SimpleComponent for App {
}
if profile.features.basalt.enabled {
missing_deps.extend(get_missing_basalt_deps());
runners.push(get_build_basalt_runner(&profile));
runners.extend(get_build_basalt_runners(&profile, clean_build));
}
if profile.features.mercury_enabled {
missing_deps.extend(get_missing_mercury_deps());