-
Notifications
You must be signed in to change notification settings - Fork 45
286 lines (252 loc) · 11.6 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
name: CI
on:
push:
paths:
- '*.c'
- '*.cpp'
- 'Makefile'
- '.github/workflows/*'
pull_request:
paths:
- '*.c'
- '*.cpp'
- 'Makefile'
- '.github/workflows/*'
workflow_dispatch:
release:
types:
- created
env:
LIBPLIST_VERSION: 2.2.0
OPENSSL_VERSION: 3.0.5
SCCACHE_VERSION: 0.3.0
TRE_COMMIT: b4dcf71e274aa2ad6a4d879d366eb20826adfecc
MMAN_COMMIT: 2d1c576e62b99e85d99407e1a88794c6e44c3310
jobs:
build-linux:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
triple:
- aarch64-linux-musl
- x86_64-linux-musl
- x86_64-w64-mingw32
env:
TOOLCHAIN: ${{ matrix.triple }}-cross
TRIPLE: ${{ matrix.triple }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore or cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/sccache
~/dep_src
key: build-linux-${{ matrix.triple }}-${{ github.sha }}
restore-keys: |
build-linux-${{ matrix.triple }}-
- name: Setup environment
run: |
export DOWNLOAD_PATH=${HOME}/dep_src
export DEP_PATH=${HOME}/build
mkdir -p ${DOWNLOAD_PATH} ${DEP_PATH}
echo "DOWNLOAD_PATH=${DOWNLOAD_PATH}" >> $GITHUB_ENV
echo "DEP_PATH=${DEP_PATH}" >> $GITHUB_ENV
echo "ARCH=$(echo ${{ matrix.triple }} | cut -d- -f 1)" >> $GITHUB_ENV
echo "OS=$(echo ${{ matrix.triple }} | cut -d- -f 2)" >> $GITHUB_ENV
if [ "$(echo ${{ matrix.triple }} | cut -d- -f 2)" = "w64" ]; then
echo "EXT=.exe" >> $GITHUB_ENV
else
echo "EXT=" >> $GITHUB_ENV
fi
- name: Setup toolchain
run: |
wget -nc -P ${DOWNLOAD_PATH} https://cameronkatri.com/toolchains/${TOOLCHAIN}.tgz
wget -nc -P ${DOWNLOAD_PATH} https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz
tar xf ${DOWNLOAD_PATH}/${TOOLCHAIN}.tgz -C ${HOME}
tar xf ${DOWNLOAD_PATH}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz -C ${HOME}
mv ${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache ${HOME}/${TOOLCHAIN}/bin
chmod +x ${HOME}/${TOOLCHAIN}/bin/sccache
echo "${HOME}/${TOOLCHAIN}/bin" >> $GITHUB_PATH
echo "CC=sccache ${TRIPLE}-gcc" >> $GITHUB_ENV
echo "CXX=sccache ${TRIPLE}-g++" >> $GITHUB_ENV
echo "AR=${TRIPLE}-gcc-ar" >> $GITHUB_ENV
echo "NM=${TRIPLE}-gcc-nm" >> $GITHUB_ENV
echo "RANLIB=${TRIPLE}-gcc-ranlib" >> $GITHUB_ENV
if [ "${OS}" = "w64" ]; then
echo "CFLAGS=-Os -fPIC -fno-pie -no-pie -static -ffunction-sections -fdata-sections" >> $GITHUB_ENV
echo "CXXFLAGS=-Os -fPIC -fno-pie -no-pie -static -ffunction-sections -fdata-sections" >> $GITHUB_ENV
echo "LDFLAGS=-Os -fPIC -fno-pie -no-pie -static -Wl,--gc-sections -Wl,-strip-all -ffunction-sections -fdata-sections" >> $GITHUB_ENV
else
echo "CFLAGS=-Os -fPIC -fno-pie -no-pie -static -ffunction-sections -flto -fdata-sections" >> $GITHUB_ENV
echo "CXXFLAGS=-Os -fPIC -fno-pie -no-pie -static -ffunction-sections -flto -fdata-sections" >> $GITHUB_ENV
echo "LDFLAGS=-Os -fPIC -fno-pie -no-pie -static -Wl,--gc-sections -Wl,-strip-all -flto -ffunction-sections -fdata-sections" >> $GITHUB_ENV
fi
- name: Build libplist
run: |
wget -nc -P ${DOWNLOAD_PATH} https://github.com/libimobiledevice/libplist/releases/download/${LIBPLIST_VERSION}/libplist-${LIBPLIST_VERSION}.tar.bz2
tar xf ${DOWNLOAD_PATH}/libplist-${LIBPLIST_VERSION}.tar.bz2 -C ${DEP_PATH}
cd ${DEP_PATH}/libplist-${LIBPLIST_VERSION}
./configure --host=${TRIPLE} --prefix=/usr --without-cython --enable-static --disable-shared
make -j$(nproc)
echo "LIBPLIST_INCLUDES=-I${DEP_PATH}/libplist-${LIBPLIST_VERSION}/include" >> $GITHUB_ENV
echo "LIBPLIST_LIBS=${DEP_PATH}/libplist-${LIBPLIST_VERSION}/src/.libs/libplist-2.0.a" >> $GITHUB_ENV
- name: Build OpenSSL
run: |
if [ "${OS}" = "w64" ]; then
export PLATFORM="mingw64"
else
export PLATFORM="linux-${ARCH}"
fi
wget -nc -P ${DOWNLOAD_PATH} https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
tar xf ${DOWNLOAD_PATH}/openssl-${OPENSSL_VERSION}.tar.gz -C ${DEP_PATH}
cd ${DEP_PATH}/openssl-${OPENSSL_VERSION}
./config -static enable-fips enable-capieng no-module enable-ktls no-zlib \
no-async no-comp no-idea no-mdc2 no-rc5 no-ec2m no-sm2 no-sm4 no-ssl3 no-seed no-weak-ssl-ciphers ${PLATFORM}
make -j$(nproc) build_generated libcrypto.a
echo "LIBCRYPTO_INCLUDES=-I${DEP_PATH}/openssl-${OPENSSL_VERSION}/include" >> $GITHUB_ENV
if [ "${OS}" = "w64" ]; then
echo "LIBCRYPTO_LIBS=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a -lws2_32 -lgdi32 -ladvapi32 -lcrypt32 -luser32" >> $GITHUB_ENV
else
echo "LIBCRYPTO_LIBS=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a" >> $GITHUB_ENV
fi
- name: Build mman-win32
if: ${{ env.OS == 'w64' }}
run: |
wget -nc -O ${DOWNLOAD_PATH}/mman-win32-${MMAN_COMMIT}.tar.gz https://github.com/alitrack/mman-win32/archive/${MMAN_COMMIT}.tar.gz || true
tar xf ${DOWNLOAD_PATH}/mman-win32-${MMAN_COMMIT}.tar.gz -C ${DEP_PATH}
cd ${DEP_PATH}/mman-win32-${MMAN_COMMIT}
./configure --prefix=/ --disable-shared --enable-static --cross-prefix="${TRIPLE}-"
make -j$(nproc)
mkdir -p include/sys/
ln -s ../../mman.h include/sys/
echo "CXXFLAGS=${CXXFLAGS} -I${DEP_PATH}/mman-win32-${MMAN_COMMIT}/include" >> $GITHUB_ENV
echo "LIBS=${LIBS} ${DEP_PATH}/mman-win32-${MMAN_COMMIT}/libmman.a" >> $GITHUB_ENV
- name: Build tre
if: ${{ env.OS == 'w64' }}
run: |
sudo apt-get install -y autopoint
wget -nc -O ${DOWNLOAD_PATH}/tre-${TRE_COMMIT}.tar.gz https://github.com/laurikari/tre/archive/${TRE_COMMIT}.tar.gz || true
tar xf ${DOWNLOAD_PATH}/tre-${TRE_COMMIT}.tar.gz -C ${DEP_PATH}
cd ${DEP_PATH}/tre-${TRE_COMMIT}
./utils/autogen.sh
./configure --host=${TRIPLE} --prefix=/usr --without-cython --enable-static --disable-shared
make -j$(nproc)
echo "CXXFLAGS=${CXXFLAGS} -I${DEP_PATH}/tre-${TRE_COMMIT}/include/tre" >> $GITHUB_ENV
echo "LIBS=${LIBS} ${DEP_PATH}/tre-${TRE_COMMIT}/lib/.libs/libtre.a" >> $GITHUB_ENV
- name: Build
run: |
make -j$(nproc) \
CXXFLAGS="-Wextra ${CXXFLAGS}" \
LDFLAGS="-static -static-libstdc++ ${LDFLAGS}" \
EXT="${EXT}"
${TRIPLE}-strip ldid${EXT}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ldid_${{ env.OS }}_${{ env.ARCH }}
path: ldid${{ env.EXT }}
- name: Upload release asset
uses: softprops/action-gh-release@v1
if: ${{ github.event_name == 'release' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ldid${{ env.EXT }}
build-macos:
name: Build
runs-on: macos-11
strategy:
matrix:
include:
- arch: x86_64
os: macosx
- arch: arm64
os: macosx
- arch: arm64
os: iphoneos
env:
ARCH: ${{ matrix.arch }}
OS: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore or cache dependencies
uses: actions/cache@v3
with:
path: |
~/Library/Caches/Mozilla.sccache
~/dep_src
key: build-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }}
restore-keys: |
build-${{ matrix.os }}-${{ matrix.arch }}-
- name: Setup environment
run: |
export DOWNLOAD_PATH=${HOME}/dep_src
export DEP_PATH=${HOME}/build
mkdir -p ${DOWNLOAD_PATH} ${DEP_PATH}
echo "DOWNLOAD_PATH=${DOWNLOAD_PATH}" >> $GITHUB_ENV
echo "DEP_PATH=${DEP_PATH}" >> $GITHUB_ENV
if [ "${ARCH}" = "arm64" ]; then
echo "HOST_ARCH=aarch64" >> $GITHUB_ENV
else
echo "HOST_ARCH=${ARCH}" >> $GITHUB_ENV
fi
echo "SDK=$(xcrun -sdk ${OS} --show-sdk-path)" >> $GITHUB_ENV
- name: Setup toolchain
run: |
brew install libtool autoconf automake
wget -nc -P ${DOWNLOAD_PATH} https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz
tar xf ${DOWNLOAD_PATH}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz -C ${HOME}
chmod +x ${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin/sccache
echo "${HOME}/sccache-v${SCCACHE_VERSION}-x86_64-apple-darwin" >> $GITHUB_PATH
CC="sccache clang -arch ${ARCH} -isysroot ${SDK}"
CXX="sccache clang++ -arch ${ARCH} -isysroot ${SDK}"
if [ "${OS}" = "macosx" ]; then
echo "CC=${CC} -mmacosx-version-min=10.13" >> $GITHUB_ENV
echo "CXX=${CXX} -mmacosx-version-min=10.13" >> $GITHUB_ENV
else
echo "CC=${CC} -miphoneos-version-min=10.0" >> $GITHUB_ENV
echo "CXX=${CXX} -miphoneos-version-min=10.0" >> $GITHUB_ENV
fi
echo "CXXFLAGS=-Os" >> $GITHUB_ENV
echo "CFLAGS=-Os" >> $GITHUB_ENV
- name: Build libplist
run: |
wget -nc -P ${DOWNLOAD_PATH} https://github.com/libimobiledevice/libplist/releases/download/${LIBPLIST_VERSION}/libplist-${LIBPLIST_VERSION}.tar.bz2
tar xf ${DOWNLOAD_PATH}/libplist-${LIBPLIST_VERSION}.tar.bz2 -C ${DEP_PATH}
cd ${DEP_PATH}/libplist-${LIBPLIST_VERSION}
./configure --host=${HOST_ARCH}-apple-darwin --without-cython --enable-static --disable-shared
make -j$(sysctl -n hw.ncpu)
echo "LIBPLIST_INCLUDES=-I${DEP_PATH}/libplist-${LIBPLIST_VERSION}/include" >> $GITHUB_ENV
echo "LIBPLIST_LIBS=${DEP_PATH}/libplist-${LIBPLIST_VERSION}/src/.libs/libplist-2.0.a" >> $GITHUB_ENV
- name: Build OpenSSL
run: |
wget -nc -P ${DOWNLOAD_PATH} https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
tar xf ${DOWNLOAD_PATH}/openssl-${OPENSSL_VERSION}.tar.gz -C ${DEP_PATH}
cd ${DEP_PATH}/openssl-${OPENSSL_VERSION}
./config -static enable-fips enable-capieng no-module enable-ktls no-zlib \
no-async no-comp no-idea no-mdc2 no-rc5 no-ec2m no-sm2 no-sm4 no-ssl3 no-seed no-weak-ssl-ciphers darwin64-${ARCH}-cc
make -j$(sysctl -n hw.ncpu) build_generated libcrypto.a
echo "LIBCRYPTO_INCLUDES=${CXXFLAGS} -I${DEP_PATH}/openssl-${OPENSSL_VERSION}/include" >> $GITHUB_ENV
echo "LIBCRYPTO_LIBS=${DEP_PATH}/openssl-${OPENSSL_VERSION}/libcrypto.a" >> $GITHUB_ENV
- name: Build
run: |
make -j$(sysctl -n hw.ncpu) \
CXXFLAGS="-flto=thin -Wextra ${CXXFLAGS}" \
LDFLAGS="-flto=thin"
strip ldid
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ldid_${{ matrix.os }}_${{ matrix.arch }}
path: ldid
- name: Upload release asset
uses: softprops/action-gh-release@v1
if: ${{ github.event_name == 'release' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ldid