From 9cb81da20e17bbd37e7bd62abb94e856ae11a497 Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Wed, 16 Nov 2016 09:22:45 -0500 Subject: [PATCH] Added build script for building packages on Windows --- build.ps1 | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 000000000..cf6dd45c8 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,41 @@ + param ( + [string]$SHA = "" + ) + +if ($SHA -eq ""){ + $SHA = (git rev-parse HEAD) | Out-String + $SHA = $SHA.Replace([System.Environment]::NewLine,"") +} + + +$PKG = "github.com/StackExchange/dnscontrol" +$DATE = [int][double]::Parse((Get-Date -UFormat %s)) +$FLAGS="-s -w -X main.SHA=$SHA -X main.BuildTime=$DATE" +Write-Host $FLAGS + +$OrigGOOS = $env:GOOS + +Write-Host 'Building Linux' +$env:GOOS = "linux" +go build -o dnscontrol-Linux -ldflags "$FLAGS" $PKG + +Write-Host 'Building Windows' +$env:GOOS = "windows" +go build -o dnscontrol.exe -ldflags "$FLAGS" $PKG + +Write-Host 'Building Darwin' +$env:GOOS = "darwin" +go build -o dnscontrol-Darwin -ldflags "$FLAGS" $PKG + +$env:GOOS = $OrigGOOS + +#No compression if building on windows +<# +if [ "$COMPRESS" = "1" ] +then + echo 'Compressing executables' + upx dnscontrol.exe + upx dnscontrol-Linux + upx dnscontrol-Darwin +fi +#> \ No newline at end of file