Skip to content

Commit b7cc6dd

Browse files
author
Soham Dasgupta
committed
feat: polygon binary compression
1 parent f570cfd commit b7cc6dd

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

polygon.ps1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@ Expand-Archive -Path "$cwd\build\Ahk2exe.zip" -DestinationPath "$cwd\build\ahk";
2929

3030
Write-Host "Downloaded the latest release from Ahk2Exe into `"$cwd\build\ahk\`"" -ForegroundColor Green;
3131

32+
# Download upx
33+
$upxFileNamePattern = "upx-.*\-win64.zip"
34+
$upxLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/upx/upx/releases/latest";
35+
$upxDownloadURL = ($upxLatestRelease.assets | Where-Object { $_.name -match "$upxFileNamePattern" }) | Select-Object -ExpandProperty browser_download_url
36+
Invoke-WebRequest -Uri $upxDownloadURL -OutFile "$cwd\build\upx.zip";
37+
Expand-Archive -Path "$cwd\build\upx.zip" -DestinationPath "$cwd\build\upx" -Force;
38+
$sourceFolders = Get-ChildItem -Path "$cwd\build\upx\" -Directory -Filter "upx-*";
39+
foreach ($folder in $sourceFolders) {
40+
$exeFiles = Get-ChildItem -Path $folder.FullName -Filter "*.exe";
41+
foreach ($file in $exeFiles) {
42+
Move-Item -Path $file.FullName -Destination "$cwd\build\ahk\" -Force;
43+
}
44+
}
45+
46+
Write-Host "Downloaded the latest release from upx into `"$cwd\build\upx\`"" -ForegroundColor Green;
47+
3248
# Download Wix3
3349
$wixFileNamePattern = "wix311-binaries.zip"
3450
$wixLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/wixtoolset/wix3/releases/latest";
@@ -38,14 +54,17 @@ Expand-Archive -Path "$cwd\build\$wixFileNamePattern" -DestinationPath "$cwd\bui
3854

3955
Write-Host "Downloaded the latest release from Wix3 into `"$cwd\build\wix\`"" -ForegroundColor Green;
4056

41-
& "$cwd\build\ahk\Ahk2Exe.exe" /in polygon.ahk /out "$cwd\build\polygon-x64.exe" /icon logo.ico /base "$cwd\build\ahk\AutoHotkey64.exe";
42-
& "$cwd\build\ahk\Ahk2Exe.exe" /in polygon.ahk /out "$cwd\build\polygon-x86.exe" /icon logo.ico /base "$cwd\build\ahk\AutoHotkey32.exe";
57+
# Build polygon executables
58+
& "$cwd\build\ahk\Ahk2Exe.exe" /in polygon.ahk /out "$cwd\build\polygon-x64.exe" /compress 2 /icon logo.ico /base "$cwd\build\ahk\AutoHotkey64.exe";
59+
& "$cwd\build\ahk\Ahk2Exe.exe" /in polygon.ahk /out "$cwd\build\polygon-x86.exe" /compress 2 /icon logo.ico /base "$cwd\build\ahk\AutoHotkey32.exe";
4360

4461
Write-Host "Polygon binaries built successfully into `"$cwd\build\`"" -ForegroundColor Green;
4562

63+
# Build polygon installer object file
4664
& "$cwd\build\wix\candle.exe" .\polygon.wxs -out "$cwd\build\polygon-x86.wixobj" -dVersion="$versionNumber" -arch x86;
4765
& "$cwd\build\wix\candle.exe" .\polygon.wxs -out "$cwd\build\polygon-x64.wixobj" -dVersion="$versionNumber" -arch x64;
4866

67+
# Build polygon installer MSI
4968
& "$cwd\build\wix\light.exe" "$cwd\build\polygon-x86.wixobj" -ext WixUIExtension -out "$cwd\build\polygon-x86.msi";
5069
& "$cwd\build\wix\light.exe" "$cwd\build\polygon-x64.wixobj" -ext WixUIExtension -out "$cwd\build\polygon-x64.msi";
5170

0 commit comments

Comments
 (0)