-
Notifications
You must be signed in to change notification settings - Fork 0
/
terribuild.ps1
233 lines (206 loc) · 9.22 KB
/
terribuild.ps1
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
[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."
}
# EXE metadata configuration
$version_string = "1.0.0"
$tool_icon = "CoZIcon.ico"
$game_icon = "LauncherIcon.ico"
$publisher = "Committee of Zero"
$product_name = "STEINS;GATE ELITE 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 GenerateEnscriptToc {
param ([string]$tocPath, [string]$scriptsPath)
$inToc = Import-CSV .\script_toc.csv -header Id, FilenameOnDisk, FilenameInArchive
$jw = New-Object Newtonsoft.Json.JsonTextWriter(New-Object System.IO.StreamWriter($tocPath))
$jw.Formatting = [Newtonsoft.Json.Formatting]::Indented
$jw.Indentation = 2
$jw.IndentChar = ' '
$jw.WriteStartArray();
foreach ($entry in $inToc) {
$jw.WriteStartObject();
$jw.WritePropertyName("id");
$jw.WriteValue([int]$entry.Id);
$jw.WritePropertyName("filename");
$jw.WriteValue($entry.FilenameInArchive);
$jw.WritePropertyName('size');
$jw.WriteValue((Get-Item "$scriptsPath\$($entry.FilenameInArchive)").Length);
$jw.WriteEndObject();
}
$jw.WriteEndArray();
$jw.Flush()
$jw.Close()
}
# 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 sge-scripts
& git pull
cd ..
PrintSection "Building LanguageBarrier as $languagebarrier_configuration"
& "$msbuild" "$languagebarrier_dir\LanguageBarrier\LanguageBarrier.vcxproj" "/p:Configuration=$languagebarrier_configuration"
PrintSection "Copying LanguageBarrier to DIST"
Copy-Item $languagebarrier_dir\languagebarrier\$languagebarrier_configuration\*.dll .\DIST
Copy-Item $languagebarrier_dir\languagebarrier\$languagebarrier_configuration\*.pdb .\symbols
Copy-Item -Recurse $languagebarrier_dir\languagebarrier\$languagebarrier_configuration\languagebarrier .\DIST
#New-Item -ItemType directory -Path ".\DIST\GATE" | Out-Null
# TODO how does wine handle this?
#Move-Item .\DIST\dinput8.dll ".\DIST"
# Reported necessary for some users, otherwise:
# "Procedure entry point csri_renderer_default could not be located in ...\CHILD\DINPUT8.dll"
#Copy-Item .\DIST\VSFilter.dll ".\DIST"
PrintSection "Building sc3tools"
cd sc3tools
cargo build --release --bin=sc3tools --package=sc3tools
cd ..
PrintSection "Patching scripts"
New-Item -ItemType directory -Path .\temp\patched_script_archive | Out-Null
copy script_archive_steam\*.scx temp\patched_script_archive
#$scripts = gci temp\patched_script_archive
#foreach ($script in $scripts)
#{
# $patches = gci .\zero-script-patches\$($script.Name).*.vcdiff | Sort
# foreach ($patch in $patches)
# {
# $scriptPath = $script.FullName
# Write-Output "$scriptPath $($patch.FullName) $scriptPath.tmp"
# .\xdelta3.exe -d -s "$scriptPath" "$($patch.FullName)" "$scriptPath.tmp"
# Remove-Item $scriptPath
# Move-Item -Path "$scriptPath.tmp" -Destination "$scriptPath"
# }
#}
#
New-Item -ItemType directory -Path .\temp\patched_edited_script_archive | Out-Null
copy temp\patched_script_archive\*.scx temp\patched_edited_script_archive
.\sc3tools\target\release\sc3tools.exe replace-text temp\patched_edited_script_archive\*.scx sge-scripts\*.txt sge
Write-Output "========================================================================"
Write-Output "Moving enscript"
Copy-Item -Recurse -Force temp\patched_edited_script_archive .\DIST\languagebarrier\enscript
Write-Output "========================================================================"
# LanguageBarrier currently needs this file to be present even if no string redirections are configured
echo $null > .\DIST\languagebarrier\stringReplacementTable.bin
#PrintSection "Copying content to DIST"
Copy-Item -Recurse -Force .\content\* .\DIST
PrintSection "Building and copying realboot"
cd launcher
& .\realboot_build.bat
cd ..
SetRealbootExeMetadata .\launcher\deploy\LauncherC0.exe
Copy-Item -Recurse -Force .\launcher\deploy\* .\DIST
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\nguninstall.exe
# Only change to switch to SFX installer: Uncomment section below, comment out section after that one
<#
PrintSection "Packing installer"
7z a -mx=0 .\temp\sfxbase.7z DIST
cd temp
7z a -mx=0 .\sfxbase.7z merged_patches
7z a -mx=0 .\sfxbase.7z merged_patches_c
cd ..
cd installer\deploy
7z a -mx=0 ..\..\temp\sfxbase.7z .\*
cd ..\..
copy .\7zS2.sfx .\temp\InstallerExtractor.exe
SetInstallerExeMetadata -exePath .\temp\InstallerExtractor.exe
cmd /c copy /b .\temp\InstallerExtractor.exe + .\temp\sfxbase.7z DIST\Installer.exe
#>
PrintSection "Packing installer"
cd temp
$patchFolderName = "SGEPatch-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
Move-Item -Force ..\..\installer\deploy\* .
Move-Item -Force .\noidget.exe .\SGEPatch-Installer.exe
cd ..\..\DIST
7z a -mx=5 "$patchFolderName.zip" "..\temp\$patchFolderName"
cd ..
PrintSection "Removing temp"
Remove-Item -Force -Recurse .\temp