-
Notifications
You must be signed in to change notification settings - Fork 3
224 lines (196 loc) · 8.28 KB
/
cmake.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
name: Release Build CI
# Controls when the workflow will run
# Triggers the workflow on push or pull request events and manually from the Actions tab
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
workflow_dispatch:
jobs:
build:
env:
GRPC_BUILD_ENABLE_CCACHE: "ON"
GH_TOKEN: ${{ secrets.GNUS_TOKEN_1 }}
runs-on: ${{matrix.host}}
strategy:
fail-fast: false
matrix:
target: [Android, iOS, OSX, Linux, Windows]
include:
- target: Linux
host: ubuntu-latest
- target: Windows
host: windows-latest
- target: OSX
host: macos-latest
- target: Android
host: ubuntu-latest
abi: arm64-v8a
- target: iOS
host: macos-latest
steps:
- name: Checkout SuperGenius repository
uses: actions/checkout@v4
with:
path: 'SuperGenius'
submodules: "recursive"
# Determine branch name to use for thirdparty repository
- name: Set branch name for thirdparty
id: branch_check
run: |
branch_name=$(git -C SuperGenius rev-parse --abbrev-ref HEAD)
# Check if the branch exists in the thirdparty repository
if git ls-remote --heads https://github.com/GeniusVentures/thirdparty.git $branch_name | grep -q $branch_name; then
echo "branch_name=$branch_name" >> $GITHUB_ENV
else
echo "branch_name=develop" >> $GITHUB_ENV
fi
shell: bash
- name: Download thirdparty release
working-directory: ${{github.workspace}}
run: |
mkdir thirdparty
cd thirdparty
tag_name=${{matrix.target}}-${branch_name}-Release
gh release download ${tag_name} --repo GeniusVentures/thirdparty -p "*-lib.tar.gz"
for library in *-lib.tar.gz; do
tar -xzvf "$library"
done
shell: bash
- name: Set clang as the default compiler
if: ${{ matrix.host == 'ubuntu-latest' }}
run: |
sudo update-alternatives --install /usr/bin/cc cc $(which clang) 100
sudo update-alternatives --install /usr/bin/c++ c++ $(which clang++) 100
sudo update-alternatives --set cc $(which clang)
sudo update-alternatives --set c++ $(which clang++)
- name: Install Linux host dependencies
if: ${{ matrix.host == 'ubuntu-latest'}}
run: |
sudo apt install ccache ninja-build libvulkan-dev -y
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
- name: Install Windows host dependencies
if: ${{ matrix.host == 'windows-latest'}}
run: |
choco install ccache -A
- name: Install Darwin host dependencies
if: ${{ matrix.host == 'macos-latest'}}
run: |
brew install ccache ninja
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
- name: Add Darwin toolchain
if: ${{ matrix.target == 'OSX'}}
run: rustup target add x86_64-apple-darwin
- name: Add iOS toolchain
if: ${{ matrix.target == 'iOS' }}
run: |
rustup toolchain install nightly-aarch64-apple-darwin
rustup component add rust-src --toolchain nightly-aarch64-apple-darwin
rustup target add aarch64-apple-ios
- name: Add Android toolchain
if: ${{ matrix.target == 'Android' }}
run: |
rustup target add aarch64-linux-android
- name: Install bindgen
run: cargo install cbindgen
- name: Add Rust target
run: rustup target add wasm32-unknown-emscripten
- name: Configure SuperGenius CMake for Mac x86
if: ${{ matrix.target == 'OSX'}}
working-directory: ${{github.workspace}}/SuperGenius
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DPLATFORM=MAC -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty
- name: Configure SuperGenius CMake for iOS
if: ${{ matrix.target == 'iOS'}}
working-directory: ${{github.workspace}}/SuperGenius
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DPLATFORM=OS64 -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty
- name: Configure SuperGenius CMake for Android
if: ${{ matrix.target == 'Android'}}
working-directory: ${{github.workspace}}/SuperGenius
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release/${{matrix.abi}} -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=${{matrix.abi}} -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty
- name: Configure SuperGenius CMake
if: ${{ matrix.target != 'OSX' && matrix.target != 'iOS' && matrix.target != 'Android' }}
working-directory: ${{github.workspace}}/SuperGenius
run: cmake -S build/${{matrix.target}} -B build/${{matrix.target}}/Release -DCMAKE_BUILD_TYPE=Release -DTHIRDPARTY_BUILD_DIR=${{github.workspace}}/thirdparty -DTHIRDPARTY_DIR=${{github.workspace}}/thirdparty
- name: Build SuperGenius
if: ${{ matrix.target != 'Android' }}
working-directory: ${{github.workspace}}/SuperGenius
run: |
if [ '${{matrix.target}}' == 'Android' ]; then
cmake --build build/${{matrix.target}}/Release/${{matrix.abi}} --config Release -j
else
cmake --build build/${{matrix.target}}/Release --config Release -j
fi
shell: bash
- name: Install SuperGenius
working-directory: ${{github.workspace}}/SuperGenius/build/${{matrix.target}}/Release
run: |
if [ '${{matrix.target}}' == 'Android' ]; then
cd ${{matrix.abi}}
fi
cmake --install .
shell: bash
- name: Compressing Build Artifacts
working-directory: ${{github.workspace}}/SuperGenius
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
shopt -s extglob
rm -rf !(build) .[!.]* ..?*
cd build
rm -rf !(${{matrix.target}}) .[!.]* ..?*
cd ${{matrix.target}}
rm -rf !(Release) .[!.]* ..?*
cd Release
if [[ "${{matrix.target == 'Android'}}"]]; then
rm -rf !(${{matrix.abi}}) .[!.]* ..?*
cd ${{matrix.abi}}
fi
rm -rf !(SuperGenius) .[!.]* ..?*
cd $GITHUB_WORKSPACE
tar -czvf SuperGenius.tar.gz SuperGenius/
shell: bash
- name: Set Release Variables
id: vars
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
if [ '${{matrix.target}}' == 'Android' ]; then
OS_NAME=${{matrix.target}}-${{matrix.abi}}
else
OS_NAME=${{matrix.target}}
fi
BRANCH_NAME=${GITHUB_REF#refs/heads/}
BUILD_TYPE=Release
FILE_NAME="${OS_NAME}-${BRANCH_NAME}-${BUILD_TYPE}.tar.gz"
echo "RELEASE_TAG=${OS_NAME}-${BRANCH_NAME}-${BUILD_TYPE}-${GITHUB_SHA::7}" >> $GITHUB_ENV
echo "RELEASE_NAME=${OS_NAME} ${BRANCH_NAME} ${BUILD_TYPE} (${GITHUB_SHA::7})" >> $GITHUB_ENV
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
shell: bash
- name: Rename Artifact
if: ${{ github.event_name == 'workflow_dispatch' }}
run: mv SuperGenius.tar.gz ${{ env.FILE_NAME }}
shell: bash
- name: Create GitHub Release
if: ${{ github.event_name == 'workflow_dispatch' }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GNUS_TOKEN_1 }}
with:
tag_name: ${{ env.RELEASE_TAG }}
release_name: ${{ env.RELEASE_NAME }}
draft: false
prerelease: false
- name: Upload Release Asset
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GNUS_TOKEN_1 }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.FILE_NAME }}
asset_name: ${{ env.FILE_NAME }}
asset_content_type: application/gzip