-
Notifications
You must be signed in to change notification settings - Fork 0
/
terribuild.ps1
198 lines (174 loc) · 7.91 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
[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.1.0"
$tool_icon = "CoZIcon.ico"
$game_icon = "LauncherIcon.ico"
$publisher = "Committee of Zero"
$product_name = "CHAOS;HEAD NOAH Overhaul Patch (Steam)"
# 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 chn-patched-scripts-builder/data/txt_eng
& git pull
cd ../../..
PrintSection "Building LanguageBarrier as $languagebarrier_configuration|$languagebarrier_platform"
& "$msbuild" "$languagebarrier_dir\LanguageBarrier\LanguageBarrier.vcxproj" "/p:Configuration=$languagebarrier_configuration" "/p:Platform=$languagebarrier_platform"
PrintSection "Copying LanguageBarrier to DIST"
Copy-Item $languagebarrier_dir\x64\$languagebarrier_configuration\*.dll .\DIST
Copy-Item $languagebarrier_dir\x64\$languagebarrier_configuration\*.pdb .\symbols
Copy-Item -Recurse $languagebarrier_dir\x64\$languagebarrier_configuration\languagebarrier .\DIST
New-Item -ItemType directory -Path ".\DIST\HEAD NOAH" | Out-Null
# TODO how does wine handle this?
Move-Item .\DIST\*.dll ".\DIST\HEAD NOAH\"
# Reported necessary for some users, otherwise:
# "Procedure entry point csri_renderer_default could not be located in ...\HEAD NOAH\DINPUT8.dll"
Copy-Item ".\DIST\HEAD NOAH\VSFilter.dll " .\DIST\
PrintSection "Patching scripts"
cd chn-patched-scripts-builder
python .\build_windows.py
Copy-Item .\out\windows\*.cpk ..\DIST\languagebarrier\
cd ..
PrintSection "Packing c0data.cpk"
cd .\cri-tools
python .\create_archive.py --directory ..\c0data\ --archive ..\DIST\languagebarrier\c0data.cpk
cd ..
# LanguageBarrier currently needs this file to be present even if no string redirections are configured
echo $null > .\content\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\Game_Steam.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
PrintSection "Packing installer"
cd temp
$patchFolderName = "CHNSteamPatch-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 STEAMGRID | Out-Null
Copy-Item -Recurse -Force ..\..\content_steamgrid\* .\STEAMGRID
Move-Item -Force ..\..\installer\deploy\* .
Move-Item -Force .\noidget.exe .\CHNSteamPatch-Installer.exe
cd ..\..\DIST
7z a -mx=5 "$patchFolderName.zip" "..\temp\$patchFolderName"
cd ..
PrintSection "Removing temp"
Remove-Item -Force -Recurse .\temp