-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.ps1
52 lines (42 loc) · 1.57 KB
/
build.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
[CmdletBinding()]
param(
[Parameter()]
[string]
$PatchDir = "alttp_sm_combo_randomizer_rom"
)
process {
$ErrorActionPreference = "Stop"
function Compress-Item([string]$Path, [string]$OutFile) {
$buffer = New-Object System.IO.MemoryStream
$gzip = New-Object System.IO.Compression.GZipStream ($buffer, [IO.Compression.CompressionMode]::Compress)
$source = [IO.File]::OpenRead($Path)
$source.CopyTo($gzip)
$source.Close()
$gzip.Close()
[IO.File]::WriteAllBytes($OutFile, $buffer.ToArray())
}
$cd = (Get-Location -PSProvider FileSystem).ProviderPath
# Download ASAR
if (-not(Test-Path -Path "$cd/asar")) {
New-Item -Path "$cd/asar" -ItemType Directory
}
Invoke-WebRequest `
-Uri "https://github.com/RPGHacker/asar/releases/download/v1.81/asar181.zip" `
-OutFile "$cd/asar/asar181.zip"
# Extract ASAR to the patch folder
[Environment]::CurrentDirectory = "$cd/asar"
Add-Type -AssemblyName System.IO.Compression.FileSystem
Try {
$zip = [System.IO.Compression.ZipFile]::OpenRead("asar181.zip")
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($zip.GetEntry("asar.exe"), "asar.exe", $true);
}
Finally {
$zip.Dispose()
}
Copy-Item -Path "$cd/asar/asar.exe" -Destination "$PatchDir/resources/asar.exe"
# Build the patch
Set-Location $PatchDir
cmd.exe /c "build.bat"
Copy-Item -Path "$cd/$PatchDir/build/zsm.ips" -Destination "$cd/src/TrackerCouncil.Smz3.UI/Patches/zsm.ips"
Set-Location $cd
}