Files
aresv2/build_windows.sh
Beyhan Oğur 4362c3b83f first commit
2026-04-26 21:33:39 +03:00

50 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Renk tanımlamaları
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # Renk Yok
echo -e "${BLUE}=== Go Windows Build Script ===${NC}"
# Çıktı klasörünü oluştur
OUTPUT_DIR="builds"
mkdir -p $OUTPUT_DIR
# Ana dosya adı (main.go varsayılır, yoksa ilk argümanı al)
ENTRY_FILE=${1:-"main.go"}
APP_NAME=$(basename $(pwd))
if [ ! -f "$ENTRY_FILE" ]; then
echo -e "${RED}Hata: $ENTRY_FILE bulunamadı!${NC}"
exit 1
fi
echo -e "Derleniyor: ${GREEN}$ENTRY_FILE${NC}"
# Mimari seçimi (Varsayılan amd64)
read -p "Mimari seçin (1: amd64 [Varsayılan], 2: 386): " ARCH_CHOICE
if [[ "$ARCH_CHOICE" == "2" ]]; then
export GOARCH=386
FINAL_NAME="${APP_NAME}_x86.exe"
else
export GOARCH=amd64
FINAL_NAME="${APP_NAME}_x64.exe"
fi
# Derleme işlemi
# -s -w bayrakları dosya boyutunu ciddi oranda küçültür
echo -e "${BLUE}Windows için derleniyor...${NC}"
env GOOS=windows CGO_ENABLED=0 \
go build -ldflags="-s -w" \
-o "$OUTPUT_DIR/$FINAL_NAME" "$ENTRY_FILE"
if [ $? -eq 0 ]; then
echo -e "${GREEN}Başarılı!${NC}"
echo -e "Çıktı: ${BLUE}$OUTPUT_DIR/$FINAL_NAME${NC}"
else
echo -e "${RED}Derleme sırasında bir hata oluştu.${NC}"
fi