Skip to content

Commit

Permalink
Update build.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
Lartsch authored Jun 6, 2022
1 parent 2155da6 commit 2adb967
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$PSDefaultParameterValues = @{}
$PSDefaultParameterValues += @{'New-RegKey:ErrorAction' = 'SilentlyContinue'}

$name = "cisextractor"
$sourcefolder = "C:\<...>\cisextractor\src"
$buildfolder = "${sourcefolder}\build"
$upxpath = "${sourcefolder}\upx.exe"
$Env:GOARCH = "amd64"

$buildnames =@{
linux="${name}_linux_amd64";
darwin="${name}_mac_amd64";
windows="${name}_win_amd64.exe"
}

$buildnames.GetEnumerator() | % {
$key = $($_.key)
$value = $($_.value)
$filepath = "${buildfolder}\${value}"
Write-Host "`nNOW BUILDING: $key - $value"
Write-Host "Compiling ..."
$Env:GOOS = $key
go build -ldflags="-s -w" -o $filepath
Write-Host "Compressing..."
& $upxpath -9 -k $filepath
}

Write-Host "`n`nCleaning up...`n"
Get-ChildItem $buildfolder | Foreach-Object {
if ($_.FullName -match '~$' -or $_.FullName -match '000') {
rm $_.FullName
}
}

Write-Host "DONE`n"

0 comments on commit 2adb967

Please sign in to comment.