diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index a71075c446..b387384ba2 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -87,9 +87,8 @@ jobs: env: RUST_BACKTRACE: 1 run: | - cargo xtask prepare-deps --platform windows --ci - cargo xtask package-streamer --gpl - cargo xtask package-launcher + cargo xtask package-streamer --gpl --ci + cargo xtask package-launcher --ci - name: Upload streamer uses: actions/upload-release-asset@v1 @@ -132,15 +131,14 @@ jobs: sudo apt-get update sudo apt-get install libfuse2 build-essential pkg-config nasm libva-dev libdrm-dev libvulkan-dev libx264-dev libx265-dev cmake libasound2-dev libjack-jackd2-dev libxrandr-dev libunwind-dev libffmpeg-nvenc-dev nvidia-cuda-toolkit libgtk-3-dev libpipewire-0.3-dev libspa-0.2-dev cp alvr/xtask/deb/cuda.pc /usr/share/pkgconfig - cargo xtask prepare-deps --platform linux - name: Build and package ALVR (.tar.gz) id: build env: RUST_BACKTRACE: 1 run: | - cargo xtask package-streamer --gpl - cargo xtask package-launcher + cargo xtask package-streamer --gpl --ci + cargo xtask package-launcher --ci - name: Upload streamer (tar.gz) uses: actions/upload-release-asset@v1 @@ -223,9 +221,7 @@ jobs: env: RUST_BACKTRACE: 1 ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }} - run: | - cargo xtask prepare-deps --platform android --ci - cargo xtask package-client + run: cargo xtask package-client --ci - name: Sign APK uses: ilharp/sign-android-release@v1 diff --git a/alvr/common/Cargo.toml b/alvr/common/Cargo.toml index bd43908422..f1f1df8f57 100644 --- a/alvr/common/Cargo.toml +++ b/alvr/common/Cargo.toml @@ -6,9 +6,6 @@ rust-version.workspace = true authors.workspace = true license.workspace = true -[features] -enable-messagebox = ["rfd"] - [dependencies] anyhow = { version = "1", features = ["backtrace"] } backtrace = "0.3" @@ -23,4 +20,4 @@ settings-schema = { git = "https://github.com/alvr-org/settings-schema-rs", rev # settings-schema = { path = "../../../../settings-schema-rs/settings-schema" } [target.'cfg(not(target_os = "android"))'.dependencies] -rfd = { version = "0.14", optional = true } +rfd = "0.14" diff --git a/alvr/common/src/logging.rs b/alvr/common/src/logging.rs index 08f85e7d9a..f0ee49e449 100644 --- a/alvr/common/src/logging.rs +++ b/alvr/common/src/logging.rs @@ -193,7 +193,7 @@ pub fn set_panic_hook() { log::error!("ALVR panicked: {err_str}"); - #[cfg(all(not(target_os = "android"), feature = "enable-messagebox"))] + #[cfg(not(target_os = "android"))] std::thread::spawn({ let panic_str = panic_info.to_string(); move || { @@ -210,7 +210,7 @@ pub fn set_panic_hook() { pub fn show_w(w: W) { log::warn!("{w}"); - #[cfg(all(not(target_os = "android"), feature = "enable-messagebox"))] + #[cfg(not(target_os = "android"))] std::thread::spawn(move || { rfd::MessageDialog::new() .set_title("ALVR warning") @@ -228,7 +228,7 @@ pub fn show_warn(res: Result) -> Option fn show_e_block(e: E, blocking: bool) { log::error!("{e}"); - #[cfg(all(not(target_os = "android"), feature = "enable-messagebox"))] + #[cfg(not(target_os = "android"))] { // Store the last error shown in a message box. Do not open a new message box if the content // of the error has not changed diff --git a/alvr/xtask/src/build.rs b/alvr/xtask/src/build.rs index 5479a515d8..dec44d7d84 100644 --- a/alvr/xtask/src/build.rs +++ b/alvr/xtask/src/build.rs @@ -27,12 +27,7 @@ impl Display for Profile { } } -pub fn build_server_lib( - profile: Profile, - enable_messagebox: bool, - root: Option, - reproducible: bool, -) { +pub fn build_server_lib(profile: Profile, root: Option, reproducible: bool) { let sh = Shell::new().unwrap(); let mut flags = vec![]; @@ -44,10 +39,6 @@ pub fn build_server_lib( Profile::Release => flags.push("--release"), Profile::Debug => (), } - if enable_messagebox { - flags.push("--features"); - flags.push("alvr_common/enable-messagebox"); - } if reproducible { flags.push("--locked"); } @@ -82,7 +73,6 @@ pub fn build_server_lib( pub fn build_streamer( profile: Profile, - enable_messagebox: bool, gpl: bool, root: Option, reproducible: bool, @@ -102,10 +92,6 @@ pub fn build_streamer( Profile::Release => common_flags.push("--release"), Profile::Debug => (), } - if enable_messagebox { - common_flags.push("--features"); - common_flags.push("alvr_common/enable-messagebox"); - } if reproducible { common_flags.push("--locked"); } @@ -280,7 +266,7 @@ pub fn build_streamer( } } -pub fn build_launcher(profile: Profile, enable_messagebox: bool, reproducible: bool) { +pub fn build_launcher(profile: Profile, reproducible: bool) { let sh = Shell::new().unwrap(); let mut common_flags = vec![]; @@ -292,10 +278,6 @@ pub fn build_launcher(profile: Profile, enable_messagebox: bool, reproducible: b Profile::Release => common_flags.push("--release"), Profile::Debug => (), } - if enable_messagebox { - common_flags.push("--features"); - common_flags.push("alvr_common/enable-messagebox"); - } if reproducible { common_flags.push("--locked"); } diff --git a/alvr/xtask/src/dependencies.rs b/alvr/xtask/src/dependencies.rs index 68cc37a239..0b553966eb 100644 --- a/alvr/xtask/src/dependencies.rs +++ b/alvr/xtask/src/dependencies.rs @@ -1,4 +1,4 @@ -use crate::command; +use crate::{command, BuildPlatform}; use alvr_filesystem as afs; use std::{fs, path::Path}; use xshell::{cmd, Shell}; @@ -299,6 +299,30 @@ pub fn prepare_macos_deps() { update_submodules(&sh); } +pub fn prepare_server_deps( + platform: Option, + skip_admin_priv: bool, + enable_nvenc: bool, +) { + match platform { + Some(BuildPlatform::Windows) => prepare_windows_deps(skip_admin_priv), + Some(BuildPlatform::Linux) => prepare_linux_deps(enable_nvenc), + Some(BuildPlatform::Macos) => prepare_macos_deps(), + Some(BuildPlatform::Android) => panic!("Android is not supported"), + None => { + if cfg!(windows) { + prepare_windows_deps(skip_admin_priv); + } else if cfg!(target_os = "linux") { + prepare_linux_deps(enable_nvenc); + } else if cfg!(target_os = "macos") { + prepare_macos_deps(); + } else { + panic!("Unsupported platform"); + } + } + } +} + fn get_android_openxr_loaders(selection: OpenXRLoadersSelection) { fn get_openxr_loader(name: &str, url: &str, source_dir: &str) { let sh = Shell::new().unwrap(); diff --git a/alvr/xtask/src/main.rs b/alvr/xtask/src/main.rs index b0f8ad3e42..0c00b21b92 100644 --- a/alvr/xtask/src/main.rs +++ b/alvr/xtask/src/main.rs @@ -49,8 +49,6 @@ FLAGS: --release Optimized build with less debug checks. For build subcommands --profiling Enable Profiling --gpl Bundle GPL libraries (FFmpeg). Only for Windows - --appimage Package as AppImage. For package-streamer subcommand - --zsync For --appimage, create .zsync update file and build AppImage with embedded update information. For package-streamer subcommand --nightly Append nightly tag to versions. For bump subcommand --no-rebuild Do not rebuild the streamer with run-streamer --ci Do some CI related tweaks. Depends on the other flags and subcommand @@ -60,12 +58,19 @@ FLAGS: --pico-store For package-client subcommand, build for Pico Store ARGS: - --platform Name of the platform (operative system or hardware name). snake_case + --platform Name of the platform (operative system name) --version Specify version to set with the bump-versions subcommand --root Installation root. By default no root is set and paths are calculated using relative paths, which requires conforming to FHS on Linux. "#; +enum BuildPlatform { + Windows, + Linux, + Macos, + Android, +} + pub fn run_streamer() { let sh = Shell::new().unwrap(); @@ -170,12 +175,18 @@ fn main() { let no_rebuild = args.contains("--no-rebuild"); let for_ci = args.contains("--ci"); let keep_config = args.contains("--keep-config"); - let appimage = args.contains("--appimage"); - let zsync = args.contains("--zsync"); let link_stdcpp = !args.contains("--no-stdcpp"); let all_targets = args.contains("--all-targets"); let platform: Option = args.opt_value_from_str("--platform").unwrap(); + let platform = platform.as_deref().map(|platform| match platform { + "windows" => BuildPlatform::Windows, + "linux" => BuildPlatform::Linux, + "macos" => BuildPlatform::Macos, + "android" => BuildPlatform::Android, + _ => panic!("Unrecognized platform."), + }); + let version: Option = args.opt_value_from_str("--version").unwrap(); let root: Option = args.opt_value_from_str("--root").unwrap(); @@ -191,23 +202,17 @@ fn main() { match subcommand.as_str() { "prepare-deps" => { if let Some(platform) = platform { - match platform.as_str() { - "windows" => dependencies::prepare_windows_deps(for_ci), - "linux" => dependencies::prepare_linux_deps(!no_nvidia), - "macos" => dependencies::prepare_macos_deps(), - "android" => dependencies::build_android_deps( + if matches!(platform, BuildPlatform::Android) { + dependencies::build_android_deps( for_ci, all_targets, OpenXRLoadersSelection::All, - ), - _ => panic!("Unrecognized platform."), + ); + } else { + dependencies::prepare_server_deps(Some(platform), for_ci, !no_nvidia); } } else { - if cfg!(windows) { - dependencies::prepare_windows_deps(for_ci); - } else if cfg!(target_os = "linux") { - dependencies::prepare_linux_deps(!no_nvidia); - } + dependencies::prepare_server_deps(platform, for_ci, !no_nvidia); dependencies::build_android_deps( for_ci, @@ -217,10 +222,10 @@ fn main() { } } "build-streamer" => { - build::build_streamer(profile, true, gpl, None, false, profiling, keep_config) + build::build_streamer(profile, gpl, None, false, profiling, keep_config) } - "build-launcher" => build::build_launcher(profile, true, false), - "build-server-lib" => build::build_server_lib(profile, true, None, false), + "build-launcher" => build::build_launcher(profile, false), + "build-server-lib" => build::build_server_lib(profile, None, false), "build-client" => build::build_android_client(profile), "build-client-lib" => { build::build_android_client_core_lib(profile, link_stdcpp, all_targets) @@ -230,27 +235,21 @@ fn main() { } "run-streamer" => { if !no_rebuild { - build::build_streamer( - profile, - true, - gpl, - None, - false, - profiling, - keep_config, - ); + build::build_streamer(profile, gpl, None, false, profiling, keep_config); } run_streamer(); } "run-launcher" => { if !no_rebuild { - build::build_launcher(profile, true, false); + build::build_launcher(profile, false); } run_launcher(); } - "package-streamer" => packaging::package_streamer(gpl, root, appimage, zsync), - "package-launcher" => packaging::package_launcher(appimage), - "package-client" => packaging::package_client_openxr(package_flavor), + "package-streamer" => { + packaging::package_streamer(platform, for_ci, !no_nvidia, gpl, root) + } + "package-launcher" => packaging::package_launcher(platform, for_ci), + "package-client" => packaging::package_client_openxr(package_flavor, for_ci), "package-client-lib" => packaging::package_client_lib(link_stdcpp, all_targets), "format" => format::format(), "check-format" => format::check_format(), diff --git a/alvr/xtask/src/packaging.rs b/alvr/xtask/src/packaging.rs index d665c27f0d..04c0e2262c 100644 --- a/alvr/xtask/src/packaging.rs +++ b/alvr/xtask/src/packaging.rs @@ -2,11 +2,10 @@ use crate::{ build::{self, Profile}, command, dependencies::{self, OpenXRLoadersSelection}, - version, + version, BuildPlatform, }; use alvr_filesystem as afs; use std::{ - env::consts::OS, fs, path::{Path, PathBuf}, }; @@ -59,67 +58,6 @@ fn build_windows_installer() { .unwrap(); } -fn package_streamer_appimage(release: bool, update: bool) { - let sh = Shell::new().unwrap(); - - let appdir = &afs::build_dir().join("ALVR.AppDir"); - let bin = &afs::build_dir().join("alvr_streamer_linux"); - - let icon = &afs::workspace_dir().join("resources/alvr.png"); - let desktop = &afs::workspace_dir().join("alvr/xtask/resources/alvr.desktop"); - - let linuxdeploy = afs::build_dir().join("linuxdeploy-x86_64.AppImage"); - - if !sh.path_exists(&linuxdeploy) { - command::download(&sh, "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage", &linuxdeploy).ok(); - } - cmd!(&sh, "chmod a+x {linuxdeploy}").run().ok(); - - if sh.path_exists(appdir) { - sh.remove_path(appdir).ok(); - } - - cmd!(&sh, "{linuxdeploy} --appdir={appdir}").run().ok(); - - sh.cmd("sh") - .arg("-c") - .arg(format!( - "cp -r {}/* {}/usr", - bin.to_string_lossy(), - appdir.to_string_lossy() - )) - .run() - .ok(); - - sh.set_var("ARCH", "x86_64"); - sh.set_var("OUTPUT", "ALVR-x86_64.AppImage"); - - if release { - let version = version::version(); - sh.set_var("VERSION", &version); - - if update { - let repo = if version.contains("nightly") { - "ALVR-nightly" - } else { - "ALVR" - }; - sh.set_var( - "UPDATE_INFORMATION", - format!("gh-releases-zsync|alvr-org|{repo}|latest|ALVR-x86_64.AppImage.zsync"), - ); - } - } - - sh.set_var("VERBOSE", "1"); - sh.set_var("NO_APPSTREAM", "1"); - // sh.set_var("APPIMAGE_COMP", "xz"); - - sh.change_dir(afs::build_dir()); - - cmd!(&sh, "{linuxdeploy} --appdir={appdir} -i{icon} -d{desktop} --deploy-deps-only={appdir}/usr/lib64/alvr/bin/linux64/driver_alvr_server.so --deploy-deps-only={appdir}/usr/lib64/libalvr_vulkan_layer.so --output appimage").run().unwrap(); -} - pub fn include_licenses(root_path: &Path, gpl: bool) { let sh = Shell::new().unwrap(); @@ -156,51 +94,47 @@ pub fn include_licenses(root_path: &Path, gpl: bool) { .unwrap(); } -pub fn package_streamer(gpl: bool, root: Option, appimage: bool, zsync: bool) { +pub fn package_streamer( + platform: Option, + skip_admin_priv: bool, + enable_nvenc: bool, + gpl: bool, + root: Option, +) { let sh = Shell::new().unwrap(); - build::build_streamer( - Profile::Distribution, - !appimage, - gpl, - root, - true, - false, - false, - ); + 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); include_licenses(&afs::streamer_build_dir(), gpl); - if OS == "windows" { + if cfg!(windows) { command::zip(&sh, &afs::streamer_build_dir()).unwrap(); - - // todo: remove installer - // note: wix package is broken, find alternative - //build_windows_installer(); } else { command::targz(&sh, &afs::streamer_build_dir()).unwrap(); - - if appimage { - package_streamer_appimage(true, zsync); - } } } -pub fn package_launcher(appimage: bool) { +pub fn package_launcher(platform: Option, skip_admin_priv: bool) { let sh = Shell::new().unwrap(); - build::build_launcher(Profile::Distribution, !appimage, true); + fs::remove_dir_all(afs::launcher_build_dir()).ok(); + + dependencies::prepare_server_deps(platform, skip_admin_priv, false); + + build::build_launcher(Profile::Distribution, true); include_licenses(&afs::launcher_build_dir(), false); - if OS == "windows" { + if cfg!(windows) { command::zip(&sh, &afs::launcher_build_dir()).unwrap(); // todo: installer } else { command::targz(&sh, &afs::launcher_build_dir()).unwrap(); - - // todo: appimage } } @@ -213,8 +147,8 @@ pub fn replace_client_openxr_manifest(from_pattern: &str, to: &str) { fs::write(manifest_path, manifest_string).unwrap(); } -pub fn package_client_openxr(flavor: ReleaseFlavor) { - crate::clean(); +pub fn package_client_openxr(flavor: ReleaseFlavor, skip_admin_priv: bool) { + fs::remove_dir_all(afs::deps_dir().join("android_openxr")).ok(); let openxr_selection = match flavor { ReleaseFlavor::GitHub => OpenXRLoadersSelection::All, @@ -222,7 +156,7 @@ pub fn package_client_openxr(flavor: ReleaseFlavor) { ReleaseFlavor::PicoStore => OpenXRLoadersSelection::OnlyPico, }; - dependencies::build_android_deps(false, false, openxr_selection); + dependencies::build_android_deps(skip_admin_priv, false, openxr_selection); if !matches!(flavor, ReleaseFlavor::GitHub) { replace_client_openxr_manifest(