From 91761f0eb50f9fb66a964a13327dc94a24cdedb0 Mon Sep 17 00:00:00 2001 From: zmerp Date: Sun, 1 Dec 2024 20:49:48 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20package-launcher=20?= =?UTF-8?q?requiring=20openvr=20submodule=20(#2549)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 Fix package-launcher requiring openvr submodule * Do not delete launch build dir with package-launcher; fix launcher installations dir --- Cargo.lock | 7 +++++-- alvr/adb/Cargo.toml | 3 +-- alvr/adb/src/lib.rs | 19 +++++++++---------- alvr/launcher/Cargo.toml | 1 + alvr/launcher/src/actions.rs | 10 ++++++---- alvr/server_core/src/connection.rs | 18 ++++++++++++++++-- alvr/session/Cargo.toml | 1 + alvr/session/src/settings.rs | 8 +------- alvr/system_info/Cargo.toml | 2 ++ alvr/system_info/src/lib.rs | 13 +++++++++++++ alvr/xtask/src/dependencies.rs | 8 ++++---- alvr/xtask/src/main.rs | 2 +- alvr/xtask/src/packaging.rs | 8 ++------ 13 files changed, 62 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 92fe9b7145..cd122266a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,8 +170,7 @@ version = "21.0.0-dev01" dependencies = [ "alvr_common", "alvr_filesystem", - "alvr_server_io", - "alvr_session", + "alvr_system_info", "anyhow", "ureq", "zip", @@ -342,6 +341,7 @@ dependencies = [ "alvr_common", "alvr_filesystem", "alvr_gui_common", + "alvr_system_info", "anyhow", "eframe", "flate2", @@ -439,6 +439,7 @@ version = "21.0.0-dev01" dependencies = [ "alvr_common", "alvr_filesystem", + "alvr_system_info", "bytemuck", "regex", "serde", @@ -469,6 +470,8 @@ dependencies = [ "ndk 0.9.0", "ndk-context", "ndk-sys 0.6.0+11769913", + "serde", + "settings-schema", ] [[package]] diff --git a/alvr/adb/Cargo.toml b/alvr/adb/Cargo.toml index 842d6683e5..5b9c3f0da8 100644 --- a/alvr/adb/Cargo.toml +++ b/alvr/adb/Cargo.toml @@ -9,8 +9,7 @@ license.workspace = true [dependencies] alvr_common.workspace = true alvr_filesystem.workspace = true -alvr_server_io.workspace = true -alvr_session.workspace = true +alvr_system_info.workspace = true anyhow = "1" ureq = "2.10" diff --git a/alvr/adb/src/lib.rs b/alvr/adb/src/lib.rs index 9308d65a55..64660b1e8e 100644 --- a/alvr/adb/src/lib.rs +++ b/alvr/adb/src/lib.rs @@ -3,13 +3,11 @@ mod parse; use alvr_common::anyhow::Result; use alvr_common::{dbg_connection, error}; -use alvr_session::{ClientFlavor, ConnectionConfig}; +use alvr_system_info::{ + ClientFlavor, PACKAGE_NAME_GITHUB_DEV, PACKAGE_NAME_GITHUB_STABLE, PACKAGE_NAME_STORE, +}; use std::collections::HashSet; -pub const PACKAGE_NAME_STORE: &str = "alvr.client"; -pub const PACKAGE_NAME_GITHUB_DEV: &str = "alvr.client.dev"; -pub const PACKAGE_NAME_GITHUB_STABLE: &str = "alvr.client.stable"; - pub enum WiredConnectionStatus { Ready, NotReady(String), @@ -32,7 +30,9 @@ impl WiredConnection { pub fn setup( &self, control_port: u16, - config: &ConnectionConfig, + stream_port: u16, + client_type: &ClientFlavor, + client_autolaunch: bool, ) -> Result { let Some(device_serial) = commands::list_devices(&self.adb_path)? .into_iter() @@ -44,7 +44,7 @@ impl WiredConnection { )); }; - let ports = HashSet::from([control_port, config.stream_port]); + let ports = HashSet::from([control_port, stream_port]); let forwarded_ports: HashSet = commands::list_forwarded_ports(&self.adb_path, &device_serial)? .into_iter() @@ -58,8 +58,7 @@ impl WiredConnection { ); } - let Some(process_name) = - get_process_name(&self.adb_path, &device_serial, &config.wired_client_type) + let Some(process_name) = get_process_name(&self.adb_path, &device_serial, client_type) else { return Ok(WiredConnectionStatus::NotReady( "No suitable ALVR client is installed".to_owned(), @@ -67,7 +66,7 @@ impl WiredConnection { }; if commands::get_process_id(&self.adb_path, &device_serial, &process_name)?.is_none() { - if config.wired_client_autolaunch { + if client_autolaunch { commands::start_application(&self.adb_path, &device_serial, &process_name)?; Ok(WiredConnectionStatus::NotReady( "Starting ALVR client".to_owned(), diff --git a/alvr/launcher/Cargo.toml b/alvr/launcher/Cargo.toml index 5f8bae2f1f..8593911190 100644 --- a/alvr/launcher/Cargo.toml +++ b/alvr/launcher/Cargo.toml @@ -11,6 +11,7 @@ alvr_adb.workspace = true alvr_common.workspace = true alvr_filesystem.workspace = true alvr_gui_common.workspace = true +alvr_system_info.workspace = true anyhow = "1" eframe = "0.28" diff --git a/alvr/launcher/src/actions.rs b/alvr/launcher/src/actions.rs index 9743b2c4cb..b18c1e2493 100644 --- a/alvr/launcher/src/actions.rs +++ b/alvr/launcher/src/actions.rs @@ -176,9 +176,9 @@ fn install_and_launch_apk( let version = Version::parse(&v).context("Failed to parse release version")?; let stable = version.pre.is_empty() && !version.build.contains("nightly"); let application_id = if stable { - alvr_adb::PACKAGE_NAME_GITHUB_STABLE + alvr_system_info::PACKAGE_NAME_GITHUB_STABLE } else { - alvr_adb::PACKAGE_NAME_GITHUB_DEV + alvr_system_info::PACKAGE_NAME_GITHUB_DEV }; if alvr_adb::commands::is_package_installed(&adb_path, &device_serial, application_id)? { @@ -272,9 +272,11 @@ pub fn data_dir() -> PathBuf { PathBuf::from(env::var("HOME").expect("Failed to determine home directory")) .join(".local/share/ALVR-Launcher") } else { - env::current_dir() + env::current_exe() .expect("Unable to determine executable directory") - .join("ALVR-Launcher") + .parent() + .unwrap() + .to_owned() } } diff --git a/alvr/server_core/src/connection.rs b/alvr/server_core/src/connection.rs index 459e0e86ce..646e19f003 100644 --- a/alvr/server_core/src/connection.rs +++ b/alvr/server_core/src/connection.rs @@ -288,9 +288,23 @@ pub fn handshake_loop(ctx: Arc, lifecycle_state: Arc status, Err(e) => { error!("{e:?}"); diff --git a/alvr/session/Cargo.toml b/alvr/session/Cargo.toml index f1cf723ff2..9166b6ab39 100644 --- a/alvr/session/Cargo.toml +++ b/alvr/session/Cargo.toml @@ -8,6 +8,7 @@ license.workspace = true [dependencies] alvr_common.workspace = true +alvr_system_info.workspace = true bytemuck = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] } diff --git a/alvr/session/src/settings.rs b/alvr/session/src/settings.rs index 7834194880..506d33b696 100644 --- a/alvr/session/src/settings.rs +++ b/alvr/session/src/settings.rs @@ -2,6 +2,7 @@ use alvr_common::{ DebugGroupsConfig, DebugGroupsConfigDefault, LogSeverity, LogSeverityDefault, LogSeverityDefaultVariant, }; +use alvr_system_info::{ClientFlavor, ClientFlavorDefault, ClientFlavorDefaultVariant}; use bytemuck::{Pod, Zeroable}; use serde::{Deserialize, Serialize}; use settings_schema::{ @@ -1126,13 +1127,6 @@ pub enum SocketBufferSize { Custom(#[schema(suffix = "B")] u32), } -#[derive(SettingsSchema, Serialize, Deserialize, Clone)] -pub enum ClientFlavor { - Store, - Github, - Custom(String), -} - #[derive(SettingsSchema, Serialize, Deserialize, Clone)] pub struct ConnectionConfig { #[schema(strings( diff --git a/alvr/system_info/Cargo.toml b/alvr/system_info/Cargo.toml index 83ef4041a6..f058c08ba3 100644 --- a/alvr/system_info/Cargo.toml +++ b/alvr/system_info/Cargo.toml @@ -11,6 +11,8 @@ alvr_common.workspace = true jni = "0.21" local-ip-address = "0.6" +serde = { version = "1", features = ["derive"] } +settings-schema = { git = "https://github.com/alvr-org/settings-schema-rs", rev = "676185f" } [target.'cfg(target_os = "android")'.dependencies] ndk = { version = "0.9", features = ["api-level-26", "media"] } diff --git a/alvr/system_info/src/lib.rs b/alvr/system_info/src/lib.rs index b14b24abbe..db994f74ad 100644 --- a/alvr/system_info/src/lib.rs +++ b/alvr/system_info/src/lib.rs @@ -4,8 +4,14 @@ pub mod android; #[cfg(target_os = "android")] pub use android::*; +use alvr_common::settings_schema::SettingsSchema; +use serde::{Deserialize, Serialize}; use std::fmt::{Display, Formatter}; +pub const PACKAGE_NAME_STORE: &str = "alvr.client"; +pub const PACKAGE_NAME_GITHUB_DEV: &str = "alvr.client.dev"; +pub const PACKAGE_NAME_GITHUB_STABLE: &str = "alvr.client.stable"; + // Platform of the device. It is used to match the VR runtime and enable features conditionally. #[derive(PartialEq, Eq, Clone, Copy)] pub enum Platform { @@ -161,3 +167,10 @@ pub fn local_ip() -> std::net::IpAddr { local_ip_address::local_ip().unwrap_or(IpAddr::V4(Ipv4Addr::UNSPECIFIED)) } + +#[derive(SettingsSchema, Serialize, Deserialize, Clone)] +pub enum ClientFlavor { + Store, + Github, + Custom(String), +} diff --git a/alvr/xtask/src/dependencies.rs b/alvr/xtask/src/dependencies.rs index 0b553966eb..a6d41ddeec 100644 --- a/alvr/xtask/src/dependencies.rs +++ b/alvr/xtask/src/dependencies.rs @@ -110,7 +110,7 @@ pub fn prepare_windows_deps(skip_admin_priv: bool) { prepare_ffmpeg_windows(&deps_path); } -pub fn prepare_linux_deps(nvenc_flag: bool) { +pub fn prepare_linux_deps(enable_nvenc: bool) { let sh = Shell::new().unwrap(); update_submodules(&sh); @@ -120,7 +120,7 @@ pub fn prepare_linux_deps(nvenc_flag: bool) { sh.create_dir(&deps_path).unwrap(); build_x264_linux(&deps_path); - build_ffmpeg_linux(nvenc_flag, &deps_path); + build_ffmpeg_linux(enable_nvenc, &deps_path); } pub fn build_x264_linux(deps_path: &Path) { @@ -156,7 +156,7 @@ pub fn build_x264_linux(deps_path: &Path) { cmd!(sh, "make install").run().unwrap(); } -pub fn build_ffmpeg_linux(nvenc_flag: bool, deps_path: &Path) { +pub fn build_ffmpeg_linux(enable_nvenc: bool, deps_path: &Path) { let sh = Shell::new().unwrap(); command::download_and_extract_zip( @@ -208,7 +208,7 @@ pub fn build_ffmpeg_linux(nvenc_flag: bool, deps_path: &Path) { let ffmpeg_command = "for p in ../../../alvr/xtask/patches/*; do patch -p1 < $p; done"; cmd!(sh, "bash -c {ffmpeg_command}").run().unwrap(); - if nvenc_flag { + if enable_nvenc { /* Describing Nvidia specific options --nvccflags: nvcc from CUDA toolkit version 11.0 or higher does not support compiling for 'compute_30' (default in ffmpeg) diff --git a/alvr/xtask/src/main.rs b/alvr/xtask/src/main.rs index 0c00b21b92..a0de3fb39a 100644 --- a/alvr/xtask/src/main.rs +++ b/alvr/xtask/src/main.rs @@ -248,7 +248,7 @@ fn main() { "package-streamer" => { packaging::package_streamer(platform, for_ci, !no_nvidia, gpl, root) } - "package-launcher" => packaging::package_launcher(platform, for_ci), + "package-launcher" => packaging::package_launcher(), "package-client" => packaging::package_client_openxr(package_flavor, for_ci), "package-client-lib" => packaging::package_client_lib(link_stdcpp, all_targets), "format" => format::format(), diff --git a/alvr/xtask/src/packaging.rs b/alvr/xtask/src/packaging.rs index 04c0e2262c..53781ec16f 100644 --- a/alvr/xtask/src/packaging.rs +++ b/alvr/xtask/src/packaging.rs @@ -103,8 +103,6 @@ pub fn package_streamer( ) { let sh = Shell::new().unwrap(); - fs::remove_dir_all(afs::streamer_build_dir()).ok(); - dependencies::prepare_server_deps(platform, skip_admin_priv, enable_nvenc); build::build_streamer(Profile::Distribution, gpl, root, true, false, false); @@ -118,12 +116,10 @@ pub fn package_streamer( } } -pub fn package_launcher(platform: Option, skip_admin_priv: bool) { +pub fn package_launcher() { let sh = Shell::new().unwrap(); - fs::remove_dir_all(afs::launcher_build_dir()).ok(); - - dependencies::prepare_server_deps(platform, skip_admin_priv, false); + sh.remove_path(afs::launcher_build_dir()).ok(); build::build_launcher(Profile::Distribution, true);