Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use xbuild instead of cargo apk in the CI #3086

Closed
wants to merge 13 commits into from
60 changes: 31 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ jobs:
- { name: 'Linux 64bit', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, }
- { name: 'X11', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: '--no-default-features --features=x11' }
- { name: 'Wayland', target: x86_64-unknown-linux-gnu, os: ubuntu-latest, options: '--no-default-features --features=wayland,wayland-dlopen' }
- { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
- { name: 'Redox OS', target: x86_64-unknown-redox, os: ubuntu-latest, }
- { name: 'macOS', target: x86_64-apple-darwin, os: macos-latest, }
- { name: 'iOS x86_64', target: x86_64-apple-ios, os: macos-latest, }
- { name: 'iOS Aarch64', target: aarch64-apple-ios, os: macos-latest, }
- { name: 'web', target: wasm32-unknown-unknown, os: ubuntu-latest, }
exclude:
# Android is tested on stable-3
- toolchain: '1.65.0'
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
include:
# Android is tested on stable-3
- toolchain: '1.69.0'
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity', cmd: 'apk --' }
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity' }
- toolchain: 'stable'
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity' }
- toolchain: 'nightly'
platform: { name: 'Android', target: aarch64-linux-android, os: ubuntu-latest, options: '--package=winit --features=android-native-activity' }


env:
# Set more verbose terminal output
notgull marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -59,7 +60,6 @@ jobs:
RUSTDOCFLAGS: '--deny=warnings'

OPTIONS: --target=${{ matrix.platform.target }} ${{ matrix.platform.options }}
CMD: ${{ matrix.platform.cmd }}

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -87,41 +87,42 @@ jobs:
if: (matrix.platform.os == 'ubuntu-latest') && contains(matrix.platform.target, 'i686')
run: sudo apt-get update && sudo apt-get install gcc-multilib

- name: Cache cargo-apk
if: contains(matrix.platform.target, 'android')
id: cargo-apk-cache
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-apk
# Change this key if we update the required cargo-apk version
key: cargo-apk-v0-9-7

- uses: dtolnay/rust-toolchain@master
if: contains(matrix.platform.target, 'android') && (steps.cargo-apk-cache.outputs.cache-hit != 'true')
- name: Install xbuild
uses: taiki-e/install-action@v2
if: contains(matrix.platform.target, 'android') || contains(matrix.platform.target, 'ios')
notgull marked this conversation as resolved.
Show resolved Hide resolved
with:
toolchain: stable

- name: Install cargo-apk
if: contains(matrix.platform.target, 'android') && (steps.cargo-apk-cache.outputs.cache-hit != 'true')
run: cargo install cargo-apk --version=^0.9.7 --locked
tool: [email protected]

- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}${{ matrix.platform.host }}
targets: ${{ matrix.platform.target }}
components: clippy

- name: Install LLVM tools for Android
if: contains(matrix.platform.target, 'android')
run: sudo apt-get update && sudo apt-get install lld llvm

- name: Check documentation
run: cargo doc --no-deps $OPTIONS --document-private-items

- name: Build crate
run: cargo $CMD build $OPTIONS
- name: Build crate
run: cargo build $OPTIONS

- name: Build and package crate for Android
if: contains(matrix.platform.target, 'android')
run: x build -p android-xbuild-target --platform android --arch arm64

- name: Build and package crate for iOS
if: contains(matrix.platform.target, 'ios')
run: x build -p ios-xbuild-target --platform ios --arch arm64

- name: Build tests
if: >
!contains(matrix.platform.target, 'redox') &&
!contains(matrix.platform.target, 'android') &&
matrix.toolchain != '1.65.0'
run: cargo $CMD test --no-run $OPTIONS
run: cargo test --no-run $OPTIONS

- name: Run tests
if: >
Expand All @@ -130,7 +131,7 @@ jobs:
!contains(matrix.platform.target, 'wasm32') &&
!contains(matrix.platform.target, 'redox') &&
matrix.toolchain != '1.65.0'
run: cargo $CMD test $OPTIONS
run: cargo test $OPTIONS

- name: Lint with clippy
if: (matrix.toolchain == 'stable') && !contains(matrix.platform.options, '--no-default-features')
Expand All @@ -139,8 +140,9 @@ jobs:
- name: Build tests with serde enabled
if: >
!contains(matrix.platform.target, 'redox') &&
!contains(matrix.platform.target, 'android') &&
matrix.toolchain != '1.65.0'
run: cargo $CMD test --no-run $OPTIONS --features serde
run: cargo test --no-run $OPTIONS --features serde

- name: Run tests with serde enabled
if: >
Expand All @@ -149,7 +151,7 @@ jobs:
!contains(matrix.platform.target, 'wasm32') &&
!contains(matrix.platform.target, 'redox') &&
matrix.toolchain != '1.65.0'
run: cargo $CMD test $OPTIONS --features serde
run: cargo test $OPTIONS --features serde

# See restore step above
- name: Save cache of cargo folder
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,7 @@ web-sys = { version = "0.3.22", features = ['CanvasRenderingContext2d'] }

[workspace]
members = [
"xbuild/android-target",
"xbuild/ios-target",
"run-wasm",
]
3 changes: 3 additions & 0 deletions xbuild/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# xbuild-target

These are crates that can be built via `x build` in order to simplify CI testing.
13 changes: 13 additions & 0 deletions xbuild/android-target/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "android-xbuild-target"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
crate_type = ["cdylib"]

[dependencies.winit]
version = "0.29.1-beta"
path = "../.."
features = ["android-native-activity"]
11 changes: 11 additions & 0 deletions xbuild/android-target/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use winit::platform::android::{activity::AndroidApp, EventLoopBuilderExtAndroid};

#[no_mangle]
fn android_main(app: AndroidApp) {
winit::event_loop::EventLoopBuilder::new()
.with_android_app(app)
.build()
.unwrap()
.run(|_, _| todo!())
.ok();
}
9 changes: 9 additions & 0 deletions xbuild/ios-target/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "ios-xbuild-target"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: given the directory structure I'd name these xbuild-ios-target. After all, xbuild is targeting an architecture, the architecture isn't targeting xbuild.

version = "0.1.0"
edition = "2021"
publish = false

[dependencies.winit]
version = "0.29.1-beta"
path = "../.."
7 changes: 7 additions & 0 deletions xbuild/ios-target/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
winit::event_loop::EventLoopBuilder::new()
.build()
.unwrap()
.run(|_, _| todo!())
.ok();
}
Loading