-
Notifications
You must be signed in to change notification settings - Fork 1
221 lines (184 loc) · 6.87 KB
/
cargo-build.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
name: Cargo build
on:
push:
branches: [ "master", "reduce-dependencies" ]
pull_request:
branches: [ "master" ]
jobs:
validate:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- name: Get current Rust version
id: get-rust-version
run: echo VERSION=$(rustc --version | sed s/\ /_/g) >> "$GITHUB_OUTPUT"
- name: Cache Rust dependencies and artifacts
id: cache-rust
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
${{ github.workspace }}/target
key: lint-${{ runner.os }}-${{ steps.get-rust-version.outputs.VERSION }}-${{ hashFiles('Cargo.lock') }}
- name: Install glslang
run: sudo apt install glslang-tools
- name: Build SPIR-V shaders with glslang
run: (cd src/correlation/shaders && ./compile-spirv.sh)
- name: Validate Rust code with clippy
run: cargo clippy
- name: Upload SPIR-V shaders
uses: actions/upload-artifact@v4
with:
name: shaders-spv
path: src/correlation/shaders/*.spv
build-linux:
# Older Ubuntu versions will link with an older GLIBC and provide better compatibility
runs-on: ubuntu-20.04
needs: validate
strategy:
fail-fast: true
matrix:
include:
- arch: x86_64
os: ubuntu
- arch: aarch64
os: ubuntu
steps:
- uses: actions/checkout@v4
- name: Get current Rust version
id: get-rust-version
run: echo VERSION=$(rustc --version | sed s/\ /_/g) >> "$GITHUB_OUTPUT"
- name: Cache Rust dependencies and artifacts
id: cache-rust
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
${{ github.workspace }}/target
key: rust-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-${{ steps.get-rust-version.outputs.VERSION }}-${{ hashFiles('Cargo.lock') }}
- name: Install compiler and prepare for cross-compilation
if: matrix.arch == 'aarch64'
run: |
rustup target add ${{ matrix.arch }}-unknown-linux-gnu
sudo apt-get update
sudo apt-get install -y crossbuild-essential-arm64 qemu-user-static
echo "LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CC=/usr/bin/aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CXX=/usr/bin/aarch64-linux-gnu-g++" >> $GITHUB_ENV
echo "CFLAGS=-march=armv8.2-a" >> $GITHUB_ENV
echo "CXXFLAGS=-march=armv8.2-a" >> $GITHUB_ENV
- name: Download SPIR-V shaders
uses: actions/download-artifact@v4
with:
name: shaders-spv
- name: Build
run: cargo build --target=${{ matrix.arch }}-unknown-linux-gnu --release
- name: Package application
run: tar -cvjf cybervision-${{ matrix.os }}-${{ matrix.arch }}.tar.bz2 -C target/${{ matrix.arch }}-unknown-linux-gnu/release cybervision
- name: Upload application
uses: actions/upload-artifact@v4
with:
name: cybervision-${{ matrix.os }}-${{ matrix.arch }}
path: cybervision-*.tar.bz2
build-windows:
runs-on: windows-latest
needs: validate
strategy:
fail-fast: true
matrix:
arch: [aarch64, x86_64]
steps:
- uses: actions/checkout@v4
- name: Get current Rust version
id: get-rust-version
run: |
$version = rustc --version | % {$_.replace(" ","_")}
echo "VERSION=$version" >> "$env:GITHUB_OUTPUT"
- name: Cache Rust dependencies and artifacts
id: cache-rust
uses: actions/cache@v4
with:
path: |
~\.cargo\registry\index
~\.cargo\registry\cache
~\.cargo\git\db
${{ github.workspace }}\target
key: rust-${{ runner.os }}-${{ matrix.arch }}-${{ steps.get-rust-version.outputs.VERSION }}-${{ hashFiles('Cargo.lock') }}
- name: Install compiler and prepare for cross-compilation
if: matrix.arch == 'aarch64'
run: rustup target add ${{ matrix.arch }}-pc-windows-msvc
- name: Download SPIR-V shaders
uses: actions/download-artifact@v4
with:
name: shaders-spv
- name: Build
run: |
$Env:RUSTFLAGS = "-C target-feature=+crt-static"
cargo build --target=${{ matrix.arch }}-pc-windows-msvc --release
- name: Package application
run: Compress-Archive -Path .\target\${{ matrix.arch }}-pc-windows-msvc\release\cybervision.exe -DestinationPath cybervision-${{ runner.os }}-${{ matrix.arch }}.zip
- name: Upload application
uses: actions/upload-artifact@v4
with:
name: cybervision-${{ runner.os }}-${{ matrix.arch }}
path: cybervision-*.zip
build-macos:
runs-on: macos-latest
if: false
strategy:
fail-fast: true
matrix:
arch: [aarch64, x86_64]
steps:
- uses: actions/checkout@v4
- name: Get current Rust version
id: get-rust-version
run: echo VERSION=$(rustc --version | sed s/\ /_/g) >> "$GITHUB_OUTPUT"
- name: Cache Rust dependencies and artifacts
id: cache-rust
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
${{ github.workspace }}/target
key: rust-${{ runner.os }}-${{ matrix.arch }}-${{ steps.get-rust-version.outputs.VERSION }}-${{ hashFiles('Cargo.lock') }}
- name: Install compiler and prepare for cross-compilation
if: matrix.arch == 'aarch64'
run: rustup target add ${{ matrix.arch }}-apple-darwin
- name: Compile shaders
run: |
xcrun -sdk macosx metal -c src/correlation/correlation.metal -o src/correlation/correlation.air
xcrun -sdk macosx metallib src/correlation/correlation.air -o src/correlation/correlation.metallib
- name: Build
run: cargo build --target=${{ matrix.arch }}-apple-darwin --release
- name: Package application
run: tar -cvjf cybervision-${{ runner.os }}-${{ matrix.arch }}.tar.bz2 -C target/${{ matrix.arch }}-apple-darwin/release cybervision
- name: Upload metallib shaders
if: matrix.arch == 'aarch64'
uses: actions/upload-artifact@v4
with:
name: shaders-metallib
path: src/correlation/correlation.metallib
- name: Upload application
uses: actions/upload-artifact@v4
with:
name: cybervision-${{ runner.os }}-${{ matrix.arch }}
path: cybervision-*.tar.bz2
package:
runs-on: ubuntu-latest
needs: [ "build-linux", "build-windows", "build-macos" ]
steps:
- name: Merge all applications
uses: actions/upload-artifact/merge@v4
with:
name: cybervision-all
pattern: cybervision-*