Skip to content

Commit

Permalink
fix(xtask): 🐛 Fix package commands; update release ci (#2545)
Browse files Browse the repository at this point in the history
  • Loading branch information
zmerp authored Dec 1, 2024
1 parent e984795 commit 56cb799
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 160 deletions.
14 changes: 5 additions & 9 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions alvr/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
6 changes: 3 additions & 3 deletions alvr/common/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {
Expand All @@ -210,7 +210,7 @@ pub fn set_panic_hook() {
pub fn show_w<W: Display + Send + 'static>(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")
Expand All @@ -228,7 +228,7 @@ pub fn show_warn<T, E: Display + Send + 'static>(res: Result<T, E>) -> Option<T>
fn show_e_block<E: Display>(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
Expand Down
22 changes: 2 additions & 20 deletions alvr/xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ impl Display for Profile {
}
}

pub fn build_server_lib(
profile: Profile,
enable_messagebox: bool,
root: Option<String>,
reproducible: bool,
) {
pub fn build_server_lib(profile: Profile, root: Option<String>, reproducible: bool) {
let sh = Shell::new().unwrap();

let mut flags = vec![];
Expand All @@ -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");
}
Expand Down Expand Up @@ -82,7 +73,6 @@ pub fn build_server_lib(

pub fn build_streamer(
profile: Profile,
enable_messagebox: bool,
gpl: bool,
root: Option<String>,
reproducible: bool,
Expand All @@ -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");
}
Expand Down Expand Up @@ -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![];
Expand All @@ -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");
}
Expand Down
26 changes: 25 additions & 1 deletion alvr/xtask/src/dependencies.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -299,6 +299,30 @@ pub fn prepare_macos_deps() {
update_submodules(&sh);
}

pub fn prepare_server_deps(
platform: Option<BuildPlatform>,
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();
Expand Down
65 changes: 32 additions & 33 deletions alvr/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -60,12 +58,19 @@ FLAGS:
--pico-store For package-client subcommand, build for Pico Store
ARGS:
--platform <NAME> Name of the platform (operative system or hardware name). snake_case
--platform <NAME> Name of the platform (operative system name)
--version <VERSION> Specify version to set with the bump-versions subcommand
--root <PATH> 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();

Expand Down Expand Up @@ -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<String> = 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<String> = args.opt_value_from_str("--version").unwrap();
let root: Option<String> = args.opt_value_from_str("--root").unwrap();

Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -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(),
Expand Down
Loading

0 comments on commit 56cb799

Please sign in to comment.