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

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

@@ -94,27 +94,24 @@ $compileResult = emcc `
src/utils.cpp `
src/math_utils.cpp `
src/smart_json_wrapper.cpp `
src/kdl_parser/src/kdl_parser.cpp `
src/kdl_parser/src/joint.cpp `
src/kdl_parser/src/link.cpp `
src/kdl_parser/src/model.cpp `
src/kdl_parser/src/pose.cpp `
src/kdl_parser/src/tinystr.cpp `
src/kdl_parser/src/tinyxml.cpp `
src/kdl_parser/src/tinyxml2.cpp `
src/kdl_parser/src/tinyxmlerror.cpp `
src/kdl_parser/src/tinyxmlparser.cpp `
src/kdl_parser/src/twist.cpp `
src/kdl_parser/src/world.cpp `
-I./inc `
-I./inc/QuadrupedRobotSimulation `
-I./inc/FourBarMechanism `
-I./inc/SharedGeometry `
-I./src/kdl_parser/include `
-I./KDL/install_wasm/include `
-I./Eigen3 `
-I./Eigen3/eigen3 `
-L./KDL/install_wasm/lib `
third_party/kdl_parser/src/kdl_parser.cpp `
third_party/kdl_parser/src/joint.cpp `
third_party/kdl_parser/src/link.cpp `
third_party/kdl_parser/src/model.cpp `
third_party/kdl_parser/src/pose.cpp `
third_party/kdl_parser/src/tinystr.cpp `
third_party/kdl_parser/src/tinyxml.cpp `
third_party/kdl_parser/src/tinyxml2.cpp `
third_party/kdl_parser/src/tinyxmlerror.cpp `
third_party/kdl_parser/src/tinyxmlparser.cpp `
third_party/kdl_parser/src/twist.cpp `
third_party/kdl_parser/src/world.cpp `
-I./include `
-I./third_party `
-I./third_party/kdl_parser/include `
-I./third_party/orocos_kdl/install_wasm/include `
-I./third_party/eigen3 `
-L./third_party/orocos_kdl/install_wasm/lib `
-lorocos-kdl `
-std=c++17 `
-s WASM=1 `

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

View File

@@ -3,17 +3,60 @@
Write-Host "=== 测试编译 ===" -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
}
$env:PATH = "$EmsdkPath\upstream\emscripten;$env:PATH"
# 公共包含目录
$includeArgs = @(
'-I./include',
'-I./third_party',
'-I./third_party/kdl_parser/include',
'-I./third_party/orocos_kdl/install_wasm/include',
'-I./third_party/eigen3'
)
# 测试 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
emcc src/math_utils.cpp @includeArgs -s WASM=1 -c -o test_math.o 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "[✓] math_utils.cpp 编译成功" -ForegroundColor Green
} else {
@@ -22,7 +65,7 @@ if ($LASTEXITCODE -eq 0) {
# 测试 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
emcc src/smart_json_wrapper.cpp @includeArgs -s WASM=1 -c -o test_wrapper.o 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "[✓] smart_json_wrapper.cpp 编译成功" -ForegroundColor Green
} else {
@@ -31,7 +74,7 @@ if ($LASTEXITCODE -eq 0) {
# 测试 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
emcc src/main.cpp @includeArgs -s WASM=1 -c -o test_main.o 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "[✓] main.cpp 编译成功" -ForegroundColor Green
} else {