Skip to content

Commit 13cca02

Browse files
committed
Merge branch 'master' into v20
2 parents 14af564 + 1d15ddd commit 13cca02

File tree

4 files changed

+40
-17
lines changed

4 files changed

+40
-17
lines changed

alvr/client_openxr/src/c_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(target_os = "android")]
22
#[no_mangle]
33
pub extern "C" fn alvr_entry_point(java_vm: *mut std::ffi::c_void, context: *mut std::ffi::c_void) {
4-
ndk_context::initialize_android_context(java_vm, context);
4+
unsafe { ndk_context::initialize_android_context(java_vm, context) };
55

66
crate::entry_point();
77
}

alvr/xtask/src/build.rs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,41 +297,60 @@ pub fn build_launcher(profile: Profile, enable_messagebox: bool, reproducible: b
297297
.unwrap();
298298
}
299299

300-
pub fn build_client_lib(profile: Profile, link_stdcpp: bool) {
300+
fn build_android_lib_impl(dir_name: &str, profile: Profile, link_stdcpp: bool) {
301301
let sh = Shell::new().unwrap();
302302

303-
let strip_flag = matches!(profile, Profile::Debug).then_some("--no-strip");
304-
305-
let mut flags = vec![];
303+
let ndk_flags = &[
304+
"-t",
305+
"arm64-v8a",
306+
"-t",
307+
"armeabi-v7a",
308+
"-t",
309+
"x86_64",
310+
"-t",
311+
"x86",
312+
"-p",
313+
"26",
314+
"--no-strip",
315+
];
316+
317+
let mut rust_flags = vec![];
306318
match profile {
307319
Profile::Distribution => {
308-
flags.push("--profile");
309-
flags.push("distribution")
320+
rust_flags.push("--profile");
321+
rust_flags.push("distribution")
310322
}
311-
Profile::Release => flags.push("--release"),
323+
Profile::Release => rust_flags.push("--release"),
312324
Profile::Debug => (),
313325
}
314326
if !link_stdcpp {
315-
flags.push("--no-default-features");
327+
rust_flags.push("--no-default-features");
316328
}
317-
let flags_ref = &flags;
329+
let rust_flags_ref = &rust_flags;
318330

319-
let build_dir = afs::build_dir().join("alvr_client_core");
331+
let build_dir = afs::build_dir().join(format!("alvr_{dir_name}"));
320332
sh.create_dir(&build_dir).unwrap();
321333

322-
let _push_guard = sh.push_dir(afs::crate_dir("client_core"));
323-
334+
let _push_guard = sh.push_dir(afs::crate_dir(dir_name));
324335
cmd!(
325336
sh,
326-
"cargo ndk -t arm64-v8a -t armeabi-v7a -t x86_64 -t x86 -p 26 {strip_flag...} -o {build_dir} build {flags_ref...}"
337+
"cargo ndk {ndk_flags...} -o {build_dir} build {rust_flags_ref...}"
327338
)
328339
.run()
329340
.unwrap();
330341

331-
let out = build_dir.join("alvr_client_core.h");
342+
let out = build_dir.join(format!("alvr_{dir_name}.h"));
332343
cmd!(sh, "cbindgen --output {out}").run().unwrap();
333344
}
334345

346+
pub fn build_android_client_core_lib(profile: Profile, link_stdcpp: bool) {
347+
build_android_lib_impl("client_core", profile, link_stdcpp)
348+
}
349+
350+
pub fn build_android_client_openxr_lib(profile: Profile, link_stdcpp: bool) {
351+
build_android_lib_impl("client_openxr", profile, link_stdcpp)
352+
}
353+
335354
pub fn build_android_client(profile: Profile) {
336355
let sh = Shell::new().unwrap();
337356

alvr/xtask/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ SUBCOMMANDS:
2525
build-server-lib Build a C-ABI ALVR server library and header
2626
build-client Build client, then copy binaries to build folder
2727
build-client-lib Build a C-ABI ALVR client library and header
28+
build-client-xr-lib Build a C-ABI ALVR OpenXR entry point client library and header
2829
run-streamer Build streamer and then open the dashboard
2930
run-launcher Build launcher and then open it
3031
package-streamer Build streamer with distribution profile, make archive
@@ -195,7 +196,10 @@ fn main() {
195196
"build-launcher" => build::build_launcher(profile, true, false),
196197
"build-server-lib" => build::build_server_lib(profile, true, gpl, None, false),
197198
"build-client" => build::build_android_client(profile),
198-
"build-client-lib" => build::build_client_lib(profile, link_stdcpp),
199+
"build-client-lib" => build::build_android_client_core_lib(profile, link_stdcpp),
200+
"build-client-xr-lib" => {
201+
build::build_android_client_openxr_lib(profile, link_stdcpp)
202+
}
199203
"run-streamer" => {
200204
if !no_rebuild {
201205
build::build_streamer(

alvr/xtask/src/packaging.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub fn package_launcher(appimage: bool) {
196196
pub fn package_client_lib(link_stdcpp: bool) {
197197
let sh = Shell::new().unwrap();
198198

199-
build::build_client_lib(Profile::Distribution, link_stdcpp);
199+
build::build_android_client_core_lib(Profile::Distribution, link_stdcpp);
200200

201201
command::zip(&sh, &afs::build_dir().join("alvr_client_core")).unwrap();
202202
}

0 commit comments

Comments
 (0)