minor: fix c example cmake and build c++ dynamic lib (#347)

This commit is contained in:
feihongxu0824
2026-04-20 22:08:34 +08:00
committed by GitHub
parent 1e25294c07
commit bbe4ca7bae
6 changed files with 230 additions and 326 deletions
+12 -1
View File
@@ -411,11 +411,22 @@ jobs:
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build "$EXAMPLES_BUILD" --parallel
# Reuse the shared-library directory from Step 4; push again in
# case Step 4 was skipped or the directory was cleaned.
DEVICE_LIB_DIR="/data/local/tmp/zvec_tests/lib"
adb shell "mkdir -p $DEVICE_LIB_DIR" 2>/dev/null || true
SO_COUNT=0
while IFS= read -r so_file; do
adb push "$so_file" "$DEVICE_LIB_DIR/$(basename "$so_file")" > /dev/null 2>&1
SO_COUNT=$((SO_COUNT + 1))
done < <(find "$BUILD_DIR/lib" -name "*.so" -type f 2>/dev/null)
echo "Pushed $SO_COUNT shared libraries to $DEVICE_LIB_DIR"
for example in ailego-example core-example db-example; do
if [ -f "$EXAMPLES_BUILD/$example" ]; then
echo "=== Running $example ==="
adb push "$EXAMPLES_BUILD/$example" "/data/local/tmp/$example" > /dev/null 2>&1
adb shell "chmod 755 /data/local/tmp/$example && cd /data/local/tmp && ./$example"
adb shell "chmod 755 /data/local/tmp/$example && cd /data/local/tmp && LD_LIBRARY_PATH=$DEVICE_LIB_DIR ./$example"
adb shell "rm -f /data/local/tmp/$example"
fi
done
+24
View File
@@ -97,6 +97,30 @@ jobs:
cd build
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release --parallel $env:NPROC
# Copy zvec.dll next to the example executables so Windows can find it.
# CMake places DLLs in bin/ (RUNTIME output) and import libs in lib/.
$buildDir = "$env:GITHUB_WORKSPACE\build"
$found = $false
foreach ($sub in @("$buildDir\bin", "$buildDir\bin\Release", "$buildDir\lib", "$buildDir\lib\Release")) {
if (Test-Path "$sub\zvec.dll") {
Copy-Item "$sub\zvec.dll" -Destination . -Force
Write-Host "Copied zvec.dll from $sub"
$found = $true
break
}
}
if (-not $found) {
Write-Host "WARNING: zvec.dll not found, searching recursively..."
$dll = Get-ChildItem -Path $buildDir -Filter "zvec.dll" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
if ($dll) {
Copy-Item $dll.FullName -Destination . -Force
Write-Host "Copied zvec.dll from $($dll.DirectoryName)"
} else {
Write-Error "zvec.dll not found anywhere under $buildDir"
}
}
.\db-example.exe
.\core-example.exe
.\ailego-example.exe