Files
shooter-demo/tools/emscripten/install.bat
2025-11-29 01:42:48 +08:00

106 lines
2.4 KiB
Batchfile
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.

@echo off
setlocal enabledelayedexpansion
echo ========================================
echo Emscripten 安装脚本 (版本: 3.1.41)
echo ========================================
echo.
:: 设置变量
set EMSCRIPTEN_VERSION=3.1.41
set SCRIPT_DIR=%~dp0
set EMSDK_DIR=%SCRIPT_DIR%emsdk
:: 检查是否已存在 emsdk 目录
if exist "%EMSDK_DIR%" (
echo 检测到已存在的 emsdk 目录...
set /p "choice=是否重新安装? (y/n): "
if /i "!choice!" neq "y" (
goto :install
)
echo 删除现有安装...
rmdir /s /q "%EMSDK_DIR%"
)
:: 检查 Git 是否可用
git --version >nul 2>&1
if %errorlevel% neq 0 (
echo 错误: 未找到 Git请先安装 Git
goto :error
)
:: 检查 Python 是否可用
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo 错误: 未找到 Python请先安装 Python 3.x
goto :error
)
echo 开始下载 Emscripten SDK...
cd /d "%SCRIPT_DIR%"
git clone https://github.com/emscripten-core/emsdk.git
if %errorlevel% neq 0 (
echo 错误: 下载 Emscripten SDK 失败
goto :error
)
:install
echo.
echo 进入 emsdk 目录...
cd "%EMSDK_DIR%"
echo 安装和激活 Emscripten %EMSCRIPTEN_VERSION%...
call emsdk.bat install %EMSCRIPTEN_VERSION%
if %errorlevel% neq 0 (
echo 错误: 安装 Emscripten %EMSCRIPTEN_VERSION% 失败
goto :error
)
echo.
echo 激活 Emscripten %EMSCRIPTEN_VERSION%...
call emsdk.bat activate %EMSCRIPTEN_VERSION%
if %errorlevel% neq 0 (
echo 错误: 激活 Emscripten %EMSCRIPTEN_VERSION% 失败
goto :error
)
echo.
echo 设置环境变量...
call emsdk_env.bat
echo.
echo 验证安装...
call emcc --version
if %errorlevel% neq 0 (
echo 错误: Emscripten 安装验证失败
goto :error
)
echo.
echo ========================================
echo Emscripten %EMSCRIPTEN_VERSION% 安装成功!
echo ========================================
echo.
echo 注意事项:
echo 1. 每次使用前需要运行 setup-env.bat 来设置环境变量
echo 2. 或者手动运行: tools\emscripten\emsdk\emsdk_env.bat
echo.
echo 创建快速设置脚本...
echo @echo off > "%SCRIPT_DIR%setup-env.bat"
echo echo 设置 Emscripten 环境变量... >> "%SCRIPT_DIR%setup-env.bat"
echo call "%EMSDK_DIR%\emsdk_env.bat" >> "%SCRIPT_DIR%setup-env.bat"
echo echo Emscripten 环境已设置完成 >> "%SCRIPT_DIR%setup-env.bat"
echo setup-env.bat 已创建
goto :end
:error
echo.
echo ========================================
echo 安装失败!请检查错误信息
echo ========================================
exit /b 1
:end
echo.
pause