|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# graph-tool-call PyInstaller sidecar 빌드 스크립트 |
| 4 | +# Tauri externalBin 규칙: binaries/{name}-{target_triple} |
| 5 | + |
| 6 | +set -e |
| 7 | + |
| 8 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 9 | +PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" |
| 10 | +BINARIES_DIR="$PROJECT_ROOT/src-tauri/binaries" |
| 11 | +GRAPH_TOOL_CALL_DIR="${GRAPH_TOOL_CALL_DIR:-$HOME/projects/app/graph-tool-call}" |
| 12 | + |
| 13 | +# 색상 정의 |
| 14 | +GREEN='\033[0;32m' |
| 15 | +YELLOW='\033[1;33m' |
| 16 | +RED='\033[0;31m' |
| 17 | +NC='\033[0m' |
| 18 | + |
| 19 | +print_step() { echo -e "\n${GREEN}==== $1 ====${NC}\n"; } |
| 20 | +print_warn() { echo -e "${YELLOW}[WARN] $1${NC}"; } |
| 21 | +print_error() { echo -e "${RED}[ERROR] $1${NC}"; } |
| 22 | + |
| 23 | +# Tauri target triple 감지 |
| 24 | +get_target_triple() { |
| 25 | + local arch=$(uname -m) |
| 26 | + local os=$(uname -s) |
| 27 | + |
| 28 | + case "$os" in |
| 29 | + Linux) |
| 30 | + case "$arch" in |
| 31 | + x86_64) echo "x86_64-unknown-linux-gnu" ;; |
| 32 | + aarch64) echo "aarch64-unknown-linux-gnu" ;; |
| 33 | + *) print_error "Unsupported arch: $arch"; exit 1 ;; |
| 34 | + esac |
| 35 | + ;; |
| 36 | + Darwin) |
| 37 | + case "$arch" in |
| 38 | + x86_64) echo "x86_64-apple-darwin" ;; |
| 39 | + arm64) echo "aarch64-apple-darwin" ;; |
| 40 | + *) print_error "Unsupported arch: $arch"; exit 1 ;; |
| 41 | + esac |
| 42 | + ;; |
| 43 | + MINGW*|MSYS*|CYGWIN*) |
| 44 | + echo "x86_64-pc-windows-msvc" |
| 45 | + ;; |
| 46 | + *) |
| 47 | + print_error "Unsupported OS: $os" |
| 48 | + exit 1 |
| 49 | + ;; |
| 50 | + esac |
| 51 | +} |
| 52 | + |
| 53 | +TARGET_TRIPLE=$(get_target_triple) |
| 54 | +BINARY_NAME="graph-tool-call-${TARGET_TRIPLE}" |
| 55 | + |
| 56 | +print_step "graph-tool-call sidecar 빌드 (target: ${TARGET_TRIPLE})" |
| 57 | + |
| 58 | +# 1. graph-tool-call 소스 확인 |
| 59 | +if [ ! -d "$GRAPH_TOOL_CALL_DIR" ]; then |
| 60 | + print_error "graph-tool-call 소스가 없습니다: $GRAPH_TOOL_CALL_DIR" |
| 61 | + print_warn "GRAPH_TOOL_CALL_DIR 환경변수로 경로를 지정하세요." |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | + |
| 65 | +# 2. PyInstaller 확인 |
| 66 | +if ! command -v pyinstaller &> /dev/null; then |
| 67 | + print_warn "PyInstaller가 없습니다. 설치 중..." |
| 68 | + pip install pyinstaller |
| 69 | +fi |
| 70 | + |
| 71 | +# 3. PyInstaller 빌드 |
| 72 | +print_step "PyInstaller 빌드" |
| 73 | +cd "$GRAPH_TOOL_CALL_DIR" |
| 74 | + |
| 75 | +pyinstaller \ |
| 76 | + --onefile \ |
| 77 | + --name graph-tool-call \ |
| 78 | + --collect-submodules graph_tool_call \ |
| 79 | + --strip \ |
| 80 | + --noconfirm \ |
| 81 | + --distpath "$GRAPH_TOOL_CALL_DIR/dist" \ |
| 82 | + graph_tool_call/__main__.py |
| 83 | + |
| 84 | +# 4. 빌드 결과 검증 |
| 85 | +BUILT_BINARY="$GRAPH_TOOL_CALL_DIR/dist/graph-tool-call" |
| 86 | +if [ ! -f "$BUILT_BINARY" ]; then |
| 87 | + print_error "빌드 실패: $BUILT_BINARY 가 없습니다." |
| 88 | + exit 1 |
| 89 | +fi |
| 90 | + |
| 91 | +# 버전 확인 |
| 92 | +VERSION=$("$BUILT_BINARY" --version 2>&1 || true) |
| 93 | +echo "빌드된 바이너리: $VERSION" |
| 94 | + |
| 95 | +# 5. Tauri binaries 디렉토리로 복사 |
| 96 | +print_step "Tauri sidecar 배치" |
| 97 | +mkdir -p "$BINARIES_DIR" |
| 98 | +cp "$BUILT_BINARY" "$BINARIES_DIR/$BINARY_NAME" |
| 99 | +chmod +x "$BINARIES_DIR/$BINARY_NAME" |
| 100 | + |
| 101 | +BINARY_SIZE=$(du -h "$BINARIES_DIR/$BINARY_NAME" | cut -f1) |
| 102 | + |
| 103 | +echo "" |
| 104 | +echo -e "${GREEN}✅ 빌드 완료!${NC}" |
| 105 | +echo " 바이너리: $BINARIES_DIR/$BINARY_NAME" |
| 106 | +echo " 크기: $BINARY_SIZE" |
| 107 | +echo " 버전: $VERSION" |
| 108 | +echo "" |
| 109 | +echo "Tauri 앱 빌드 시 자동으로 번들됩니다." |
0 commit comments