-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathterribuild.ps1
More file actions
310 lines (263 loc) · 12.6 KB
/
Copy pathterribuild.ps1
File metadata and controls
310 lines (263 loc) · 12.6 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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
[Reflection.Assembly]::LoadFrom("$((Get-Location).Path)\Newtonsoft.Json.dll")
# Config
try {
. ".\config.ps1"
}
catch {
throw "Please put a config.ps1 from the provided config.ps1.sample in the repository root, and run this script from there."
}
$repoRoot = $pwd.Path
# EXE metadata configuration
$version_string = "1.1.0"
$tool_icon = "CoZIcon.ico"
$game_icon = "LauncherIcon.ico"
$publisher = "Committee of Zero"
$product_name = "ANONYMOUS;CODE Improvement Patch"
# Code
function SetInstallerExeMetadata {
param ([string]$exePath)
$originalFilename = (Get-Item $exePath).Name
.\rcedit-x86.exe $exePath `
--set-icon "$tool_icon" `
--set-file-version "$version_string" `
--set-product-version "$version_string" `
--set-version-string "CompanyName" "$publisher" `
--set-version-string "FileDescription" "$product_name Installer (v$version_string)" `
--set-version-string "FileVersion" "$version_string" `
--set-version-string "InternalName" "Installer.exe" `
--set-version-string "LegalCopyright" "$publisher" `
--set-version-string "OriginalFilename" "$originalFilename" `
--set-version-string "ProductName" "$product_name Installer" `
--set-version-string "ProductVersion" "$version_string"
}
function SetUninstallerExeMetadata {
param ([string]$exePath)
$originalFilename = (Get-Item $exePath).Name
.\rcedit-x86.exe $exePath `
--set-icon "$tool_icon" `
--set-file-version "$version_string" `
--set-product-version "$version_string" `
--set-version-string "CompanyName" "$publisher" `
--set-version-string "FileDescription" "$product_name Uninstaller (v$version_string)" `
--set-version-string "FileVersion" "$version_string" `
--set-version-string "InternalName" "nguninstall.exe" `
--set-version-string "LegalCopyright" "$publisher" `
--set-version-string "OriginalFilename" "$originalFilename" `
--set-version-string "ProductName" "$product_name Uninstaller" `
--set-version-string "ProductVersion" "$version_string"
}
function SetRealbootExeMetadata {
param ([string]$exePath)
$originalFilename = (Get-Item $exePath).Name
.\rcedit-x86.exe $exePath `
--set-icon "$game_icon" `
--set-file-version "$version_string" `
--set-product-version "$version_string" `
--set-version-string "CompanyName" "$publisher" `
--set-version-string "FileDescription" "$product_name Launcher (v$version_string)" `
--set-version-string "FileVersion" "$version_string" `
--set-version-string "InternalName" "realboot.exe" `
--set-version-string "LegalCopyright" "$publisher" `
--set-version-string "OriginalFilename" "$originalFilename" `
--set-version-string "ProductName" "$product_name Launcher" `
--set-version-string "ProductVersion" "$version_string"
}
function RunInsert {
param ([string]$scriptsName, [string]$variant)
New-Item -ItemType directory -Path "$repoRoot\temp\lines_$scriptsName" | Out-Null
New-Item -ItemType Junction -Path "$repoRoot\temp\lines_$scriptsName\lang0" -Target "$repoRoot\$scriptsName" | Out-Null
python "$repoRoot\kawtools\insert.py" "$repoRoot\temp\lines_$scriptsName" "$repoRoot\build-vortex\$variant\c0patch\scenario"
}
function RebuildC0patch {
param ([string]$variant)
$tempDir = "$repoRoot\temp\$variant\c0patch"
New-Item -ItemType directory -Path $tempDir | Out-Null
cd "$repoRoot\build-vortex\$variant"
& "$repoRoot\DoNut\DoNut\bin\Release\net8.0\DoNut.exe" "c0patch"
Move-Item -Force .\c0patch_info.json .\c0patch_info.psb.m.json
& "$repoRoot\FreeMote\PsBuild.exe" info-psb c0patch_info.psb.m.json
Move-Item -Force .\c0patch_info.psb.m $tempDir
Move-Item -Force .\c0patch_body.bin $tempDir
cd $repoRoot
}
function RebuildTips {
param ([string]$scriptsName, [string]$variant)
& "$repoRoot\FreeMote\PsbDecompile.exe" "$repoRoot\build-vortex\$variant\config\tips.psb.m"
New-Item -ItemType directory -Path "$repoRoot\temp\tipslines_$scriptsName" | Out-Null
New-Item -ItemType Junction -Path "$repoRoot\temp\tipslines_$scriptsName\lang1" -Target "$repoRoot\$scriptsName" | Out-Null
python "$repoRoot\kawtools\insert_tips.py" "$repoRoot\temp\tipslines_$scriptsName" "$repoRoot\build-vortex\$variant\config\tips.psb.m.json"
}
function RebuildTriggerParams {
param ([string]$scriptsName, [string]$variant)
& "$repoRoot\FreeMote\PsbDecompile.exe" "$repoRoot\build-vortex\$variant\config\trigger_params.psb.m"
python "$repoRoot\kawtools\insert_trigger_params.py" "$repoRoot\$scriptsName\trigger_params.txt" "$repoRoot\build-vortex\$variant\config\trigger_params.psb.m.json"
}
function RebuildConfig {
param ([string]$variant)
$tempDir = "$repoRoot\temp\$variant\config"
New-Item -ItemType directory -Path $tempDir | Out-Null
cd "$repoRoot\build-vortex\$variant"
foreach ($name in @("init", "movie_config", "trigger_params", "tips")) {
& "$repoRoot\FreeMote\PsBuild.exe" -nr -o "config\$name.psb.m" "config\$name.psb.m.json"
}
New-Item -ItemType directory -Path .\overrides_stash | Out-Null
Move-Item -Force config\*.json .\overrides_stash
Remove-Item -Force -ErrorAction SilentlyContinue config\*.pure.psb, config\tips.psb.m.psb
python "$repoRoot\kawtools\gen_archive_info.py" config config_info.psb.m.json
& "$repoRoot\FreeMote\PsBuild.exe" info-psb config_info.psb.m.json
Move-Item -Force .\overrides_stash\*.json config\
Remove-Item .\overrides_stash
Move-Item -Force .\config_info.psb.m $tempDir
Move-Item -Force .\config_body.bin $tempDir
cd $repoRoot
}
function RebuildScript {
$tempDir = "$repoRoot\temp\common\script"
New-Item -ItemType directory -Path $tempDir | Out-Null
cd "$repoRoot\build-vortex\common"
python "$repoRoot\kawtools\gen_archive_info.py" script script_info.psb.m.json
& "$repoRoot\FreeMote\PsBuild.exe" info-psb script_info.psb.m.json
Move-Item -Force .\script_info.psb.m $tempDir
Move-Item -Force .\script_body.bin $tempDir
cd $repoRoot
}
function RebuildFont {
$tempDir = "$repoRoot\temp\common\font"
New-Item -ItemType directory -Path $tempDir | Out-Null
cd "$repoRoot\build-vortex\common"
python "$repoRoot\kawtools\gen_archive_info.py" font font_info.psb.m.json
& "$repoRoot\FreeMote\PsBuild.exe" info-psb font_info.psb.m.json
Move-Item -Force .\font_info.psb.m $tempDir
Move-Item -Force .\font_body.bin $tempDir
cd $repoRoot
}
function RebuildC0sound {
$tempDir = "$repoRoot\temp\common\c0sound"
New-Item -ItemType directory -Path $tempDir | Out-Null
cd "$repoRoot\build-vortex\common"
# PsBuild's archive packer scans the ArchiveSource folder directly and
# packs every physical file as an entry, regardless of the manifest's
# file_info list -- .gitkeep would otherwise get packed as a spurious
# entry. Stash it out of the folder for the pack step, then restore it.
Move-Item -Force .\c0sound\.gitkeep $tempDir
python "$repoRoot\kawtools\gen_archive_info.py" c0sound c0sound_info.psb.m.json "*" ".psb"
& "$repoRoot\FreeMote\PsBuild.exe" info-psb c0sound_info.psb.m.json
Move-Item -Force $tempDir\.gitkeep .\c0sound\.gitkeep
Move-Item -Force .\c0sound_info.psb.m $tempDir
Move-Item -Force .\c0sound_body.bin $tempDir
cd $repoRoot
}
# END CONFIG
function PrintSection {
param ([string]$desc)
$line = "------------------------------------------------------------------------"
$len = (($line.length, $desc.legnth) | Measure -Max).Maximum
Write-Host ""
Write-Host $line.PadRight($len) -BackgroundColor DarkBlue -ForegroundColor Cyan
Write-Host (" >> " + $desc).PadRight($len) -BackgroundColor DarkBlue -ForegroundColor Cyan
Write-Host $line.PadRight($len) -BackgroundColor DarkBlue -ForegroundColor Cyan
Write-Host ""
}
Write-Output " TERRIBUILD"
Write-Output "Rated World's #1 Build Script By Leading Game Industry Officials"
Write-Output ""
Write-Output "------------------------------------------------------------------------"
Write-Output ""
PrintSection "Creating new DIST and temp"
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue .\DIST
New-Item -ItemType directory -Path .\DIST | Out-Null
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue .\temp
New-Item -ItemType directory -Path .\temp | Out-Null
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue .\symbols
New-Item -ItemType directory -Path .\symbols | Out-Null
PrintSection "Pulling latest script changes"
cd ac-scripts-full
& git pull
cd ..
cd ac-scripts-partial
& git pull
cd ..
PrintSection "Building DoNut"
dotnet build .\DoNut\DoNut\DoNut.csproj -c Release
PrintSection "Inserting translated scenario text"
Write-Output "Inserting full scenario text"
RunInsert "ac-scripts-full" "full"
Write-Output "Inserting partial scenario text"
RunInsert "ac-scripts-partial" "partial"
PrintSection "Inserting translated tips text"
Write-Output "Inserting full tips text"
RebuildTips "ac-scripts-full" "full"
Write-Output "Inserting partial tips text"
RebuildTips "ac-scripts-partial" "partial"
PrintSection "Inserting translated trigger_params text"
Write-Output "Inserting full trigger_params text"
RebuildTriggerParams "ac-scripts-full" "full"
Write-Output "Inserting partial trigger_params text"
RebuildTriggerParams "ac-scripts-partial" "partial"
PrintSection "Reconstructing c0patch archives"
Write-Output "Rebuilding full c0patch"
RebuildC0patch "full"
Write-Output "Rebuilding partial c0patch"
RebuildC0patch "partial"
PrintSection "Reconstructing config archives"
Write-Output "Rebuilding full config"
RebuildConfig "full"
Write-Output "Rebuilding partial config"
RebuildConfig "partial"
PrintSection "Reconstructing script, font, and c0sound archives"
Write-Output "Rebuilding script"
RebuildScript
Write-Output "Rebuilding font"
RebuildFont
Write-Output "Rebuilding c0sound"
RebuildC0sound
PrintSection "Copying content to DIST"
Copy-Item -Recurse -Force .\content\* .\DIST
PrintSection "Copying rebuilt archives to DIST"
New-Item -ItemType directory -Force -Path .\DIST\DIST_FULL\windata | Out-Null
New-Item -ItemType directory -Force -Path .\DIST\DIST_PARTIAL\windata | Out-Null
New-Item -ItemType directory -Force -Path .\DIST\DIST_COMMON\windata | Out-Null
Copy-Item -Force .\temp\full\c0patch\c0patch_info.psb.m, .\temp\full\c0patch\c0patch_body.bin .\DIST\DIST_FULL\windata
Copy-Item -Force .\temp\partial\c0patch\c0patch_info.psb.m, .\temp\partial\c0patch\c0patch_body.bin .\DIST\DIST_PARTIAL\windata
Copy-Item -Force .\temp\full\config\config_info.psb.m, .\temp\full\config\config_body.bin .\DIST\DIST_FULL\windata
Copy-Item -Force .\temp\partial\config\config_info.psb.m, .\temp\partial\config\config_body.bin .\DIST\DIST_PARTIAL\windata
Copy-Item -Force .\temp\common\script\script_info.psb.m, .\temp\common\script\script_body.bin .\DIST\DIST_COMMON\windata
Copy-Item -Force .\temp\common\font\font_info.psb.m, .\temp\common\font\font_body.bin .\DIST\DIST_COMMON\windata
Copy-Item -Force .\temp\common\c0sound\c0sound_info.psb.m, .\temp\common\c0sound\c0sound_body.bin .\DIST\DIST_COMMON\windata
PrintSection "Building and copying realboot"
cd launcher
& .\realboot_build.bat
cd ..
SetRealbootExeMetadata .\launcher\deploy\MAGESgamelauncher.exe
Copy-Item -Recurse -Force .\launcher\deploy\* .\DIST\DIST_COMMON
Copy-Item -Recurse -Force .\launcher\build\release\*.pdb .\symbols
PrintSection "Building noidget"
cd installer
& .\noidget_build.bat
cd ..
SetInstallerExeMetadata .\installer\deploy\noidget.exe
SetUninstallerExeMetadata .\installer\deployUninstaller\noidget.exe
Copy-Item -Recurse -Force .\installer\build\release\*.pdb .\symbols
PrintSection "Packing uninstaller"
cd installer\deployUninstaller
7z a -mx=0 ..\..\temp\sfxbaseUninstaller.7z .\*
cd ..\..
copy .\7zS2.sfx .\temp\UninstallerExtractor.exe
SetUninstallerExeMetadata -exePath .\temp\UninstallerExtractor.exe
cmd /c copy /b .\temp\UninstallerExtractor.exe + .\temp\sfxbaseUninstaller.7z DIST\DIST_COMMON\nguninstall.exe
PrintSection "Packing installer"
cd temp
$patchFolderName = "ACSteamPatch-v$version_string-Setup"
New-Item -ItemType directory -Path $patchFolderName | Out-Null
cd $patchFolderName
New-Item -ItemType directory -Path DIST | Out-Null
Move-Item -Force ..\..\DIST\* .\DIST
New-Item -ItemType directory -Path achievements | Out-Null
Copy-Item -Recurse -Force ..\..\achievements\* .\achievements
Move-Item -Force ..\..\installer\deploy\* .
Move-Item -Force .\noidget.exe .\ACSteamPatch-Installer.exe
cd ..\..\DIST
7z a -mx=5 "$patchFolderName.zip" "..\temp\$patchFolderName"
cd ..
PrintSection "Removing temp"
Remove-Item -Force -Recurse .\temp