Merge pull request #147 from Schmarni-Dev/build_script_and_pico

add android build script and pico support
This commit is contained in:
Schmarni
2024-08-21 21:43:57 +02:00
committed by GitHub
3 changed files with 45 additions and 1 deletions

View File

@@ -11,6 +11,10 @@ bevy_mod_openxr.path = "../.."
bevy = { workspace = true, default-features = true } bevy = { workspace = true, default-features = true }
bevy_xr_utils.path = "../../../bevy_xr_utils" bevy_xr_utils.path = "../../../bevy_xr_utils"
[build-dependencies]
reqwest = { version = "0.12", features = ["blocking"] }
zip = "2.1"
[lib] [lib]
name = "bevy_openxr_android" name = "bevy_openxr_android"

View File

@@ -0,0 +1,36 @@
use std::{env, ffi::OsString, fs, io::Read, path::Path};
pub const OPENXR_VERSION: &str = "1.1.38";
fn main() {
println!("cargo::rerun-if-changed=build.rs");
if env::var_os("CARGO_CFG_TARGET_OS") != Some(OsString::from("android")) {
return;
}
let mut resp = reqwest::blocking::get(
format!(
"https://github.com/KhronosGroup/OpenXR-SDK-Source/releases/download/release-{}/openxr_loader_for_android-{}.aar",
OPENXR_VERSION,OPENXR_VERSION)).unwrap();
if !resp.status().is_success() {
eprintln!("ERROR: Unable to get OpenXR loader from github release");
return;
}
let mut file = Vec::new();
resp.read_to_end(&mut file).unwrap();
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("openxr_loader_android.arr");
fs::write(&dest_path, file).unwrap();
let file = fs::File::open(&dest_path).unwrap();
let mut zip_file = zip::ZipArchive::new(file).unwrap();
eprintln!("{:#?}", zip_file.file_names().collect::<Vec<_>>());
let mut loader_file = zip_file
.by_name("prefab/modules/openxr_loader/libs/android.arm64-v8a/libopenxr_loader.so")
.unwrap();
let mut file = Vec::new();
loader_file.read_to_end(&mut file).unwrap();
let out_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("./runtime_libs/arm64-v8a/libopenxr_loader.so");
let _ = fs::create_dir_all(dest_path.parent().unwrap());
fs::write(&dest_path, file).unwrap();
}

View File

@@ -24,6 +24,10 @@ android:
value: "vr_only" value: "vr_only"
- name: "com.oculus.supportedDevices" - name: "com.oculus.supportedDevices"
value: "quest|quest2|quest3|questpro" value: "quest|quest2|quest3|questpro"
- name: "pvr.app.type"
value: "vr"
- name: "pvr.sdk.version"
value: "OpenXR"
activities: activities:
- config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode|screenLayout" - config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode|screenLayout"
launch_mode: "singleTask" launch_mode: "singleTask"
@@ -36,4 +40,4 @@ android:
- "android.intent.category.LAUNCHER" - "android.intent.category.LAUNCHER"
- "org.khronos.openxr.intent.category.IMMERSIVE_HMD" - "org.khronos.openxr.intent.category.IMMERSIVE_HMD"
sdk: sdk:
target_sdk_version: 32 target_sdk_version: 32