Spaces:
Paused
Paused
File size: 1,206 Bytes
d3f40ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #!/bin/bash
# 这是一个辅助脚本,用于在终端中手动编译 OpenClaw 为 WASM
# 用法: ./build_wasm.sh
# 确保 Emscripten 环境已激活
source "/opt/emsdk/emsdk_env.sh"
echo "Downloading OpenClaw source..."
git clone https://github.com/pjasicek/OpenClaw.git
cd OpenClaw
# 简单的 Hello World 验证 (可选)
# echo "int main() { return 0; }" > test.c
# emcc test.c -o test.html
# OpenClaw 编译尝试 (这只是一个起点,通常需要修改源码)
# 注意: OpenClaw 依赖 SDL2, SDL2_image, SDL2_mixer, SDL2_ttf
# Emscripten 内置了 SDL2 (-s USE_SDL=2),但其他库需要 port
mkdir -p build_wasm
cd build_wasm
echo "Configuring CMake for WASM..."
emcmake cmake .. \
-DPLATFORM=EMSCRIPTEN \
-DCMAKE_BUILD_TYPE=Release
echo "Building..."
emmake make -j$(nproc)
# 如果编译成功,将结果复制到 Nginx 目录
if [ -f "OpenClaw.html" ]; then
echo "Build successful! Deploying to /var/www/html/game..."
cp OpenClaw.html /var/www/html/game/index.html
cp OpenClaw.js /var/www/html/game/
cp OpenClaw.wasm /var/www/html/game/
cp OpenClaw.data /var/www/html/game/ 2>/dev/null || true
else
echo "Build failed or output file not found."
fi
|