Skip to content

Commit 92c26ec

Browse files
zeroshadelidavidmamoebambrobbeleitsupi
authored
feat(rust/core): add function to load driver manifests (#3099)
Following the pattern of the C++ driver manager and the various bindings to it, we also have to add support for the Rust driver manager to handle and load drivers via manifest files too. Since the Rust driver manager doesn't bind to the C++ one like everyone else, we need to add the support in rust directly to locate, open, and parse driver manifests. This PR adds a new function `ManagedDriver::find_load_from_name` along with constants for the `LoadFlags` to control what paths are searched. The basic logic mirrors the C++ implementation. Unit tests are also included. To control the tests, two new features are added: `driver_manager_test_lib` which expects an env var `ADBC_DRIVER_MANAGER_TEST_LIB` to be set, just like the C++ driver manager tests, to the path for an adbc library to load. And `driver_manager_test_manifest_user` which controls whether the test that interacts with the user's config directory should be run or not. --------- Co-authored-by: David Li <[email protected]> Co-authored-by: Bryce Mecum <[email protected]> Co-authored-by: Matthijs Brobbel <[email protected]> Co-authored-by: eitsupi <[email protected]>
1 parent bcd2d75 commit 92c26ec

File tree

6 files changed

+1335
-391
lines changed

6 files changed

+1335
-391
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ jobs:
127127
if: matrix.os == 'macos-latest'
128128
run: |
129129
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/sqlite/lib:${{ github.workspace }}/local/lib:$DYLD_LIBRARY_PATH" >> "$GITHUB_ENV"
130+
echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/lib/libadbc_driver_sqlite.dylib" >> "$GITHUB_ENV"
130131
- name: Set dynamic linker path
131132
if: matrix.os == 'macos-13'
132133
run: |
133134
echo "DYLD_LIBRARY_PATH=/usr/local/opt/sqlite/lib:${{ github.workspace }}/local/lib:$DYLD_LIBRARY_PATH" >> "$GITHUB_ENV"
135+
echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/lib/libadbc_driver_sqlite.dylib" >> "$GITHUB_ENV"
136+
- name: Set test env var
137+
if: runner.os == 'Linux'
138+
run: echo "ADBC_DRIVER_MANAGER_TEST_LIB=${{ github.workspace }}/local/lib/libadbc_driver_sqlite.so" >> "$GITHUB_ENV"
134139
- name: Set search dir for Snowflake Go lib
135140
run: echo "ADBC_SNOWFLAKE_GO_LIB_DIR=${{ github.workspace }}/local/lib" >> "$GITHUB_ENV"
136141
- name: Clippy

ci/scripts/rust_test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ export LD_LIBRARY_PATH="${cpp_libs_dir}/lib:${LD_LIBRARY_PATH:-}"
2626
export DYLD_LIBRARY_PATH="${cpp_libs_dir}/lib:${DYLD_LIBRARY_PATH:-}"
2727

2828
pushd "${source_dir}"
29+
case "$(uname)" in
30+
Linux) EXT="so" ;;
31+
Darwin) EXT="dylib" ;;
32+
MINGW*|MSYS*) EXT="dll" ;;
33+
esac
34+
export ADBC_DRIVER_MANAGER_TEST_LIB="${cpp_libs_dir}/lib/libadbc_driver_sqlite.${EXT:-}"
2935
cargo test --all-features --workspace
3036
popd

0 commit comments

Comments
 (0)