Skip to content

Commit 2adb967

Browse files
authored
Update build.ps1
1 parent 2155da6 commit 2adb967

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/build.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$PSDefaultParameterValues = @{}
2+
$PSDefaultParameterValues += @{'New-RegKey:ErrorAction' = 'SilentlyContinue'}
3+
4+
$name = "cisextractor"
5+
$sourcefolder = "C:\<...>\cisextractor\src"
6+
$buildfolder = "${sourcefolder}\build"
7+
$upxpath = "${sourcefolder}\upx.exe"
8+
$Env:GOARCH = "amd64"
9+
10+
$buildnames =@{
11+
linux="${name}_linux_amd64";
12+
darwin="${name}_mac_amd64";
13+
windows="${name}_win_amd64.exe"
14+
}
15+
16+
$buildnames.GetEnumerator() | % {
17+
$key = $($_.key)
18+
$value = $($_.value)
19+
$filepath = "${buildfolder}\${value}"
20+
Write-Host "`nNOW BUILDING: $key - $value"
21+
Write-Host "Compiling ..."
22+
$Env:GOOS = $key
23+
go build -ldflags="-s -w" -o $filepath
24+
Write-Host "Compressing..."
25+
& $upxpath -9 -k $filepath
26+
}
27+
28+
Write-Host "`n`nCleaning up...`n"
29+
Get-ChildItem $buildfolder | Foreach-Object {
30+
if ($_.FullName -match '~$' -or $_.FullName -match '000') {
31+
rm $_.FullName
32+
}
33+
}
34+
35+
Write-Host "DONE`n"

0 commit comments

Comments
 (0)