-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Test Rust API on Windows #3385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Rust API on Windows #3385
Changes from all commits
68e9356
d037f83
da1233c
518ea02
8012d45
3a81576
4b46ee2
a5b030b
0483887
2c98a08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -191,6 +191,14 @@ jobs: | |||||
| cp -a build/install/lib $dst/ | ||||||
| cp -a build/install/include $dst/ | ||||||
|
|
||||||
| if [[ $shared_lib == "ON" && -f build/install/lib/onnxruntime.lib ]]; then | ||||||
| cp -v build/install/lib/onnxruntime.lib $dst/lib/ | ||||||
| fi | ||||||
|
|
||||||
| rm -rf $dst/lib/pkgconfig | ||||||
| rm -f $dst/lib/cargs.dll $dst/lib/cargs.lib $dst/lib/cargs.h | ||||||
| rm -f $dst/include/cargs.h | ||||||
|
|
||||||
| ls -lh $dst/bin/ | ||||||
| echo "---" | ||||||
| ls -lh $dst/lib/ | ||||||
|
|
@@ -244,7 +252,7 @@ jobs: | |||||
| file: sherpa-onnx-*-win-x64*.tar.bz2 | ||||||
| repo_name: k2-fsa/sherpa-onnx | ||||||
| repo_token: ${{ secrets.UPLOAD_GH_SHERPA_ONNX_TOKEN }} | ||||||
| tag: v1.12.28 | ||||||
| tag: v1.12.31 | ||||||
|
||||||
| tag: v1.12.31 | |
| tag: ${{ github.ref_name }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -107,3 +107,4 @@ message(STATUS "onnxruntime lib files: ${onnxruntime_lib_files}") | |||||||||||||
|
|
||||||||||||||
| install(FILES ${onnxruntime_lib_files} DESTINATION lib) | ||||||||||||||
| install(FILES ${onnxruntime_lib_files} DESTINATION bin) | ||||||||||||||
| install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib) | ||||||||||||||
|
||||||||||||||
| install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib) | |
| if(EXISTS "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib") | |
| install(FILES "${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib" DESTINATION lib) | |
| else() | |
| message(WARNING "onnxruntime import library not found at '${onnxruntime_SOURCE_DIR}/lib/onnxruntime.lib'; it will not be installed.") | |
| endif() |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,25 +1,88 @@ | ||||||
| # Introduction | ||||||
|
|
||||||
| This folder uses Rust API maintained by us. | ||||||
| This folder contains examples that use the `sherpa-onnx` Rust crate maintained in | ||||||
| this repository. | ||||||
|
|
||||||
| ## Setup library path | ||||||
| ## Setup | ||||||
|
|
||||||
| ### Method 1 (Build from source, support only shared libs right now) | ||||||
| The Rust crate needs to find the sherpa-onnx shared libraries at build time, and | ||||||
| your operating system needs to find them again at run time. | ||||||
|
|
||||||
| There are two common ways to do that: | ||||||
|
|
||||||
| - Method 1: Build sherpa-onnx from source and use the generated shared libraries | ||||||
| - Method 2: Download a prebuilt sherpa-onnx shared-library package from GitHub releases | ||||||
|
|
||||||
| ### Method 1: Build from source | ||||||
|
|
||||||
| Build and install sherpa-onnx first. After that, point `SHERPA_ONNX_LIB_DIR` to | ||||||
| the generated `lib` directory. | ||||||
|
|
||||||
| #### Linux | ||||||
|
|
||||||
| ```bash | ||||||
| export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/build/install/lib | ||||||
| export RUSTFLAGS="-C link-arg=-Wl,-rpath,$SHERPA_ONNX_LIB_DIR" | ||||||
| ``` | ||||||
|
|
||||||
| #### macOS | ||||||
|
|
||||||
| ```bash | ||||||
| export SHERPA_ONNX_LIB_DIR=/Users/fangjun/open-source/sherpa-onnx/build/install/lib | ||||||
| export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/build/install/lib | ||||||
| export RUSTFLAGS="-C link-arg=-Wl,-rpath,$SHERPA_ONNX_LIB_DIR" | ||||||
| ``` | ||||||
|
|
||||||
| ### Method 2 (Download pre-built libs) | ||||||
| #### Windows | ||||||
|
|
||||||
| ```bash | ||||||
| export SHERPA_ONNX_LIB_DIR=/path/to/sherpa-onnx/build/install/lib | ||||||
| export PATH="$SHERPA_ONNX_LIB_DIR:$PATH" | ||||||
| ``` | ||||||
|
|
||||||
| If Windows still reports that it cannot find a DLL, or if it loads a wrong | ||||||
| `onnxruntime.dll`, copy the DLL files from `%SHERPA_ONNX_LIB_DIR%` to the same | ||||||
|
||||||
| `onnxruntime.dll`, copy the DLL files from `%SHERPA_ONNX_LIB_DIR%` to the same | |
| `onnxruntime.dll`, copy the DLL files from `$SHERPA_ONNX_LIB_DIR` to the same |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| notes.md | ||
| target | ||
| Cargo.lock |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,8 +21,9 @@ fn main() { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Link the dynamic libraries regardless (cargo will fail later if not found) | ||||||
| // Always link against the public sherpa-onnx C API import library. | ||||||
|
||||||
| // Always link against the public sherpa-onnx C API import library. | |
| // Always link against the public sherpa-onnx C API shared library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cp -v "$SHERPA_ONNX_LIB_DIR"/*.dll ...will fail the step when no DLLs exist in$SHERPA_ONNX_LIB_DIR(very common if DLLs live underbin/in the archive). Guard the copy (e.g., check for matches / enablenullglob) and/or copy from the directory that actually contains the DLLs (often$PWD/$d/bin) to avoid spurious CI failures.