forked from winnerspiros/UnleashedRecomp_Android
-
Notifications
You must be signed in to change notification settings - Fork 0
188 lines (164 loc) · 6.96 KB
/
Copy pathvalidate.yml
File metadata and controls
188 lines (164 loc) · 6.96 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
name: validate
on:
workflow_call:
secrets:
ASSET_REPO:
required: false
ASSET_REPO_TOKEN:
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-android:
name: Build Android
runs-on: ubuntu-24.04
env:
CMAKE_BUILD_PARALLEL_LEVEL: 1
ASSET_REPO: ${{ secrets.ASSET_REPO }}
ASSET_REPO_TOKEN: ${{ secrets.ASSET_REPO_TOKEN }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup System
run: |
sudo apt-get update
sudo apt-get install -y patchelf p7zip-full wget file ccache libtbb-dev libcurl4-openssl-dev
- name: Setup extract-xiso
run: |
git clone https://github.com/XboxDev/extract-xiso.git
cd extract-xiso
sed -i "s|if ( ( err = mkdir( dir->filename, 0755 ) ) ) mkdir_err( dir->filename );|if ( ( err = mkdir( dir->filename, 0755 ) ) ) { if ( errno == EEXIST ) err = 0; else mkdir_err( dir->filename ); }|" extract-xiso.c
sed -i "s|if ( ( err = mkdir( iso_name, 0755 ) ) ) mkdir_err( iso_name );|if ( ( err = mkdir( iso_name, 0755 ) ) ) { if ( errno == EEXIST ) err = 0; else mkdir_err( iso_name ); }|" extract-xiso.c
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install
- name: Check Secrets
if: env.ASSET_REPO == ''
run: echo "ASSET_REPO secret is missing. Skipping Android build steps."
- name: Checkout Private Repository
if: env.ASSET_REPO != ''
uses: actions/checkout@v4
with:
repository: ${{ env.ASSET_REPO }}
token: ${{ env.ASSET_REPO_TOKEN }}
path: ./private
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Install Android NDK
run: echo y | sdkmanager "ndk;29.0.14206865"
- name: Cache vcpkg
uses: actions/cache@v4
with:
path: |
./thirdparty/vcpkg/downloads
./thirdparty/vcpkg/packages
key: vcpkg-android-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-android-
- name: Bootstrap vcpkg
run: |
./thirdparty/vcpkg/bootstrap-vcpkg.sh
- name: Apply Patches
run: |
chmod +x apply_patches.sh
./apply_patches.sh
- name: Setup Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libtbb-dev libcurl4-openssl-dev patchelf p7zip-full
- name: Run Build Tools
run: |
chmod +x ./build_tools.sh
./build_tools.sh
- name: Prepare Project
if: env.ASSET_REPO != ''
run: |
mkdir -p ./UnleashedRecompLib/private
if [ -d "./private" ]; then
cp -rv private/* ./UnleashedRecompLib/private/ 2>/dev/null || true
fi
# Recursive extraction
for i in {1..15}; do
nested=$(find ./UnleashedRecompLib/private -type f \( -iname "*.iso" -o -iname "*.7z" -o -iname "*.zip" -o -iname "*.rar" -o -iname "TU_*" -o -iname "*.tar*" -o -iregex ".*/[0-9a-fA-F]\\{8,42\\}" \) -not -name "*.skipped" -not -name "*.extracted" | head -n 1)
if [ -z "$nested" ]; then break; fi
filename=$(basename "$nested")
extension="${filename##*.}"
is_iso=0
if [[ "$extension" =~ ^(iso|ISO)$ ]]; then is_iso=1; fi
success=0
if 7z x -y "$nested" -o./UnleashedRecompLib/private/ > /dev/null 2>&1; then
success=1
elif [ "$is_iso" -eq 1 ] && (extract-xiso -x "$nested" -d ./UnleashedRecompLib/private/ || python3 tools/extract_xgd.py "$nested" ./UnleashedRecompLib/private/); then
success=1
elif [ "$is_iso" -eq 0 ] && python3 tools/extract_stfs.py "$nested" ./UnleashedRecompLib/private/; then
success=1
fi
if [ "$success" -eq 1 ]; then rm -f "$nested"; else mv "$nested" "${nested}.skipped"; fi
done
# Robust Normalization
finalize_file() {
local filename="$1"
local target_path="./UnleashedRecompLib/private/$filename"
local candidates=$(find ./UnleashedRecompLib/private -type f -iname "$filename" | { grep -vFx "$target_path" || true; })
local candidate_count=$(echo "$candidates" | grep -v "^$" | wc -l || true)
if [ "$candidate_count" -gt 0 ]; then
local found_file=""
if [ "$candidate_count" -gt 1 ]; then
found_file=$(echo "$candidates" | grep -vE "/(game|base)/" | head -n 1)
if [ -z "$found_file" ]; then found_file=$(echo "$candidates" | head -n 1); fi
else
found_file="$candidates"
fi
if [ -n "$found_file" ]; then mv -f "$found_file" "$target_path"; fi
fi
# Case fix for root files
local root_file=$(find ./UnleashedRecompLib/private -maxdepth 1 -type f -iname "$filename" | head -n 1)
if [ -n "$root_file" ] && [ "$root_file" != "$target_path" ]; then mv -f "$root_file" "$target_path"; fi
}
finalize_file "default.xex"
finalize_file "default.xexp"
finalize_file "shader.ar"
if [ -f "./UnleashedRecompLib/private/default.xex" ] && [ -f "./UnleashedRecompLib/private/shader.ar" ]; then
echo "Assets found."
else
echo "Error: Mandatory assets (default.xex, shader.ar) missing after extraction."
false
fi
# Cleanup empty directories
find ./UnleashedRecompLib/private -depth -type d -empty -delete 2>/dev/null || true
- name: Build Debug APK
if: env.ASSET_REPO != ''
working-directory: ./android
run: |
chmod +x gradlew
export ANDROID_NDK_HOME=${ANDROID_SDK_ROOT}/ndk/29.0.14206865
./gradlew assembleDebug --max-workers=1 --no-daemon
- name: Upload Debug Artifact
if: env.ASSET_REPO != ''
uses: actions/upload-artifact@v4
with:
name: UnleashedRecomp-Android-Debug
path: android/app/build/outputs/apk/debug/app-debug.apk
- name: Build Release APK
if: env.ASSET_REPO != ''
working-directory: ./android
run: |
chmod +x gradlew
export ANDROID_NDK_HOME=${ANDROID_SDK_ROOT}/ndk/29.0.14206865
./gradlew assembleRelease --max-workers=1 --no-daemon
- name: Upload Release Artifact
if: env.ASSET_REPO != ''
uses: actions/upload-artifact@v4
with:
name: UnleashedRecomp-Android-Release
path: android/app/build/outputs/apk/release/app-release.apk