6dccf494f8
cleanup permit policies and correct documentation * docs * policy cleanup * refactor * Merge remote-tracking branch 'origin/feature/permit-policy-cleanup' into feature/permit-policy-cleanup * docs and edits
74 lines
1.9 KiB
Bash
Executable File
74 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Build Linux binaries for the cognito auth harness main.go
|
|
# Usage examples:
|
|
# ./build_linux.sh # builds linux/amd64 -> cognito.auth.harness_linux_amd64
|
|
# ./build_linux.sh --arch arm64 # builds linux/arm64 -> cognito.auth.harness_linux_arm64
|
|
# ./build_linux.sh --all # builds both amd64 and arm64
|
|
# ./build_linux.sh ./my_out # custom output for single-arch build
|
|
#
|
|
# Notes:
|
|
# - For AWS Graviton instances use --arch arm64
|
|
# - For AWS CloudShell or x86 EC2 use default (amd64)
|
|
#
|
|
# Env overrides:
|
|
# GOARCH: target architecture (amd64|arm64) when not using --all
|
|
# CGO_ENABLED: 0 by default for cross-compilation
|
|
|
|
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
GOOS=linux
|
|
DEFAULT_ARCH="${GOARCH:-amd64}"
|
|
CGO_ENABLED="${CGO_ENABLED:-0}"
|
|
|
|
OUT_OVERRIDE=""
|
|
ARCH_ARG=""
|
|
BUILD_BOTH=false
|
|
|
|
print_help() {
|
|
sed -n '1,35p' "$0" | sed 's/^# \{0,1\}//'
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--arch)
|
|
ARCH_ARG="$2"; shift 2 ;;
|
|
--all)
|
|
BUILD_BOTH=true; shift ;;
|
|
-h|--help)
|
|
print_help; exit 0 ;;
|
|
--)
|
|
shift; break ;;
|
|
-* )
|
|
echo "Unknown option: $1" >&2; exit 1 ;;
|
|
* )
|
|
# positional: output override for single-arch build
|
|
OUT_OVERRIDE="$1"; shift ;;
|
|
esac
|
|
done
|
|
|
|
build_one() {
|
|
local arch="$1"
|
|
local out_path="$2"
|
|
echo "Building Linux binary (GOARCH=${arch})"
|
|
echo " GOOS=${GOOS} GOARCH=${arch} CGO_ENABLED=${CGO_ENABLED}"
|
|
echo " Output: ${out_path}"
|
|
GOOS="$GOOS" GOARCH="$arch" CGO_ENABLED="$CGO_ENABLED" \
|
|
go build -o "$out_path" main.go
|
|
echo "✅ Built ${out_path}"
|
|
}
|
|
|
|
if $BUILD_BOTH; then
|
|
build_one amd64 "cognito.auth.harness_linux_amd64"
|
|
build_one arm64 "cognito.auth.harness_linux_arm64"
|
|
exit 0
|
|
fi
|
|
|
|
ARCH="${ARCH_ARG:-$DEFAULT_ARCH}"
|
|
DEFAULT_OUT="cognito.auth.harness_linux_${ARCH}"
|
|
OUT_PATH="${OUT_OVERRIDE:-$DEFAULT_OUT}"
|
|
|
|
build_one "$ARCH" "$OUT_PATH"
|