Skip to content

Commit 94ffe65

Browse files
Isaac SpringerIsaac Springer
authored andcommitted
add build and ignore
1 parent 9247b90 commit 94ffe65

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

build.ps1

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
$MyScript = $MyInvocation.MyCommand.Definition
2+
$MyPath = Split-Path $MyScript
3+
$MyProject = $(Get-Item $MyPath).BaseName
4+
5+
$BuildOpts = @{
6+
"windows" = @("386", "amd64")
7+
}
8+
9+
Push-Location $MyPath
10+
if (!(Test-Path $MyPath\bin)) { New-Item -Path $MyPath\bin -ItemType Directory | Out-Null }
11+
12+
ForEach ($OS in $BuildOpts.GetEnumerator()) {
13+
ForEach ($Arch in $OS.Value) {
14+
$env:GOOS = $OS.Key
15+
$env:GOARCH = $Arch
16+
17+
if ($env:GOOS -eq "windows") { $Ext = ".exe" } else { $Ext = $null }
18+
19+
Try {
20+
Write-Host "Building: $env:GOOS ($env:GOARCH)"
21+
& go build -o "$MyPath\bin\$MyProject-$env:GOOS-$env:GOARCH$Ext"
22+
}
23+
24+
Catch {
25+
Write-Warning ("Build Failure: $env:GOOS ($env:GOARCH)`r`n`t" + $_.Exception.Message)
26+
}
27+
}
28+
}
29+
30+
Pop-Location

0 commit comments

Comments
 (0)