Skip to content

Commit

Permalink
Initial support for native android builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeicor committed Aug 13, 2023
1 parent 3cdca0f commit a1c6d80
Show file tree
Hide file tree
Showing 10 changed files with 850 additions and 461 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/release-wasm-post.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cat >index.html <<EOF
<body>
<canvas id="sdf-viewer" style="position: absolute;top:0;bottom: 0;left: 0;right: 0;margin:auto;"></canvas>
<script type="module">
import * as SDFViewer from './sdf_viewer_lib.js';
import * as SDFViewer from './sdf_viewer.js';
SDFViewer.default().then( // Async initialization
() => SDFViewer.run_app("sdf-viewer")); // Run the actual App
Expand All @@ -45,7 +45,7 @@ EOF
# Also compile the SDF demo to an example small WASM file and include it in the distribution.
wasm_demo_file="demo_sdf.wasm"
cargo build --lib --no-default-features --features sdfdemoffi --release --target wasm32-unknown-unknown
cp "../wasm32-unknown-unknown/release/sdf_viewer_lib.wasm" "$wasm_demo_file"
cp "../wasm32-unknown-unknown/release/sdf_viewer.wasm" "$wasm_demo_file"

[ -f .gitignore ] && rm .gitignore # This may conflict with some deployments and it is already ignored in the main repo.

Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ jobs:
pre: rustup target add wasm32-unknown-unknown && curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
build: wasm-pack build --target web --out-dir ./target/pkg -- --no-default-features --features default-wasm
post: ".github/scripts/release-wasm-post.sh ./target/pkg/${GITHUB_REPOSITORY#*/}.wasm"
# TODO: Android
# - os: ubuntu-latest
# target: android # Multiple architectures are supported
# pre: rustup target add aarch64-linux-android && cargo install cargo-apk
# build: cargo apk build --release --lib
# ext: apk
# Android
- os: ubuntu-latest
target: android # Multiple architectures are supported
pre: |
apt update
apt install sdkmanager openjdk-8-jre-headless
sdkmanager --install "platforms;android-33" "ndk-bundle;r25c" "build-tools;33.0.2"
export ANDROID_HOME=/opt/android-sdk ANDROID_NDK_ROOT=/opt/android-sdk/ndk-bundle
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
cargo install cargo-apk
build: cargo apk build --lib --no-default-features --features default-android # --release requires keystore
ext: apk
# TODO: iOS
# - os: macos-latest
# target: ???
Expand Down
Loading

0 comments on commit a1c6d80

Please sign in to comment.