#!/bin/bash # OnlineRpg 构建脚本 (Linux/Unix) # 使用方法: ./build.sh echo "================================================" echo " OnlineRpg Build Script (Linux/Unix)" echo "================================================" echo "" # 检查 CMake 是否安装 if ! command -v cmake &> /dev/null; then echo "[ERROR] CMake not found! Please install CMake first." exit 1 fi echo "[INFO] CMake version:" cmake --version echo "" # 创建 build 目录 if [ ! -d "build" ]; then echo "[INFO] Creating build directory..." mkdir build fi # 进入 build 目录 cd build # 配置项目 echo "[INFO] Configuring project with CMake..." cmake .. -DCMAKE_BUILD_TYPE=Release if [ $? -ne 0 ]; then echo "[ERROR] CMake configuration failed!" cd .. exit 1 fi echo "" echo "[INFO] Building project..." make -j$(nproc) if [ $? -ne 0 ]; then echo "[ERROR] Build failed!" cd .. exit 1 fi echo "" echo "[SUCCESS] Build completed successfully!" echo "" echo "Executables are located in: build/bin/" echo " - server" echo " - client" echo "" cd .. echo "To run the server: ./build/bin/server" echo "To run the client: ./build/bin/client"