-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-macos.sh
More file actions
52 lines (45 loc) · 1.71 KB
/
Copy pathbuild-macos.sh
File metadata and controls
52 lines (45 loc) · 1.71 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
#!/usr/bin/env bash
#
# Build TetherSSH natively on macOS (run this ON a Mac).
#
# Place this at the repo root (same directory as go.mod and the cli/ folder).
# Run: ./build-macos.sh # build for the host arch (arm64 or amd64)
# ./build-macos.sh universal # fat binary: arm64 + amd64 via lipo
# ./build-macos.sh amd64 # force one arch
# STRIP=0 ./build-macos.sh # keep symbols
#
# Build deps: Xcode command line tools -> xcode-select --install
#
# Cross note: Apple's clang is multi-arch, so on either Apple Silicon or Intel you
# can build BOTH darwin arches locally; "universal" just builds each and lipo's them.
set -euo pipefail
cd "$(dirname "$0")"
APP="tetherssh"
OUT="dist/macos"
mkdir -p "$OUT"
ARCH="${1:-$(go env GOARCH)}" # arm64 | amd64 | universal
LDFLAGS=""
if [ "${STRIP:-1}" = "1" ]; then
LDFLAGS="-s -w"
fi
build_one () {
local goarch="$1" out="$2"
echo ">> building ${APP} for darwin/${goarch} (CGO on)"
CGO_ENABLED=1 GOOS=darwin GOARCH="${goarch}" \
go build -trimpath -ldflags "${LDFLAGS}" -o "${out}" ./cli
}
if [ "${ARCH}" = "universal" ]; then
build_one arm64 "${OUT}/${APP}.arm64"
build_one amd64 "${OUT}/${APP}.amd64"
echo ">> lipo -> universal"
lipo -create -output "${OUT}/${APP}" "${OUT}/${APP}.arm64" "${OUT}/${APP}.amd64"
rm -f "${OUT}/${APP}.arm64" "${OUT}/${APP}.amd64"
else
build_one "${ARCH}" "${OUT}/${APP}"
fi
echo ">> done: ${OUT}/${APP}"
file "${OUT}/${APP}"
# Optional: produce a double-clickable TetherSSH.app instead of a bare binary.
# go install fyne.io/fyne/v2/cmd/fyne@latest
# fyne package -os darwin -name TetherSSH -icon Icon.png -src ./cli
# (run from repo root; needs an Icon.png and FyneApp.toml or -appID set)