Skip to content

Commit

Permalink
implement quest support
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Nov 19, 2023
1 parent 6510436 commit bbfe7bf
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.aarch64-linux-android.openxr_loader]
rustc-link-search = ["runtime_libs/arm64-v8a"]
33 changes: 33 additions & 0 deletions .github/workflows/cd_android_gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: deploy android/quest apk to gh-pages
on:
workflow_run:
branches: [main]
workflows: [CI]
types: [completed]

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-android

- run: mkdir dist
- run: cp target/x/release/android/osmeta.apk dist/osmeta.apk

- uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
keep_files: true
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,33 @@ jobs:
run: rustup component add rustfmt
- name: Run cargo fmt
run: cargo fmt --all -- --check

android:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Install Dependencies
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev lld llvm
- uses: actions/checkout@v4
- run: git submodule update --init
- name: Cache
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-android
- uses: dtolnay/rust-toolchain@stable
- name: Add Android targets
run: rustup target add aarch64-linux-android armv7-linux-androideabi
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install xbuild
run: cargo binstall --git https://github.com/NiklasEi/xbuild --bin-dir x xbuild -y
- name: show deps
run: x doctor
- name: Build app bundle
run: x build --release --platform android --format apk --arch arm64
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "runtime_libs"]
path = runtime_libs
url = https://github.com/DerKarlos/OSMeta.git
branch = binaries
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Build for android

On windows hosts, install `llvm` (contains `clang`) from https://github.com/llvm/llvm-project/releases/

```
cargo install --git https://github.com/NiklasEi/xbuild
```

run `x doctor` to see what else you need to install for android, then run

```
x build --release --platform android --format apk --arch arm64
```
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "osmeta" # OSMeta ??? `#[warn(non_snake_case)]` on by default
name = "osmeta" # OSMeta ??? `#[warn(non_snake_case)]` on by default
version = "0.1.0"
edition = "2021"

links = "openxr_loader"
build = "build.rs"

# Enable a small amount of optimization in debug mode
[profile.dev]
Expand Down Expand Up @@ -36,3 +37,10 @@ default = ["xr"]
# path = "examples/test.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


# we need to split our crate into a lib and a binary, because android targets don't want a binary.
# our binary is now just a tiny dummy thing that invokes the library's main function.
[lib]
name = "osmeta"
crate-type = ["staticlib", "cdylib", "lib"]
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("cargo:rerun-if-changed=build.rs");
}
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon.xcf
Binary file not shown.
27 changes: 27 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
android:
runtime_libs:
- "runtime_libs"
manifest:
package: "osm.eta.app"
application:
label: "OSMeta"
theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
meta_data:
- name: "com.oculus.intent.category.VR"
value: "vr_only"
- name: "com.samsung.android.vr.application.mode"
value: "vr_only"
- name: "com.oculus.supportedDevices"
value: "quest|quest2|quest3|questpro"
activities:
- config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
launch_mode: "singleTask"
orientation: "landscape"
intent_filters:
- actions:
- "android.intent.action.MAIN"
categories:
- "com.oculus.intent.category.VR"
- "android.intent.category.LAUNCHER"
sdk:
target_sdk_version: 32
3 changes: 3 additions & 0 deletions src/bin/demo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
osmeta::main();
}
3 changes: 2 additions & 1 deletion src/main.rs → src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ mod tilemap;
#[cfg(all(feature = "xr", not(target_os = "macos")))]
mod xr;

fn main() {
#[bevy_main]
pub fn main() {
let mut app = App::new();
if std::env::args().any(|arg| arg == "xr") {
#[cfg(all(feature = "xr", not(target_os = "macos")))]
Expand Down

0 comments on commit bbfe7bf

Please sign in to comment.