-
Notifications
You must be signed in to change notification settings - Fork 106
243 lines (232 loc) · 7.82 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# This is the main CI workflow to test that the package can be build on various platforms
name: CI
on:
push:
branches: ["*"]
pull_request:
branches-ignore: []
env:
CARGO_INCREMENTAL: false
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
CACHE_SUFFIX: a
WGPU_ANDROID_NDK_VERSION: r27b # 27.1.12297006
jobs:
# A build that does some "meta" checks on the code integrity where the Rust compiler can't.
integrity-build:
name: Code integrity checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v4
- run: python checks.py
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
components: rustfmt
- name: Run rustfmt
run: |
cargo fmt -- --check
clippy:
name: Clippy ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
# Linux
- name: Linux x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
# Macos
- name: Macos x86_64
os: macos-14
target: x86_64-apple-darwin
- name: Macos aarch64
os: macos-14
target: aarch64-apple-darwin
# Windows
- name: Windows gnu x86_64
os: windows-latest
target: x86_64-pc-windows-gnu
- name: Windows msvc x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
- name: Windows gnu i686
os: windows-latest
target: i686-pc-windows-gnu
- name: Windows msvc i686
os: windows-latest
target: i686-pc-windows-msvc
# Android
- name: Android aarch64
os: ubuntu-latest
target: aarch64-linux-android
setup_env: |
set -x
ANDROID_NDK_HOME=$HOME/wgpu-deps/ndk/android-ndk-$WGPU_ANDROID_NDK_VERSION
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CC++" >> $GITHUB_ENV
echo "CLANG_PATH=$CC" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CC" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV
- name: Android armv7
os: ubuntu-latest
target: armv7-linux-androideabi
setup_env: |
set -x
ANDROID_NDK_HOME=$HOME/wgpu-deps/ndk/android-ndk-$WGPU_ANDROID_NDK_VERSION
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang
echo "CC=$CC" >> $GITHUB_ENV
echo "CXX=$CC++" >> $GITHUB_ENV
echo "CLANG_PATH=$CC" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$CC" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-config" >> $GITHUB_ENV
echo "BINDGEN_EXTRA_CLANG_ARGS='-isysroot $ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot'" >> $GITHUB_ENV
# iOS
- name: iOS stable
os: macos-14
target: aarch64-apple-ios
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
components: clippy
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: clippy-${{ matrix.target }}-${{ env.CACHE_SUFFIX }}
- if: contains(matrix.target, 'android')
name: Setup Android NDK
run: |
mkdir -p $HOME/wgpu-deps/ndk
cd $HOME/wgpu-deps/ndk
curl -LO https://dl.google.com/android/repository/android-ndk-$WGPU_ANDROID_NDK_VERSION-linux.zip
unzip android-ndk-$WGPU_ANDROID_NDK_VERSION-linux.zip
rm android-ndk-$WGPU_ANDROID_NDK_VERSION-linux.zip
- name: Setup Environment
run: ${{ matrix.setup_env }}
- name: Run clippy
run: cargo clippy
shell: bash
examples:
name: Examples ${{ matrix.name }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.shell }}
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
shell: bash
setup_env: |
set -x;
sudo apt update -y
sudo apt install -y \
cmake ninja-build clang \
xorg-dev libwayland-dev libxkbcommon-dev wayland-protocols \
libegl1-mesa-dev mesa-vulkan-drivers
- name: Macos
os: macos-14
target: aarch64-apple-darwin
shell: bash
setup_env: brew install cmake ninja
- name: Windows gnu
os: windows-latest
target: x86_64-pc-windows-gnu
shell: msys2 {0}
- name: Windows msvc
os: windows-latest
target: x86_64-pc-windows-msvc
shell: cmd
setup_env: choco install -y make
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- if: contains(matrix.target, 'windows-msvc')
name: Setup msvc
uses: ilammy/msvc-dev-cmd@v1
- if: contains(matrix.target, 'windows-gnu')
name: Setup msys2
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >-
make
git
pacboy: >-
toolchain:p
cmake:p
ninja:p
rust:p
- if: "!contains(matrix.target, 'windows-gnu')"
name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Setup caching
uses: Swatinem/rust-cache@v2
with:
key: examples-${{ matrix.target }}-${{ env.CACHE_SUFFIX }}
- name: Setup Environment
run: ${{ matrix.setup_env }}
- name: Run tests
run: cargo test
- name: Build examples debug
run: |
make example-capture
make example-compute
make example-triangle
make example-enumerate_adapters
make example-texture_arrays
make example-push_constants
- name: Run examples debug
run: |
make run-example-capture
make run-example-compute
make run-example-enumerate_adapters
make run-example-push_constants
- name: Build examples release
run: |
make example-capture-release
make example-compute-release
make example-triangle-release
make example-enumerate_adapters-release
make example-texture_arrays-release
make example-push_constants-release
- name: Run examples release
run: |
make run-example-capture-release
make run-example-compute-release
make run-example-enumerate_adapters-release
make run-example-push_constants-release