规范模块目录和第三方依赖结构

This commit is contained in:
zhangshun
2026-06-01 16:57:39 +08:00
parent e8e485b115
commit c2ce29d874
1758 changed files with 187 additions and 102 deletions

View File

@@ -3,8 +3,42 @@
Write-Host "=== 重新构建 WASM 模块 ===" -ForegroundColor Cyan
# 设置环境
$EmsdkPath = "E:\emsdk"
if (-not (Test-Path $EmsdkPath)) {
$emsdkCandidates = @()
if ($env:EMSDK) {
$emsdkCandidates += $env:EMSDK
}
$emsdkCandidates += "E:\emsdk"
$emsdkCandidates += (Join-Path (Split-Path $PSScriptRoot -Parent) "..\emsdk")
$emsdkCandidates += (Join-Path (Split-Path $PSScriptRoot -Parent) "emsdk")
$emccCommand = Get-Command emcc -ErrorAction SilentlyContinue
if ($emccCommand -and $emccCommand.Source) {
$emccSourceDir = Split-Path $emccCommand.Source -Parent
if (Test-Path (Join-Path $emccSourceDir "emcc.ps1")) {
$emsdkCandidates += (Split-Path (Split-Path $emccSourceDir -Parent) -Parent)
}
}
$EmsdkPath = $null
foreach ($candidate in $emsdkCandidates | Select-Object -Unique) {
if (-not [string]::IsNullOrWhiteSpace($candidate)) {
try {
if (Test-Path $candidate) {
$resolvedCandidate = [System.IO.Path]::GetFullPath($candidate)
if (Test-Path (Join-Path $resolvedCandidate "upstream\emscripten\emcc.ps1")) {
$EmsdkPath = $resolvedCandidate
break
}
}
} catch {
continue
}
}
}
if (-not $EmsdkPath) {
Write-Host "[错误] 未找到 Emscripten" -ForegroundColor Red
exit 1
}
@@ -18,7 +52,7 @@ Write-Host "[ ] 编译 WASM 模块(包含完整的运行时方法)..." -Fore
# 完整的编译命令
$compileCmd = @'
emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp -I./src -std=c++17 -s WASM=1 -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_main"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","UTF8ToString","stringToUTF8","lengthBytesUTF8","allocateUTF8","allocate","ALLOC_NORMAL","getValue","setValue"]' -s MODULARIZE=1 -s EXPORT_NAME="createSmartMathModule" -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 -O3 -o public/wasm/smart_math.js
emcc src/math_utils.cpp src/smart_json_wrapper.cpp src/main.cpp -I./include -I./third_party -I./third_party/kdl_parser/include -I./third_party/orocos_kdl/install_wasm/include -I./third_party/eigen3 -std=c++17 -s WASM=1 -s EXPORTED_FUNCTIONS='["_smart_process_json","_smart_get_function_list","_smart_get_function_info","_smart_test_match","_smart_get_version","_smart_free_string","_main"]' -s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","UTF8ToString","stringToUTF8","lengthBytesUTF8","allocateUTF8","allocate","ALLOC_NORMAL","getValue","setValue"]' -s MODULARIZE=1 -s EXPORT_NAME="createSmartMathModule" -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 -O3 -o public/wasm/smart_math.js
'@
Write-Host "执行命令: $compileCmd" -ForegroundColor Gray