forked from LuckyPray/DexKit
-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (197 loc) · 8.05 KB
/
Copy pathbuild-native.yml
File metadata and controls
229 lines (197 loc) · 8.05 KB
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
name: Build DexKit Native Libraries
env:
LINUX_CODENAME: xenial
LINUX_SYSROOT_PATH: .dexkit-sysroot/ubuntu-16.04-x86_64
LINUX_GCC10_HEADERS_PATH: .dexkit-sysroot/gcc10-headers
LINUX_SYSROOT_CACHE_KEY_PREFIX: dexkit-linux-amd64-sysroot-v1
on:
push:
branches: [ master ]
tags: [ '*' ]
pull_request:
branches: [ master ]
jobs:
build-native:
strategy:
matrix:
sys:
- { name: linux, os: ubuntu-latest, shell: bash}
- { name: windows, os: windows-latest, shell: bash}
- { name: macos, os: macos-latest, shell: bash}
defaults:
run:
shell: ${{ matrix.sys.shell }}
runs-on: ${{ matrix.sys.os }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v1
with:
version: 3.25.0
- name: Install Linux build tools
if: ${{ matrix.sys.name == 'linux' }}
run: |
sudo apt-get update
sudo apt-get install -y clang lld ninja-build binutils xz-utils
- name: Restore target Linux sysroot cache
if: ${{ matrix.sys.name == 'linux' }}
id: cache_linux_sysroot
uses: actions/cache@v4
with:
path: ${{ env.LINUX_SYSROOT_PATH }}.tar.xz
key: ${{ env.LINUX_SYSROOT_CACHE_KEY_PREFIX }}-${{ env.LINUX_CODENAME }}-${{ hashFiles('build-support/linux-sysroot/**') }}
- name: Restore GCC 10 headers cache
if: ${{ matrix.sys.name == 'linux' }}
id: cache_linux_gcc10_headers
uses: actions/cache@v4
with:
path: ${{ env.LINUX_GCC10_HEADERS_PATH }}.tar.xz
key: ${{ env.LINUX_SYSROOT_CACHE_KEY_PREFIX }}-gcc10-headers-${{ hashFiles('build-support/linux-sysroot/**') }}
- name: Build missing Linux sysroot and GCC 10 headers
if: ${{ matrix.sys.name == 'linux' }}
run: |
build_sysroot() {
local codename="$1"
local path="$2"
if [ -f "$path.tar.xz" ]; then
return
fi
rm -rf "$path"
sudo env \
UBUNTU_CODENAME="$codename" \
bash build-support/linux-sysroot/build-linux-sysroot.sh "$path"
sudo tar -C "$path" \
--exclude=./dev \
--exclude=./proc \
--exclude=./sys \
--exclude=./run \
--exclude=./tmp \
--exclude=./var/tmp \
-cJf "$path.tar.xz" .
sudo chown "$(id -u):$(id -g)" "$path.tar.xz"
sudo rm -rf "$path"
sudo chown -R "$(id -u):$(id -g)" "$(dirname "$path")"
}
build_gcc10_headers() {
local path="$1"
if [ -f "$path.tar.xz" ]; then
return
fi
rm -rf "$path"
bash build-support/linux-sysroot/fetch-libstdcxx-headers.sh "$path"
tar -C "$path" -cJf "$path.tar.xz" .
rm -rf "$path"
}
build_sysroot "$LINUX_CODENAME" "$LINUX_SYSROOT_PATH"
build_gcc10_headers "$LINUX_GCC10_HEADERS_PATH"
- name: Unpack Linux sysroot and GCC 10 headers
if: ${{ matrix.sys.name == 'linux' }}
run: |
unpack_archive() {
local path="$1"
rm -rf "$path"
mkdir -p "$path"
tar -C "$path" -xJf "$path.tar.xz"
}
unpack_archive "$LINUX_SYSROOT_PATH"
unpack_archive "$LINUX_GCC10_HEADERS_PATH"
- name: Prepare Linux compatibility headers
if: ${{ matrix.sys.name == 'linux' }}
run: |
compat_dir="$GITHUB_WORKSPACE/.dexkit-sysroot/compat"
target_sysroot="$GITHUB_WORKSPACE/$LINUX_SYSROOT_PATH"
template_dir="$GITHUB_WORKSPACE/build-support/linux-sysroot"
mkdir -p "$compat_dir/gcc5-thread-wrapper"
cp "$template_dir/glibc-libstdcxx10-compat.h" "$compat_dir/glibc-libstdcxx10-compat.h"
sed "s|@TARGET_SYSROOT@|$target_sysroot|g" \
"$template_dir/gcc5-thread-wrapper/thread.in" \
> "$compat_dir/gcc5-thread-wrapper/thread"
sed "s|@TARGET_SYSROOT@|$target_sysroot|g" \
"$template_dir/gcc5-thread-wrapper/future.in" \
> "$compat_dir/gcc5-thread-wrapper/future"
- name: Run Gradle CMake build (linux)
if: ${{ matrix.sys.name == 'linux' }}
run: |
chmod +x gradlew
sysroot="$GITHUB_WORKSPACE/$LINUX_SYSROOT_PATH"
gcc10_headers="$GITHUB_WORKSPACE/$LINUX_GCC10_HEADERS_PATH/usr/include"
compat_dir="$GITHUB_WORKSPACE/.dexkit-sysroot/compat"
compat_header="$compat_dir/glibc-libstdcxx10-compat.h"
cxxflags="-fno-exceptions -nostdinc++ -isystem $compat_dir/gcc5-thread-wrapper -isystem $gcc10_headers/c++/10 -isystem $gcc10_headers/x86_64-linux-gnu/c++/10 -include $compat_header"
export CC="clang --sysroot=$sysroot --gcc-toolchain=$sysroot/usr"
export CXX="clang++ --sysroot=$sysroot --gcc-toolchain=$sysroot/usr"
export AR=llvm-ar
export RANLIB=llvm-ranlib
export LD=ld.lld
export CFLAGS=""
export CXXFLAGS="$cxxflags"
export LDFLAGS="-Wl,--no-as-needed -lpthread"
./gradlew :dexkit:cmakeBuild --console=plain
- name: Run Gradle CMake build (windows)
if: ${{ matrix.sys.name == 'windows' }}
run: |
chmod +x gradlew
./gradlew :dexkit:cmakeBuild --console=plain
- name: Run Gradle package build (macOS)
if: ${{ matrix.sys.name == 'macos' }}
run: |
chmod +x gradlew
./gradlew :dexkit:cmakeBuild :dexkit:jar :dexkit:sourcesJar :dexkit-android:assembleRelease :dexkit-android:sourcesJar --console=plain
- name: Collect build artifacts
run: |
rm -rf artifacts
if [ "${RUNNER_OS}" = "Linux" ]; then
mkdir -p artifacts/native/linux
cp dexkit/build/cmake/main/*/libdexkit.so artifacts/native/linux/
elif [ "${RUNNER_OS}" = "Windows" ]; then
mkdir -p artifacts/native/windows
cp dexkit/build/cmake/main/*/libdexkit.dll artifacts/native/windows/
elif [ "${RUNNER_OS}" = "macOS" ]; then
mkdir -p artifacts/native/macos artifacts/jvm artifacts/android
cp dexkit/build/cmake/main/*/libdexkit.dylib artifacts/native/macos/
cp dexkit/build/libs/dexkit.jar artifacts/jvm/
cp dexkit/build/libs/dexkit-sources.jar artifacts/jvm/
cp dexkit-android/build/outputs/aar/dexkit-android-release.aar artifacts/android/dexkit-android.aar
cp dexkit-android/build/libs/dexkit-android-sources.jar artifacts/android/
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dexkit-build-${{ matrix.sys.name }}
path: artifacts/
package-all:
needs: build-native
runs-on: ubuntu-latest
env:
PACKAGE_ROOT: dexkit-all-platforms
steps:
- name: Download and merge workflow artifacts
uses: actions/download-artifact@v4
with:
pattern: dexkit-build-*
path: ${{ env.PACKAGE_ROOT }}
merge-multiple: true
- name: Verify combined artifact layout
run: |
test -f $PACKAGE_ROOT/jvm/dexkit.jar
test -f $PACKAGE_ROOT/jvm/dexkit-sources.jar
test -f $PACKAGE_ROOT/android/dexkit-android.aar
test -f $PACKAGE_ROOT/android/dexkit-android-sources.jar
test -f $PACKAGE_ROOT/native/linux/libdexkit.so
test -f $PACKAGE_ROOT/native/macos/libdexkit.dylib
test -f $PACKAGE_ROOT/native/windows/libdexkit.dll
- name: Delete individual platform artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: dexkit-build-*
- name: Upload combined ZIP
uses: actions/upload-artifact@v4
with:
name: dexkit-all-platforms
path: ${{ env.PACKAGE_ROOT }}/