dev 1015 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. # Simple dev tool launcher - builds if needed
  3. set -euo pipefail
  4. # Change to script's directory
  5. cd "$(dirname "${BASH_SOURCE[0]}")"
  6. # Colors
  7. GREEN='\033[0;32m'
  8. RED='\033[0;31m'
  9. NC='\033[0m'
  10. log() { echo -e "${GREEN}[DEV]${NC} $*"; }
  11. error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
  12. # Simple platform detection
  13. ARCH=$(uname -m)
  14. case $ARCH in
  15. x86_64) ARCH="amd64" ;;
  16. arm64 | aarch64) ARCH="arm64" ;;
  17. *)
  18. error "Unsupported arch: $ARCH"
  19. exit 1
  20. ;;
  21. esac
  22. BINARY="bin/dev-linux-$ARCH"
  23. # Build if binary doesn't exist or source is newer
  24. if [[ ! -f "$BINARY" ]] || [[ "main.go" -nt "$BINARY" ]]; then
  25. if ! command -v go &>/dev/null; then
  26. error "Go not installed. Install with: sudo pacman -S go"
  27. exit 1
  28. fi
  29. log "Building dev tool..."
  30. mkdir -p bin
  31. go mod tidy
  32. if go build -ldflags="-s -w" -o "$BINARY" main.go; then
  33. log "✅ Built: $BINARY"
  34. else
  35. error "Build failed"
  36. exit 1
  37. fi
  38. fi
  39. # Run the binary
  40. exec "$BINARY" "$@"