-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
81 lines (69 loc) · 2.48 KB
/
build.ps1
File metadata and controls
81 lines (69 loc) · 2.48 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# build.ps1
# Builds terminal and GUI versions of 3270Connect for Windows and Linux
Write-Host "======================================"
Write-Host " Building 3270Connect binaries"
Write-Host "======================================"
Write-Host ""
# --- Ensure rsrc exists ---
$rsrcCmd = Get-Command rsrc -ErrorAction SilentlyContinue
if ($rsrcCmd) {
$rsrcPath = $rsrcCmd.Source
} else {
$rsrcPath = Join-Path $env:USERPROFILE "go\bin\rsrc.exe"
}
if (-not (Test-Path $rsrcPath)) {
Write-Host "Installing rsrc (for Windows icon embedding)..."
go install github.com/akavel/rsrc@latest
$rsrcPath = Join-Path $env:USERPROFILE "go\bin\rsrc.exe"
}
# --- Check rsrc and logo.ico ---
if (-not (Test-Path $rsrcPath)) {
Write-Error "❌ Could not find rsrc.exe even after install. Ensure Go bin folder is in PATH."
exit 1
}
if (-not (Test-Path "logo.ico")) {
Write-Error "❌ logo.ico not found in project directory: $PWD"
exit 1
}
# --- Embed Windows icon ---
Write-Host "Embedding icon into the Windows binary..."
& $rsrcPath -ico "logo.ico" -o "resource.syso"
if ($LASTEXITCODE -ne 0) {
Write-Error "❌ Failed to embed icon via rsrc."
exit 1
}
# --- Create output folder ---
if (-not (Test-Path "dist")) {
New-Item -ItemType Directory -Path "dist" | Out-Null
}
# --- Build Windows terminal version ---
Write-Host "Building Windows terminal version..."
go build -o "dist/3270Connect.exe" .
if ($LASTEXITCODE -ne 0) {
Write-Error "❌ Failed to build Windows version."
exit 1
}
# --- Build Linux version ---
Write-Host "Building Linux version..."
$oldGOOS = $env:GOOS
$oldGOARCH = $env:GOARCH
$oldCGO = $env:CGO_ENABLED
$env:GOOS = "linux"
$env:GOARCH = "amd64"
$env:CGO_ENABLED = "0"
go build -o "dist/3270Connect_linux" .
if ($LASTEXITCODE -ne 0) {
Write-Error "❌ Failed to build Linux version."
exit 1
}
# --- Restore environment variables ---
if ($oldGOOS) { $env:GOOS = $oldGOOS } else { Remove-Item Env:GOOS -ErrorAction SilentlyContinue }
if ($oldGOARCH) { $env:GOARCH = $oldGOARCH } else { Remove-Item Env:GOARCH -ErrorAction SilentlyContinue }
if ($oldCGO) { $env:CGO_ENABLED = $oldCGO } else { Remove-Item Env:CGO_ENABLED -ErrorAction SilentlyContinue }
Write-Host ""
Write-Host " Build complete!"
Write-Host "--------------------------------------"
Write-Host " dist/3270Connect.exe → Windows terminal version"
Write-Host " dist/3270Connect_linux → Linux (amd64, static)"
Write-Host "--------------------------------------"
Write-Host ""