build(xtask): Add xtask build-server-lib

This commit is contained in:
Riccardo Zaglia 2023-10-18 13:48:16 +08:00
parent 6374dee48e
commit 2b17f057a0
4 changed files with 86 additions and 16 deletions

10
alvr/server/cbindgen.toml Normal file
View File

@ -0,0 +1,10 @@
language = "C"
header = "/* ALVR is licensed under the MIT license. https://github.com/alvr-org/ALVR/blob/master/LICENSE */"
pragma_once = true
autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */"
cpp_compat = true
tab_width = 4
documentation_style = "c99"
[enum]
rename_variants = "QualifiedScreamingSnakeCase"

View File

@ -1,6 +1,5 @@
#![allow(dead_code, unused_variables)]
use ash::vk;
use std::{
ffi::{c_char, CStr},
time::Instant,
@ -239,27 +238,29 @@ pub unsafe extern "C" fn alvr_post_vulkan() {
pub unsafe extern "C" fn alvr_create_vk_target_swapchain(
width: u32,
height: u32,
color_format: vk::Format,
color_space: vk::ColorSpaceKHR,
image_usage: vk::ImageUsageFlags,
present_mode: vk::PresentModeKHR,
vk_color_format: i32,
vk_color_space: i32,
vk_image_usage: u32,
vk_present_mode: i32,
image_count: u64,
) {
todo!()
}
// returns vkResult
#[no_mangle]
pub unsafe extern "C" fn alvr_acquire_image(out_swapchain_index: u64) -> vk::Result {
pub unsafe extern "C" fn alvr_acquire_image(out_swapchain_index: u64) -> i32 {
todo!()
}
// returns vkResult
#[no_mangle]
pub unsafe extern "C" fn alvr_present(
queue: vk::Queue,
vk_queue: u64,
swapchain_index: u64,
timeline_semaphore_value: u64,
timestamp_ns: u64,
) -> vk::Result {
) -> i32 {
todo!()
}

View File

@ -26,6 +26,64 @@ impl Display for Profile {
}
}
pub fn build_server_lib(
profile: Profile,
enable_messagebox: bool,
gpl: bool,
root: Option<String>,
reproducible: bool,
) {
let sh = Shell::new().unwrap();
let mut flags = vec![];
match profile {
Profile::Distribution => {
flags.push("--profile");
flags.push("distribution");
}
Profile::Release => flags.push("--release"),
Profile::Debug => (),
}
if enable_messagebox {
flags.push("--features");
flags.push("alvr_common/enable-messagebox");
}
if gpl {
flags.push("--features");
flags.push("gpl");
}
if reproducible {
flags.push("--locked");
}
let flags_ref = &flags;
let artifacts_dir = afs::target_dir().join(profile.to_string());
let build_dir = afs::build_dir().join("alvr_server_core");
sh.create_dir(&build_dir).unwrap();
if let Some(root) = root {
sh.set_var("ALVR_ROOT_DIR", root);
}
let _push_guard = sh.push_dir(afs::crate_dir("server"));
cmd!(sh, "cargo build {flags_ref...}").run().unwrap();
sh.copy_file(
artifacts_dir.join(afs::dynlib_fname("alvr_server")),
&build_dir,
)
.unwrap();
if cfg!(windows) {
sh.copy_file(artifacts_dir.join("alvr_server_core.pdb"), &build_dir)
.unwrap();
}
let out = build_dir.join("alvr_server_core.h");
cmd!(sh, "cbindgen --output {out}").run().unwrap();
}
pub fn build_streamer(
profile: Profile,
enable_messagebox: bool,
@ -64,9 +122,8 @@ pub fn build_streamer(
None
};
sh.remove_path(&afs::streamer_build_dir()).unwrap();
sh.create_dir(&build_layout.openvr_driver_lib_dir())
.unwrap();
sh.remove_path(afs::streamer_build_dir()).unwrap();
sh.create_dir(build_layout.openvr_driver_lib_dir()).unwrap();
sh.create_dir(&build_layout.executables_dir).unwrap();
if let Some(config) = maybe_config {
@ -235,9 +292,6 @@ pub fn build_launcher(profile: Profile, enable_messagebox: bool, reproducible: b
pub fn build_client_lib(profile: Profile, link_stdcpp: bool) {
let sh = Shell::new().unwrap();
let build_dir = afs::build_dir().join("alvr_client_core");
sh.create_dir(&build_dir).unwrap();
let strip_flag = matches!(profile, Profile::Debug).then_some("--no-strip");
let mut flags = vec![];
@ -254,6 +308,9 @@ pub fn build_client_lib(profile: Profile, link_stdcpp: bool) {
}
let flags_ref = &flags;
let build_dir = afs::build_dir().join("alvr_client_core");
sh.create_dir(&build_dir).unwrap();
let _push_guard = sh.push_dir(afs::crate_dir("client_core"));
cmd!(

View File

@ -22,14 +22,15 @@ SUBCOMMANDS:
prepare-deps Download and compile streamer and client external dependencies
build-streamer Build streamer, then copy binaries to build folder
build-launcher Build launcher, then copy binaries to build folder
build-server-lib Build a C-ABI ALVR server library and header
build-client Build client, then copy binaries to build folder
build-client-lib Build a C-ABI ALVR client library and header.
build-client-lib Build a C-ABI ALVR client library and header
run-streamer Build streamer and then open the dashboard
run-launcher Build launcher and then open it
package-streamer Build streamer with distribution profile, make archive
package-launcher Build launcher in release mode, make portable and installer versions
package-client-lib Build client library then zip it
clean Removes all build artifacts and dependencies.
clean Removes all build artifacts and dependencies
bump Bump streamer and client package versions
clippy Show warnings for selected clippy lints
kill-oculus Kill all Oculus processes
@ -190,6 +191,7 @@ fn main() {
build::build_streamer(profile, true, gpl, None, false, keep_config)
}
"build-launcher" => build::build_launcher(profile, true, false),
"build-server-lib" => build::build_server_lib(profile, true, gpl, None, false),
"build-client" => build::build_android_client(profile),
"build-client-lib" => build::build_client_lib(profile, link_stdcpp),
"run-streamer" => {