Skip to content

Commit

Permalink
fix: 🐛 Fix package-launcher requiring openvr submodule (alvr-org#2549)
Browse files Browse the repository at this point in the history
* fix: 🐛 Fix package-launcher requiring openvr submodule

* Do not delete launch build dir with package-launcher; fix launcher installations dir
  • Loading branch information
zmerp authored Dec 1, 2024
1 parent 5152b06 commit 91761f0
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 38 deletions.
7 changes: 5 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions alvr/adb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 9 additions & 10 deletions alvr/adb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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<WiredConnectionStatus> {
let Some(device_serial) = commands::list_devices(&self.adb_path)?
.into_iter()
Expand All @@ -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<u16> =
commands::list_forwarded_ports(&self.adb_path, &device_serial)?
.into_iter()
Expand All @@ -58,16 +58,15 @@ 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(),
));
};

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(),
Expand Down
1 change: 1 addition & 0 deletions alvr/launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions alvr/launcher/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)? {
Expand Down Expand Up @@ -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()
}
}

Expand Down
18 changes: 16 additions & 2 deletions alvr/server_core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,23 @@ pub fn handshake_loop(ctx: Arc<ConnectionContext>, lifecycle_state: Arc<RwLock<L
wired_connection.as_ref().unwrap()
};

let status = match wired_connection
.setup(CONTROL_PORT, &SESSION_MANAGER.read().settings().connection)
let stream_port;
let client_type;
let client_autolaunch;
{
let session_manager_lock = SESSION_MANAGER.read();
let connection = &session_manager_lock.settings().connection;
stream_port = connection.stream_port;
client_type = connection.wired_client_type.clone();
client_autolaunch = connection.wired_client_autolaunch;
}

let status = match wired_connection.setup(
CONTROL_PORT,
stream_port,
&client_type,
client_autolaunch,
) {
Ok(status) => status,
Err(e) => {
error!("{e:?}");
Expand Down
1 change: 1 addition & 0 deletions alvr/session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
8 changes: 1 addition & 7 deletions alvr/session/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions alvr/system_info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
13 changes: 13 additions & 0 deletions alvr/system_info/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
}
8 changes: 4 additions & 4 deletions alvr/xtask/src/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion alvr/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
8 changes: 2 additions & 6 deletions alvr/xtask/src/packaging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -118,12 +116,10 @@ pub fn package_streamer(
}
}

pub fn package_launcher(platform: Option<BuildPlatform>, 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);

Expand Down

0 comments on commit 91761f0

Please sign in to comment.