diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..4a45b73 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.aarch64-linux-android.openxr_loader] +rustc-link-search = ["runtime_libs/arm64-v8a"] diff --git a/.github/workflows/cd_android_gh-pages.yml b/.github/workflows/cd_android_gh-pages.yml new file mode 100644 index 0000000..2772bef --- /dev/null +++ b/.github/workflows/cd_android_gh-pages.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c3110b..95aa3d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0e6c55c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "runtime_libs"] + path = runtime_libs + url = https://github.com/DerKarlos/OSMeta.git + branch = binaries diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..32391d3 --- /dev/null +++ b/CONTRIBUTING.md @@ -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 +``` diff --git a/Cargo.toml b/Cargo.toml index 0be2763..45a0d18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] @@ -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"] diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..c2bce4f --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rerun-if-changed=build.rs"); +} diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..60de4dd Binary files /dev/null and b/icon.png differ diff --git a/icon.xcf b/icon.xcf new file mode 100644 index 0000000..af5ee01 Binary files /dev/null and b/icon.xcf differ diff --git a/manifest.yaml b/manifest.yaml new file mode 100644 index 0000000..3c7047e --- /dev/null +++ b/manifest.yaml @@ -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 diff --git a/src/bin/demo.rs b/src/bin/demo.rs new file mode 100644 index 0000000..7c02085 --- /dev/null +++ b/src/bin/demo.rs @@ -0,0 +1,3 @@ +fn main() { + osmeta::main(); +} diff --git a/src/main.rs b/src/lib.rs similarity index 99% rename from src/main.rs rename to src/lib.rs index c723832..3560ab1 100644 --- a/src/main.rs +++ b/src/lib.rs @@ -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")))]