You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/bin/bash
# 编译Web版本脚本
echo "正在编译Web版本..."
# 检查gson库
if [ ! -f "lib/gson-2.10.1.jar" ]; then
echo "📦 正在下载Gson库..."
mkdir -p lib
if command -v wget &> /dev/null; then
wget -q -O lib/gson-2.10.1.jar https://repo1.maven.org/maven2/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar
elif command -v curl &> /dev/null; then
curl -s -o lib/gson-2.10.1.jar https://repo1.maven.org/maven2/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar
else
echo "❌ 需要wget或curl来下载依赖"
echo "请手动下载: https://repo1.maven.org/maven2/com/google/code/gson/gson/2.10.1/gson-2.10.1.jar"
echo "保存到: lib/gson-2.10.1.jar"
exit 1
fi
if [ ! -f "lib/gson-2.10.1.jar" ]; then
echo "❌ 下载失败请手动下载gson-2.10.1.jar到lib目录"
exit 1
fi
echo "✅ Gson库下载成功"
fi
# 创建输出目录
mkdir -p bin
# 编译WebSocket服务器
javac -cp "lib/gson-2.10.1.jar" -d bin -encoding UTF-8 \
src/common/Message.java \
src/common/MessageType.java \
src/server/WebSocketServer.java \
src/server/WebSocketClient.java
if [ $? -eq 0 ]; then
echo "✅ 编译成功!"
echo "输出目录: bin/"
else
echo "❌ 编译失败!"
exit 1
fi