Skip to content

Commit e95e9c4

Browse files
committed
Drop unneeded cargo-apk setup and add xbuild docs
Without configuration `cargo-apk` uses the default `rust.<package>` namespace, instead of the hardcoded `com.foo.bar`. Similarly `xbuild` can build and run this project out of the box, no extra configuration (nor installation / dependencies!) required.
1 parent 3ad2b59 commit e95e9c4

File tree

15 files changed

+86
-361
lines changed

15 files changed

+86
-361
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ jobs:
2323
with:
2424
rust-version: ${{ matrix.rust_version }}
2525

26+
- name: Install LLVM
27+
run: sudo apt-get update && sudo apt-get install llvm
28+
29+
- name: Build na-mainloop with xbuild
30+
working-directory: na-mainloop
31+
run: |
32+
cargo install xbuild
33+
# Showcase that x builds out-of-the-box with no external dependencies
34+
x build --platform android --arch arm64
35+
2636
- name: Install Rust targets
2737
run: >
2838
rustup target add

agdk-cpal/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This is a minimal test application based on `GameActivity` that just
22
runs a mainloop based on android_activity::poll_events() and plays a
33
sine wave audio test using the Cpal audio library.
44

5-
```
5+
```bash
66
export ANDROID_NDK_HOME="path/to/ndk"
77
export ANDROID_HOME="path/to/sdk"
88

agdk-eframe/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ This tests using `GameActivity` with egui, winit and wgpu.
33
This is based on a re-worked winit backend here:
44
https://github.com/rib/winit/tree/android-activity
55

6-
```
6+
```bash
77
export ANDROID_NDK_HOME="path/to/ndk"
88
export ANDROID_HOME="path/to/sdk"
99

agdk-mainloop/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ runs a mainloop based on android_activity::poll_events() and traces
33
the events received without doing any rendering. It also saves and
44
restores some minimal application state.
55

6-
```
6+
```bash
77
export ANDROID_NDK_HOME="path/to/ndk"
88
export ANDROID_HOME="path/to/sdk"
99

agdk-oboe/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ This is a minimal test application based on `GameActivity` that just
22
runs a mainloop based on android_activity::poll_events() and plays a
33
sine wave audio test using the Oboe audio library.
44

5-
```
5+
```bash
66
export ANDROID_NDK_HOME="path/to/ndk"
77
export ANDROID_HOME="path/to/sdk"
88

na-mainloop/Cargo.toml

Lines changed: 2 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -8,178 +8,11 @@ edition = "2021"
88
[dependencies]
99
log = "0.4"
1010
android_logger = "0.11.0"
11-
android-activity = { version = "0.4", features = [ "native-activity" ] }
11+
android-activity = { version = "0.4", features = ["native-activity"] }
1212
#android-activity = { path = "../../android-activity/android-activity", features = [ "native-activity" ] }
1313
ndk-sys = "0.4"
1414
ndk = "0.7"
1515

1616
[lib]
1717
#name="na_mainloop"
18-
crate_type=["cdylib"]
19-
20-
21-
####################
22-
# cargo apk config #
23-
####################
24-
25-
[package.metadata.android]
26-
# Specifies the package property of the manifest.
27-
package = "com.foo.bar"
28-
29-
# Specifies the array of targets to build for.
30-
build_targets = [ "aarch64-linux-android" ]
31-
32-
# Path to your application's resources folder.
33-
# If not specified, resources will not be included in the APK.
34-
#resources = "path/to/resources_folder"
35-
36-
# Path to the folder containing your application's assets.
37-
# If not specified, assets will not be included in the APK.
38-
#assets = "path/to/assets_folder"
39-
40-
# Name for final APK file.
41-
# Defaults to package name.
42-
#apk_name = "myapp"
43-
44-
# Folder containing extra shared libraries intended to be dynamically loaded at runtime.
45-
# Files matching `libs_folder/${android_abi}/*.so` are added to the apk
46-
# according to the specified build_targets.
47-
#runtime_libs = "path/to/libs_folder"
48-
49-
# See https://developer.android.com/guide/topics/manifest/uses-sdk-element
50-
#
51-
# Defaults to a `min_sdk_version` of 23 and `target_sdk_version` of 30 (or lower if the detected NDK doesn't support this).
52-
[package.metadata.android.sdk]
53-
min_sdk_version = 28
54-
target_sdk_version = 31
55-
#max_sdk_version = 31
56-
57-
# See https://developer.android.com/guide/topics/manifest/uses-feature-element
58-
#
59-
# Note: there can be multiple .uses_feature entries.
60-
[[package.metadata.android.uses_feature]]
61-
name = "android.hardware.vulkan.level"
62-
required = true
63-
version = 1
64-
65-
# See https://developer.android.com/guide/topics/manifest/uses-permission-element
66-
#
67-
# Note: there can be multiple .uses_permission entries.
68-
#[[package.metadata.android.uses_permission]]
69-
#name = "android.permission.WRITE_EXTERNAL_STORAGE"
70-
#max_sdk_version = 18
71-
72-
# See https://developer.android.com/guide/topics/manifest/queries-element#provider
73-
#[[package.metadata.android.queries.provider]]
74-
#authorities = "org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker"
75-
# Note: The `name` attribute is normally not required for a queries provider, but is non-optional
76-
# as a workaround for aapt throwing errors about missing `android:name` attribute.
77-
# This will be made optional if/when cargo-apk migrates to aapt2.
78-
#name = "org.khronos.openxr"
79-
80-
# See https://developer.android.com/guide/topics/manifest/queries-element#intent
81-
#[[package.metadata.android.queries.intent]]
82-
#actions = ["android.intent.action.SEND"]
83-
84-
# See https://developer.android.com/guide/topics/manifest/queries-element#intent
85-
# Note: there can be several .data entries.
86-
#[[package.metadata.android.queries.intent.data]]
87-
#mime_type = "image/jpeg"
88-
89-
# See https://developer.android.com/guide/topics/manifest/queries-element#package
90-
#[[package.metadata.android.queries.package]]
91-
#name = "org.freedesktop.monado.openxr_runtime.in_process"
92-
93-
# See https://developer.android.com/guide/topics/manifest/application-element
94-
#[package.metadata.android.application]
95-
96-
# See https://developer.android.com/guide/topics/manifest/application-element#debug
97-
#
98-
# Defaults to false.
99-
#debuggable = false
100-
101-
# See https://developer.android.com/guide/topics/manifest/application-element#theme
102-
#
103-
# Example shows setting the theme of an application to fullscreen.
104-
#theme = "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
105-
106-
# Virtual path your application's icon for any mipmap level.
107-
# If not specified, an icon will not be included in the APK.
108-
#icon = "@mipmap/ic_launcher"
109-
110-
# See https://developer.android.com/guide/topics/manifest/application-element#label
111-
#
112-
# Defaults to the compiled artifact's name.
113-
label = "Application Name"
114-
115-
# See https://developer.android.com/guide/topics/manifest/meta-data-element
116-
#
117-
# Note: there can be several .meta_data entries.
118-
# Note: the `resource` attribute is currently not supported.
119-
#[[package.metadata.android.application.meta_data]]
120-
#name = "com.samsung.android.vr.application.mode"
121-
#value = "vr_only"
122-
123-
# See https://developer.android.com/guide/topics/manifest/activity-element
124-
[package.metadata.android.application.activity]
125-
126-
# See https://developer.android.com/guide/topics/manifest/activity-element#nm
127-
#
128-
# The name of the class that implements the activity, a subclass of Activity
129-
#
130-
# Defaults to "android.app.NativeActivity"
131-
# name = "android.app.MyActivity"
132-
133-
# See https://developer.android.com/guide/topics/manifest/activity-element#config
134-
#
135-
# Defaults to "orientation|keyboardHidden|screenSize".
136-
#config_changes = "orientation"
137-
138-
# See https://developer.android.com/guide/topics/manifest/activity-element#label
139-
#
140-
# Defaults to the application's label.
141-
#label = "Activity Name"
142-
143-
# See https://developer.android.com/guide/topics/manifest/activity-element#lmode
144-
#
145-
# Defaults to "standard".
146-
#launch_mode = "singleTop"
147-
148-
# See https://developer.android.com/guide/topics/manifest/activity-element#screen
149-
#
150-
# Defaults to "unspecified".
151-
#orientation = "landscape"
152-
153-
# See https://developer.android.com/guide/topics/manifest/activity-element#exported
154-
#
155-
# Unset by default, or "true" when targeting Android >= 31 (S and up).
156-
#exported = "true"
157-
158-
# See https://developer.android.com/guide/topics/manifest/meta-data-element
159-
#
160-
# Note: there can be several .meta_data entries.
161-
# Note: the `resource` attribute is currently not supported.
162-
#[[package.metadata.android.application.activity.meta_data]]
163-
#name = "com.oculus.vr.focusaware"
164-
#value = "true"
165-
166-
# See https://developer.android.com/guide/topics/manifest/intent-filter-element
167-
#
168-
# Note: there can be several .intent_filter entries.
169-
#[[package.metadata.android.application.activity.intent_filter]]
170-
# See https://developer.android.com/guide/topics/manifest/action-element
171-
#actions = ["android.intent.action.VIEW", "android.intent.action.WEB_SEARCH"]
172-
# See https://developer.android.com/guide/topics/manifest/category-element
173-
#categories = ["android.intent.category.DEFAULT", "android.intent.category.BROWSABLE"]
174-
175-
# See https://developer.android.com/guide/topics/manifest/data-element
176-
#
177-
# Note: there can be several .data entries.
178-
# Note: not specifying an attribute excludes it from the final data specification.
179-
#[[package.metadata.android.application.activity.intent_filter.data]]
180-
#scheme = "https"
181-
#host = "github.com"
182-
#port = "8080"
183-
#path = "/rust-windowing/android-ndk-rs/tree/master/cargo-apk"
184-
#path_prefix = "/rust-windowing/"
185-
#mime_type = "image/jpeg"
18+
crate_type = ["cdylib"]

na-mainloop/README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@ the events received without doing any rendering. It also saves and
44
restores some minimal application state.
55

66
Since this test doesn't require a custom `Activity` subclass it's
7-
optionally possible to build this example with `cargo apk`.
7+
optionally possible to build this example with `xbuild` or `cargo apk`.
88

9-
# Gradle Build
9+
# xbuild
10+
11+
```bash
12+
cargo install xbuild
13+
14+
# Get ID of connected debug device, of the form adb:DEVICEID
15+
x devices
16+
17+
# Build and run for that configuration
18+
x run --device adb:DEVICEID
19+
20+
# Or build for a generic arm64 Android device
21+
x build --platform android --arch arm64
1022
```
23+
24+
# Gradle Build
25+
26+
```bash
1127
export ANDROID_NDK_HOME="path/to/ndk"
1228
export ANDROID_HOME="path/to/sdk"
1329

@@ -20,7 +36,8 @@ cargo ndk -t arm64-v8a -o app/src/main/jniLibs/ build
2036
```
2137

2238
# Cargo APK Build
23-
```
39+
40+
```bash
2441
export ANDROID_NDK_HOME="path/to/ndk"
2542
export ANDROID_SDK_HOME="path/to/sdk"
2643

na-openxr-info/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ android_logger = "0.11.0"
1717
android-activity = { version = "0.4", features = ["native-activity"] }
1818

1919
[features]
20-
default = [ "linked" ]
20+
default = ["linked"]
2121

22-
android = [ "openxr/linked" ]
23-
desktop = [ "linked", "openxr/static"]
24-
linked = []
22+
android = ["linked"]
23+
desktop = ["linked", "openxr/static"]
24+
linked = ["openxr/linked"]
2525

2626
[lib]
27-
name="main"
28-
crate_type=["cdylib"]
27+
name = "main"
28+
crate_type = ["cdylib"]
2929

3030
[[bin]]
31-
path="src/lib.rs"
32-
name="test-winit-wgpu"
33-
required-features = [ "desktop" ]
31+
path = "src/lib.rs"
32+
name = "test-winit-wgpu"
33+
required-features = ["desktop"]

na-openxr-info/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///! Based on https://github.com/Ralith/openxrs/blob/master/openxr/examples/hello.rs
1+
//! Based on <https://github.com/Ralith/openxrs/blob/master/openxr/examples/hello.rs>
22
use openxr as xr;
33

44
#[cfg(target_os = "android")]

na-openxr-wgpu/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ library to `app/src/main/jniLibs/<abi>`
2121
For example if building for arm64-v8a:
2222
`cp path/to/ovr_openxr_mobile_sdk_42.0/OpenXR/Libs/Android/arm64-v8a/Debug/libopenxr_loader.so app/src/main/jniLibs/arm64-v8a`
2323

24-
```
24+
```bash
2525
export ANDROID_NDK_HOME="path/to/ndk"
2626
export ANDROID_HOME="path/to/sdk"
2727

@@ -36,12 +36,13 @@ cargo ndk -t arm64-v8a -o app/src/main/jniLibs/ build
3636
# Oculus Quest: Vulkan Validation Layer
3737

3838
To enable the Vulkan validation layer on the Oculus Quest run:
39-
```
39+
40+
```bash
4041
adb shell setprop debug.oculus.loadandinjectpackagedvvl.co.realfit.naopenxrwgpu 1
4142
```
4243

4344
# Desktop
4445

4546
To build for PC you need to build with the "desktop" feature
4647

47-
`cargo run --features=desktop`
48+
`cargo run --features=desktop`

0 commit comments

Comments
 (0)