# test_compile.ps1 - 测试编译 Write-Host "=== 测试编译 ===" -ForegroundColor Cyan # 设置环境 $EmsdkPath = "E:\emsdk" if (-not (Test-Path $EmsdkPath)) { Write-Host "[错误] 未找到 Emscripten" -ForegroundColor Red exit 1 } $env:PATH = "$EmsdkPath\upstream\emscripten;$env:PATH" # 测试 1: 编译 math_utils.cpp Write-Host "[ ] 测试编译 math_utils.cpp..." -ForegroundColor Cyan emcc src/math_utils.cpp -I./src -s WASM=1 -c -o test_math.o 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "[✓] math_utils.cpp 编译成功" -ForegroundColor Green } else { Write-Host "[✗] math_utils.cpp 编译失败" -ForegroundColor Red } # 测试 2: 编译 smart_json_wrapper.cpp Write-Host "[ ] 测试编译 smart_json_wrapper.cpp..." -ForegroundColor Cyan emcc src/smart_json_wrapper.cpp -I./src -s WASM=1 -c -o test_wrapper.o 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "[✓] smart_json_wrapper.cpp 编译成功" -ForegroundColor Green } else { Write-Host "[✗] smart_json_wrapper.cpp 编译失败" -ForegroundColor Red } # 测试 3: 编译 main.cpp Write-Host "[ ] 测试编译 main.cpp..." -ForegroundColor Cyan emcc src/main.cpp -I./src -s WASM=1 -c -o test_main.o 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "[✓] main.cpp 编译成功" -ForegroundColor Green } else { Write-Host "[✗] main.cpp 编译失败" -ForegroundColor Red } # 清理 Remove-Item test_*.o -ErrorAction SilentlyContinue