Skip to content

Commit

Permalink
Try #7493:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Feb 3, 2023
2 parents 6506ea4 + ee1daec commit bbd0d32
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
--no-push \
--exclude ci \
--exclude errors \
--exclude bevy-ios-example \
--exclude bevy_mobile_example \
--exclude build-wasm-example
- name: Create PR
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
--dependent-version upgrade \
--exclude ci \
--exclude errors \
--exclude bevy-ios-example \
--exclude bevy_mobile_example \
--exclude build-wasm-example
- name: Create PR
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validation-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: rustup target add aarch64-apple-ios x86_64-apple-ios

- name: Build and install iOS app in iOS Simulator.
run: cd examples/ios && make install
run: cd examples/mobile && make install

build-android:
runs-on: ubuntu-latest
Expand All @@ -56,7 +56,7 @@ jobs:
run: cargo install --force cargo-apk

- name: Build APK
run: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME cargo apk build --package bevy-android-example
run: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME cargo apk build --package bevy_mobile_example

run-examples-on-windows-dx12:
runs-on: windows-latest
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ rust-version = "1.67.0"
exclude = ["benches", "crates/bevy_ecs_compile_fail_tests", "crates/bevy_reflect_compile_fail_tests"]
members = [
"crates/*",
"examples/android",
"examples/ios",
"examples/mobile",
"tools/ci",
"tools/build-example-pages",
"tools/build-wasm-example",
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ anyhow = "1.0.4"
rodio = { version = "0.16", default-features = false }
parking_lot = "0.12.1"

[target.'cfg(target_os = "android")'.dependencies]
oboe = { version = "0.4", features = ["shared-stdcxx"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
rodio = { version = "0.16", default-features = false, features = ["wasm-bindgen"] }

Expand Down
20 changes: 10 additions & 10 deletions crates/bevy_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ struct WinitPersistentState {
impl Default for WinitPersistentState {
fn default() -> Self {
Self {
active: true,
active: false,
low_power_event: false,
redraw_request_sent: false,
timeout_reached: false,
Expand Down Expand Up @@ -289,7 +289,7 @@ pub fn winit_runner(mut app: App) {
}
}

{
if winit_state.active {
#[cfg(not(target_arch = "wasm32"))]
let (commands, mut new_windows, created_window_writer, winit_windows) =
create_window_system_state.get_mut(&mut app.world);
Expand Down Expand Up @@ -474,14 +474,7 @@ pub fn winit_runner(mut app: App) {
}
},
WindowEvent::Touch(touch) => {
let mut location =
touch.location.to_logical(window.resolution.scale_factor());

// On a mobile window, the start is from the top while on PC/Linux/OSX from
// bottom
if cfg!(target_os = "android") || cfg!(target_os = "ios") {
location.y = window.height() as f64 - location.y;
}
let location = touch.location.to_logical(window.resolution.scale_factor());

// Event
input_events
Expand Down Expand Up @@ -615,6 +608,13 @@ pub fn winit_runner(mut app: App) {
}
event::Event::Suspended => {
winit_state.active = false;
#[cfg(target_os = "android")]
{
// Bevy doesn't support suspend/resume so we just exit
// and Android will restart the application on resume
// TODO: Save save some state and load on resume
*control_flow = ControlFlow::Exit;
}
}
event::Event::Resumed => {
winit_state.active = true;
Expand Down
10 changes: 5 additions & 5 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ When using `NDK (Side by side)`, the environment variable `ANDROID_NDK_ROOT` mus
To run on a device setup for Android development, run:

```sh
cargo apk run --example android_example
cargo apk run -p bevy_mobile_example
```

When using Bevy as a library, the following fields must be added to `Cargo.toml`:
Expand Down Expand Up @@ -415,7 +415,7 @@ min_sdk_version = >>API or less<<

Example | File | Description
--- | --- | ---
`android` | [`android/android.rs`](./android/android.rs) | The `3d/3d_scene.rs` example for Android
`android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound

## iOS

Expand All @@ -436,7 +436,7 @@ rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
Using bash:

```sh
cd examples/ios
cd examples/mobile
make run
```

Expand All @@ -451,15 +451,15 @@ DEVICE_ID=${YOUR_DEVICE_ID} make run
If you'd like to see xcode do stuff, you can run

```sh
open bevy_ios_example.xcodeproj/
open bevy_mobile_example.xcodeproj/
```

which will open xcode. You then must push the zoom zoom play button and wait
for the magic.

Example | File | Description
--- | --- | ---
`ios` | [`ios/src/lib.rs`](./ios/src/lib.rs) | The `3d/3d_scene.rs` example for iOS
`ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound

## WASM

Expand Down
10 changes: 5 additions & 5 deletions examples/README.md.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ When using `NDK (Side by side)`, the environment variable `ANDROID_NDK_ROOT` mus
To run on a device setup for Android development, run:

```sh
cargo apk run --example android_example
cargo apk run -p bevy_mobile_example
```

When using Bevy as a library, the following fields must be added to `Cargo.toml`:
Expand Down Expand Up @@ -145,7 +145,7 @@ min_sdk_version = >>API or less<<

Example | File | Description
--- | --- | ---
`android` | [`android/android.rs`](./android/android.rs) | The `3d/3d_scene.rs` example for Android
`android` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound

## iOS

Expand All @@ -166,7 +166,7 @@ rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim
Using bash:

```sh
cd examples/ios
cd examples/mobile
make run
```

Expand All @@ -181,15 +181,15 @@ DEVICE_ID=${YOUR_DEVICE_ID} make run
If you'd like to see xcode do stuff, you can run

```sh
open bevy_ios_example.xcodeproj/
open bevy_mobile_example.xcodeproj/
```

which will open xcode. You then must push the zoom zoom play button and wait
for the magic.

Example | File | Description
--- | --- | ---
`ios` | [`ios/src/lib.rs`](./ios/src/lib.rs) | The `3d/3d_scene.rs` example for iOS
`ios` | [`mobile/src/lib.rs`](./mobile/src/lib.rs) | A 3d Scene with a button and playing sound

## WASM

Expand Down
54 changes: 0 additions & 54 deletions examples/android/src/lib.rs

This file was deleted.

14 changes: 0 additions & 14 deletions examples/ios/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 4 additions & 4 deletions examples/android/Cargo.toml → examples/mobile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "bevy-android-example"
name = "bevy_mobile_example"
version = "0.1.0"
edition = "2021"
description = "Example for building an Android app with Bevy"
description = "Example for building an iOS or Android app with Bevy"
publish = false
license = "MIT OR Apache-2.0"

[lib]
name = "bevy_android_example"
crate-type = ["cdylib"]
name = "bevy_mobile_example"
crate-type = ["staticlib", "cdylib"]

[dependencies]
bevy = { path = "../../" }
Expand Down
8 changes: 4 additions & 4 deletions examples/ios/Makefile → examples/mobile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ ifndef DEVICE_ID
endif

run: install
xcrun simctl launch --console $(DEVICE) com.rust.bevy-ios-example
xcrun simctl launch --console $(DEVICE) com.rust.bevy_mobile_example

boot-sim:
xcrun simctl boot $(DEVICE) || true

install: xcodebuild-simulator boot-sim
xcrun simctl install $(DEVICE) build/Build/Products/Debug-iphonesimulator/bevy_ios_example.app
xcrun simctl install $(DEVICE) build/Build/Products/Debug-iphonesimulator/bevy_mobile_example.app

xcodebuild-simulator:
IOS_TARGETS=x86_64-apple-ios xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -destination "id=$(DEVICE)"
IOS_TARGETS=x86_64-apple-ios xcodebuild -scheme bevy_mobile_example -configuration Debug -derivedDataPath build -destination "id=$(DEVICE)"

xcodebuild-iphone:
IOS_TARGETS=aarch64-apple-ios xcodebuild -scheme bevy_ios_example -configuration Debug -derivedDataPath build -arch arm64
IOS_TARGETS=aarch64-apple-ios xcodebuild -scheme bevy_mobile_example -configuration Debug -derivedDataPath build -arch arm64

clean:
rm -r build
Expand Down
Loading

0 comments on commit bbd0d32

Please sign in to comment.