forked from wheremyfoodat/Panda3DS
-
Notifications
You must be signed in to change notification settings - Fork 0
179 lines (150 loc) · 6.38 KB
/
Android_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
name: Android Build
on:
push:
branches:
- master
pull_request:
jobs:
x64:
runs-on: ubuntu-24.04
strategy:
matrix:
build_type:
- release
steps:
- uses: actions/checkout@v4
- name: Fetch submodules
run: |
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
git submodule update --init --recursive
fi
- name: Set BUILD_TYPE variable
run: |
echo "BUILD_TYPE=${{ matrix.build_type }}" >> $GITHUB_ENV
git diff --exit-code --quiet -- '*.cpp' '*.h' '*.hpp' || echo "CODE_CHANGED=true" >> $GITHUB_ENV
git diff --exit-code --quiet -- submodule || echo "CODE_CHANGED=true" >> $GITHUB_ENV
- name: Set up gradle caches
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/src/pandroid/app/src/main/jniLibs/x86_64
key: ${{ runner.os }}-pandroid-x86_64-${{ github.sha }}
restore-keys: |
${{ runner.os }}-pandroid-x86_64-
- name: Setup Vulkan SDK
if: ${{ env.CODE_CHANGED == 'true' }}
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-use-cache: true
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Tools, Glslang
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Configure CMake
run: |
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
echo "Code changed, rebuilding from scratch..."
cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=x86_64 -DENABLE_VULKAN=0 -DENABLE_USER_BUILD=ON
fi
- name: Build
run: |
# Skip using the cache if code has changed
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
rm -f ./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so
fi
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/x86_64/libAlber.so" ]; then
# Apply patch for GLES compatibility
git apply ./.github/gles.patch
# Build the project with CMake
cmake --build ${{github.workspace}}/build --config ${{ env.BUILD_TYPE }}
# Strip the generated library and move it to the appropriate location
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-unneeded ./build/libAlber.so
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/x86_64/
fi
# Build the Android app with Gradle
cd src/pandroid
./gradlew assemble${{ env.BUILD_TYPE }}
cd ../..
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Android APKs (x86-64)
path: |
./src/pandroid/app/build/outputs/apk/${{ env.BUILD_TYPE }}/app-${{ env.BUILD_TYPE }}.apk
arm64:
runs-on: ubuntu-latest
strategy:
matrix:
build_type:
- release
steps:
- uses: actions/checkout@v4
- name: Fetch submodules
run: |
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so" ]; then
git submodule update --init --recursive
fi
- name: Set BUILD_TYPE variable
run: |
echo "BUILD_TYPE=${{ matrix.build_type }}" >> $GITHUB_ENV
git diff --exit-code --quiet -- '*.cpp' '*.h' '*.hpp' || echo "CODE_CHANGED=true" >> $GITHUB_ENV
git diff --exit-code --quiet -- submodule || echo "CODE_CHANGED=true" >> $GITHUB_ENV
- name: Set up gradle caches
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/src/pandroid/app/src/main/jniLibs/arm64-v8a
key: ${{ runner.os }}-pandroid-arm64-${{ github.sha }}
restore-keys: |
${{ runner.os }}-pandroid-arm64-
- name: Setup Vulkan SDK
if: ${{ env.CODE_CHANGED == 'true' }}
uses: humbletim/[email protected]
with:
vulkan-query-version: latest
vulkan-use-cache: true
vulkan-components: Vulkan-Headers, Vulkan-Loader, SPIRV-Tools, Glslang
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
- name: Configure CMake
run: |
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so" ]; then
echo "Code changed, rebuilding from scratch..."
cmake -B ${{github.workspace}}/build -DBUILD_HYDRA_CORE=1 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DENABLE_VULKAN=0 -DENABLE_USER_BUILD=ON -DCMAKE_CXX_FLAGS="-march=armv8-a+crypto"
fi
- name: Build
run: |
# Skip using the cache if code has changed
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so" ]; then
rm -f ./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so
fi
if [[ "$CODE_CHANGED" == "true" ]] || [ ! -f "./src/pandroid/app/src/main/jniLibs/arm64-v8a/libAlber.so" ]; then
# Apply patch for GLES compatibility
git apply ./.github/gles.patch
# Build the project with CMake
cmake --build ${{github.workspace}}/build --config ${{ env.BUILD_TYPE }}
# Strip the generated library and move it to the appropriate location
${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip --strip-unneeded ./build/libAlber.so
mv ./build/libAlber.so ./src/pandroid/app/src/main/jniLibs/arm64-v8a/
fi
# Build the Android app with Gradle
cd src/pandroid
./gradlew assemble${{ env.BUILD_TYPE }}
ls -R app/build/outputs
cd ../..
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Android APKs (arm64)
path: |
./src/pandroid/app/build/outputs/apk/${{ env.BUILD_TYPE }}/app-${{ env.BUILD_TYPE }}.apk