forked from Juice-Labs/Juice-Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build-All.ps1
57 lines (47 loc) · 1.57 KB
/
Build-All.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
param (
[Parameter()]
[string]
$Output = (Get-Location).Path,
[Parameter()]
[switch]
$BuildDebug,
[Parameter()]
[string]
$Version = "unset"
)
# Powershell 5 and below are available only on Windows
if ($PSVersionTable.PSVersion.Major -lt 7)
{
$IsWindows = $true
$IsLinux = $false
}
$Suffix = ""
if ($IsWindows)
{
$Suffix = ".exe"
}
function Get-LinkFlags($Component)
{
$SentryDsn = @{
agent = $env:JUICE_AGENT_SENTRY_DSN;
controller = $env:JUICE_CONTROLLER_SENTRY_DSN;
juicify = $env:JUICE_JUICIFY_SENTRY_DSN;
}
$dsn = $SentryDsn[$Component]
return @(
"-X github.com/Juice-Labs/Juice-Labs/cmd/internal/build.Version=$Version";
"-X github.com/Juice-Labs/Juice-Labs/pkg/sentry.SentryDsn=$dsn";
) | Join-String -Separator " "
}
if ($BuildDebug)
{
& go build -o $Output/agent$Suffix -ldflags (Get-LinkFlags -Component "agent") -gcflags=all='-N -l' ./cmd/agent/main.go
& go build -o $Output/controller$Suffix -ldflags (Get-LinkFlags -Component "controller") -gcflags=all='-N -l' ./cmd/controller/main.go
& go build -o $Output/juicify$Suffix -ldflags (Get-LinkFlags -Component "juicify") -gcflags=all='-N -l' ./cmd/juicify/main.go
}
else
{
& go build -o $Output/agent$Suffix -ldflags (Get-LinkFlags -Component "agent") ./cmd/agent/main.go
& go build -o $Output/controller$Suffix -ldflags (Get-LinkFlags -Component "controller") ./cmd/controller/main.go
& go build -o $Output/juicify$Suffix -ldflags (Get-LinkFlags -Component "juicify") ./cmd/juicify/main.go
}