Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ jobs:
run: |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
dotnet test -c Debug --logger "console;verbosity=detailed"
shell: bash
working-directory: ${{ github.workspace }}/csharp
Expand Down Expand Up @@ -218,6 +219,7 @@ jobs:
run: |
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
dotnet test -c Debug --logger "console;verbosity=detailed"
shell: bash
working-directory: ${{ github.workspace }}/csharp
Expand Down Expand Up @@ -307,8 +309,8 @@ jobs:
# C/C++
- name: Build C/C++
run: |
choco install cmake
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0
choco install cmake -y
cmake -B build_artifacts -D CMAKE_BUILD_TYPE=RelWithDebInfo -D USEARCH_BUILD_TEST_CPP=1 -D USEARCH_BUILD_TEST_C=1 -D USEARCH_BUILD_LIB_C=1 -D USEARCH_BUILD_SQLITE=0 -D USEARCH_USE_NUMKONG=1
cmake --build build_artifacts --config RelWithDebInfo
- name: Test C++
run: .\build_artifacts\test_cpp.exe
Expand Down Expand Up @@ -353,11 +355,13 @@ jobs:
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Test .NET
shell: pwsh
run: |
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
$nativeDir = "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
Copy-Item "${{ github.workspace }}\build_artifacts\libusearch_c.dll" -Destination $nativeDir
Copy-Item "${{ github.workspace }}\build_artifacts\numkong.dll" -Destination $nativeDir
dotnet test -c Debug --logger "console;verbosity=detailed"
shell: bash
working-directory: ${{ github.workspace }}/csharp

test_windows_arm:
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ jobs:
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.so" "${{ github.workspace }}/csharp/lib/runtimes/linux-x64/native"

- name: Build C library for MacOS
if: matrix.os == 'macos-15'
Expand All @@ -1146,15 +1147,19 @@ jobs:
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
cp "${{ github.workspace }}/build_artifacts/libusearch_c.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"
cp "${{ github.workspace }}/build_artifacts/numkong/libnumkong.dylib" "${{ github.workspace }}/csharp/lib/runtimes/osx-arm64/native"

- name: Build C library for Windows
if: matrix.os == 'windows-2022'
shell: pwsh
run: |
choco install cmake
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_NUMKONG=0 -DUSEARCH_USE_JEMALLOC=0
choco install cmake -y
cmake -B build_artifacts -DCMAKE_BUILD_TYPE=Release -DUSEARCH_BUILD_TEST_CPP=0 -DUSEARCH_BUILD_TEST_C=0 -DUSEARCH_BUILD_LIB_C=1 -DUSEARCH_USE_OPENMP=0 -DUSEARCH_USE_NUMKONG=1 -DUSEARCH_USE_JEMALLOC=0
cmake --build build_artifacts --config Release
mkdir -p "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
cp "${{ github.workspace }}\build_artifacts\libusearch_c.dll" "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
$nativeDir = "${{ github.workspace }}\csharp\lib\runtimes\win-x64\native"
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
Copy-Item "${{ github.workspace }}\build_artifacts\libusearch_c.dll" -Destination $nativeDir
Copy-Item "${{ github.workspace }}\build_artifacts\numkong.dll" -Destination $nativeDir

- name: Upload Artifacts
uses: actions/upload-artifact@v5
Expand Down Expand Up @@ -1188,6 +1193,15 @@ jobs:
merge-multiple: true
path: ${{ env.USEARCH_LIBS }}

- name: Verify native package inputs
run: |
test -f "${{ env.USEARCH_LIBS }}/runtimes/linux-x64/native/libusearch_c.so"
test -f "${{ env.USEARCH_LIBS }}/runtimes/linux-x64/native/libnumkong.so"
test -f "${{ env.USEARCH_LIBS }}/runtimes/osx-arm64/native/libusearch_c.dylib"
test -f "${{ env.USEARCH_LIBS }}/runtimes/osx-arm64/native/libnumkong.dylib"
test -f "${{ env.USEARCH_LIBS }}/runtimes/win-x64/native/libusearch_c.dll"
test -f "${{ env.USEARCH_LIBS }}/runtimes/win-x64/native/numkong.dll"

- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
Expand Down
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ function (setup_target TARGET_NAME)
if (USEARCH_USE_NUMKONG AND TARGET nk_shared)
target_compile_definitions(${TARGET_NAME} PRIVATE "NK_DYNAMIC_DISPATCH=1")
target_link_libraries(${TARGET_NAME} PRIVATE nk_shared)

# Keep NumKong discoverable both in the build tree (`build/numkong`) and
# after packaging it next to `libusearch_c` in language bindings.
if (APPLE)
set(_USEARCH_NUMKONG_RPATH "@loader_path;@loader_path/numkong")
elseif (UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(_USEARCH_NUMKONG_RPATH "$ORIGIN;$ORIGIN/numkong")
endif ()

if (DEFINED _USEARCH_NUMKONG_RPATH)
set_target_properties(
${TARGET_NAME} PROPERTIES BUILD_RPATH "${_USEARCH_NUMKONG_RPATH}"
INSTALL_RPATH "${_USEARCH_NUMKONG_RPATH}"
)
endif ()
endif ()

endfunction ()
Expand All @@ -394,6 +409,19 @@ if (USEARCH_USE_NUMKONG)

if (TARGET nk_shared)
set_target_properties(nk_shared PROPERTIES ENABLE_EXPORTS ON)

# Windows has no RPATH equivalent, so the dynamic loader only finds
# NumKong reliably when it sits next to the binaries that link it.
if (WIN32)
set_target_properties(
nk_shared
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}"
)
endif ()
endif ()
endif ()

Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ Then, on Windows, copy the library to the CSharp project and run the tests:
```sh
mkdir -p ".\csharp\lib\runtimes\win-x64\native"
cp ".\build_artifacts\libusearch_c.dll" ".\csharp\lib\runtimes\win-x64\native"
cp ".\build_artifacts\numkong.dll" ".\csharp\lib\runtimes\win-x64\native"
cd csharp
dotnet test -c Debug --logger "console;verbosity=detailed"
dotnet test -c Release
Expand All @@ -494,8 +495,10 @@ On Linux, the process is similar:
```sh
mkdir -p "csharp/lib/runtimes/linux-x64/native" # for x86
cp "build_artifacts/libusearch_c.so" "csharp/lib/runtimes/linux-x64/native" # for x86
cp "build_artifacts/numkong/libnumkong.so" "csharp/lib/runtimes/linux-x64/native" # for x86
mkdir -p "csharp/lib/runtimes/linux-arm64/native" # for ARM
cp "build_artifacts/libusearch_c.so" "csharp/lib/runtimes/linux-arm64/native" # for ARM
cp "build_artifacts/numkong/libnumkong.so" "csharp/lib/runtimes/linux-arm64/native" # for ARM
cd csharp
dotnet test -c Debug --logger "console;verbosity=detailed"
dotnet test -c Release
Expand Down
Loading