forked from MaaAssistantArknights/MaaDeps
-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (181 loc) · 6.26 KB
/
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
name: build
on:
push:
workflow_dispatch:
inputs:
use-cache:
type: boolean
default: true
description: Use binary cache
jobs:
build-maadeps:
strategy:
matrix:
os: [ubuntu, windows, macos]
arch: [x64, arm64]
include:
- os: ubuntu
arch: arm64-android
- os: ubuntu
arch: arm-android
- os: ubuntu
arch: arm-neon-android
# clang-17: error: unsupported argument 'i686' to option '-march='
# https://github.com/MaaAssistantArknights/MaaDeps/actions/runs/7285060481/job/19851366697
# - os: ubuntu
# arch: x64-android
fail-fast: false
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 720
steps:
- name: Windows runner hack
if: runner.os == 'Windows'
shell: cmd
run: |
dir d:\a
cd ..
mkdir C:\MaaDeps
rmdir MaaDeps
mklink /j MaaDeps C:\MaaDeps
dism /Online /Disable-Feature /FeatureName:Windows-Defender /Remove /NoRestart /Quiet
cd .
- name: Windows runner hack (2)
if: runner.os == 'Windows'
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "D:"
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Install Packages on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build python3-pyelftools elfutils patchelf nasm
- name: Install Cross-Compiler for Linux
if: runner.os == 'Linux' && matrix.arch == 'arm64'
run: |
sudo apt install crossbuild-essential-arm64
- uses: nttld/setup-ndk@v1
if: contains(matrix.arch, 'android')
id: setup-ndk
with:
ndk-version: r27
add-to-path: false
- name: Install Packages on MacOS
if: runner.os == 'macOS'
run: |
brew update
brew install ccache ninja pkg-config nasm bison
brew install bash gnu-sed gnu-tar
echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
echo "$(brew --prefix)/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
brew unlink python
brew link --overwrite python
- uses: actions/cache@v3
with:
path: |
vcpkg/downloads/
key: cache-downloads-${{ matrix.os }}-${{ matrix.arch }}-${{ hashfiles('vcpkg-overlay', 'vcpkg*.json') }}
# no symbols if installed from binary archive
# - uses: actions/cache/restore@v3
# if: github.event.inputs.use-cache
# with:
# path: |
# vcpkg/archives/
# key: cache-${{ matrix.os }}-${{ matrix.arch }}-${{ hashfiles('vcpkg-overlay') }}
# # this should work on both bash and pwsh, and giving native path on windows
# - run: |
# mkdir -p vcpkg/archives
# echo "VCPKG_DEFAULT_BINARY_CACHE=$PWD/vcpkg/archives" >> $GITHUB_ENV
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows'
id: msvc-env
with:
arch: amd64${{ matrix.arch != 'x64' && format('_{0}', matrix.arch) || '' }}
- name: Setup MSVC environment
if: matrix.os == 'windows'
run: |
echo "CC=cl" >> $GITHUB_ENV
echo "CXX=cl" >> $GITHUB_ENV
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
windows_compile_environment: msvc
# vcpkg will clean environment so that ccache is not used anyway
# - name: post-setup cache (windows)
# if: runner.os == 'Windows'
# shell: cmd
# run: |
# echo "PATH=%ccache_symlinks_path%;%PATH%" >> %GITHUB_ENV%
# - name: enable NTFS compression (windows)
# if: runner.os == 'Windows'
# shell: cmd
# run: |
# compact /c /q vcpkg
- name: Set target
run: |
lower() { printf '%s\n' "${1,,}"; }
if [[ "${{matrix.arch}}" == *"android"* ]]; then
echo "TARGET=${{ matrix.arch }}" >> $GITHUB_ENV
else
export RUNNER_OS=$(lower ${{runner.os}})
export OS=$(echo $RUNNER_OS | sed 's/macOS/osx/I')
echo "TARGET=${{ matrix.arch }}-${OS}" >> $GITHUB_ENV
fi
- name: Set OBJCOPY for arm64-linux
if: matrix.arch == 'arm64' && matrix.os == 'ubuntu'
run: |
echo "OBJCOPY=aarch64-linux-gnu-objcopy" >> $GITHUB_ENV
- name: Build MaaDeps
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
for attempt in 1 2 3
do
python3 build.py --tarball --target maa-$TARGET -- $MAA_CMAKE_ARGS && break
# delete object and archive files (of already installed packages) and retry
shopt -s globstar nullglob
df -lh
rm -f vcpkg/buildtrees/**/*.{o,obj,a,lib}
df -lh
du -sh vcpkg/buildtrees/*
[[ $attempt != 3 ]] # fail on last attempt
done
- name: Collect Logs
if: always()
run: |
shopt -s globstar
tar caf logs.tar --ignore-failed-read vcpkg/buildtrees/**/*.log
- name: Upload Logs
uses: actions/[email protected]
if: always()
with:
name: logs-${{ env.TARGET }}
path: logs.tar
- name: Upload Artifact
uses: actions/[email protected]
with:
name: tarball-${{ env.TARGET }}
path: tarball
- name: release
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
shell: bash
run: |
gh release create "$TAG_NAME" --prerelease || true # accept existing release
gh release upload "$TAG_NAME" tarball/*
# - name: cache binary archives
# uses: actions/cache/save@v3
# if: github.event.inputs.use-cache
# with:
# path: |
# vcpkg/archives/
# key: cache-${{ matrix.os }}-${{ matrix.arch }}-${{ hashfiles('vcpkg-overlay') }}