Skip to content

Commit 8e1b028

Browse files
zeroshadekoupaleolimbotlidavidm
authored
feat(c/driver_manager): add new function to allow loading by manifest (#2918)
Following the discussions on the mailing list and on https://docs.google.com/document/d/1ANeoDI7MCi9xFt_q8z726xKweWS2vgqO8Ut6BSTt5zM/edit?tab=t.0#heading=h.rd6unnsl7uy this PR implements the proposed behavior by adding a new function to the driver manager rather than changing the existing AdbcLoadDriver (for now). The new function, `AdbcFindLoadDriver` adds a parameter for LoadOptions along with behavior to search directories at multiple levels (environment, user, system) to search for either a manifest or a driver library. This should improve the developer experience and make it easier for users and applications to leverage the driver manager. --------- Co-authored-by: Sutou Kouhei <kou@cozmixng.org> Co-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Dewey Dunnington <dewey@dunnington.ca> Co-authored-by: David Li <li.davidm96@gmail.com>
1 parent eba5235 commit 8e1b028

File tree

36 files changed

+19579
-81
lines changed

36 files changed

+19579
-81
lines changed

.github/workflows/native-unix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ jobs:
194194
BUILD_DRIVER_MANAGER: "1"
195195
BUILD_DRIVER_POSTGRESQL: "1"
196196
BUILD_DRIVER_SQLITE: "1"
197+
ADBC_DRIVER_MANAGER_USER_CONFIG_TEST: "1"
197198
run: |
198199
./ci/scripts/cpp_build.sh "$(pwd)" "$(pwd)/build"
199200
- name: Test

.github/workflows/native-windows.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
BUILD_DRIVER_BIGQUERY: "0"
9898
BUILD_DRIVER_FLIGHTSQL: "0"
9999
BUILD_DRIVER_SNOWFLAKE: "0"
100+
BUILD_DRIVER_MANAGER_USER_CONFIG_TEST: "1"
100101
run: |
101102
.\ci\scripts\cpp_build.ps1 $pwd ${{ github.workspace }}\build
102103
@@ -149,6 +150,7 @@ jobs:
149150
env:
150151
BUILD_ALL: "0"
151152
BUILD_DRIVER_MANAGER: "1"
153+
BUILD_DRIVER_MANAGER_USER_CONFIG_TEST: "1"
152154
run: .\ci\scripts\cpp_build.ps1 $pwd $pwd\build
153155
- name: Build Driver PostgreSQL
154156
env:
@@ -164,6 +166,7 @@ jobs:
164166
env:
165167
BUILD_ALL: "0"
166168
BUILD_DRIVER_MANAGER: "1"
169+
BUILD_DRIVER_MANAGER_USER_CONFIG_TEST: "1"
167170
run: .\ci\scripts\cpp_test.ps1 $pwd\build
168171
- name: Test Driver SQLite
169172
env:

.github/workflows/packaging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ jobs:
907907
shell: cmd
908908
run: |
909909
where python.exe
910-
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
910+
CALL "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
911911
pushd adbc
912912
set SETUPTOOLS_SCM_PRETEND_VERSION=%VERSION%
913913
.\ci\scripts\python_wheel_windows_build.bat %cd% %cd%\build

LICENSE.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,31 @@ public domain, released using the CC0 1.0 Universal dedication (*).
229229

230230
--------------------------------------------------------------------------------
231231

232+
The files in c/vendor/toml++ contain code from
233+
234+
https://github.com/marzer/tomlplusplus
235+
236+
and have the following copyright notice:
237+
238+
MIT License
239+
240+
Copyright (c) Mark Gillard <mark.gillard@outlook.com.au>
241+
242+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
243+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
244+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
245+
permit persons to whom the Software is furnished to do so, subject to the following conditions:
246+
247+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
248+
Software.
249+
250+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
251+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
252+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
253+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
254+
255+
--------------------------------------------------------------------------------
256+
232257
The files python/*/*/_version.py and python/*/*/_static_version.py
233258
contain code from
234259

c/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
cmake_minimum_required(VERSION 3.18)
1919
get_filename_component(REPOSITORY_ROOT ".." ABSOLUTE)
2020
list(APPEND CMAKE_MODULE_PATH "${REPOSITORY_ROOT}/c/cmake_modules/")
21-
include(AdbcDefines)
22-
include(BuildUtils)
21+
include(AdbcVersion)
2322
project(adbc
2423
VERSION "${ADBC_BASE_VERSION}"
2524
LANGUAGES C CXX)
2625
set(CMAKE_C_STANDARD 99)
2726
set(CMAKE_CXX_STANDARD 17)
2827
set(CMAKE_CXX_STANDARD_REQUIRED ON)
28+
include(AdbcDefines)
29+
include(BuildUtils)
2930

3031
include(CTest)
3132

c/cmake_modules/AdbcDefines.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ enable_language(C CXX)
2222

2323
set(BUILD_SUPPORT_DIR "${REPOSITORY_ROOT}/ci/build_support")
2424

25-
include(AdbcVersion)
2625
include(CheckLinkerFlag)
2726
include(DefineOptions)
2827
include(GNUInstallDirs) # Populates CMAKE_INSTALL_INCLUDEDIR
@@ -92,6 +91,8 @@ if(MSVC)
9291
add_compile_options(/wd4711)
9392
# Don't warn about padding added after members
9493
add_compile_options(/wd4820)
94+
# Don't warn about enforcing left-to-right evaluation order for operator[]
95+
add_compile_options(/wd4866)
9596
add_compile_options(/wd5027)
9697
add_compile_options(/wd5039)
9798
add_compile_options(/wd5045)

c/cmake_modules/BuildUtils.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function(ADD_ARROW_LIB LIB_NAME)
199199

200200
if(BUILD_SHARED)
201201
add_library(${LIB_NAME}_shared SHARED ${LIB_DEPS})
202-
target_compile_features(${LIB_NAME}_shared PRIVATE cxx_std_11)
202+
target_compile_features(${LIB_NAME}_shared PRIVATE cxx_std_17)
203203
set_property(TARGET ${LIB_NAME}_shared PROPERTY CXX_STANDARD_REQUIRED ON)
204204
adbc_configure_target(${LIB_NAME}_shared)
205205
if(EXTRA_DEPS)

c/cmake_modules/DefineOptions.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
139139
"shared"
140140
"static")
141141

142+
define_option(ADBC_DRIVER_MANAGER_TEST_MANIFEST_USER_LEVEL
143+
"Build driver manager manifest user-level tests" OFF)
144+
145+
define_option(ADBC_DRIVER_MANAGER_TEST_MANIFEST_SYSTEM_LEVEL
146+
"Build driver manager manifest system-level tests" OFF)
147+
142148
#----------------------------------------------------------------------
143149
set_option_category("Lint")
144150

c/driver_manager/CMakeLists.txt

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,34 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18+
set(ADBC_DRIVER_MANAGER_SHARED_LINK_LIBS ${CMAKE_DL_LIBS})
19+
set(ADBC_DRIVER_MANAGER_STATIC_LINK_LIBS ${CMAKE_DL_LIBS})
20+
# std::filesystem with old g++/clang++ require libstdc++fs/libc++fs.
21+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
22+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9")
23+
list(APPEND ADBC_DRIVER_MANAGER_SHARED_LINK_LIBS stdc++fs)
24+
list(APPEND ADBC_DRIVER_MANAGER_STATIC_LINK_LIBS stdc++fs)
25+
endif()
26+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
27+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8")
28+
list(APPEND ADBC_DRIVER_MANAGER_SHARED_LINK_LIBS c++fs)
29+
list(APPEND ADBC_DRIVER_MANAGER_STATIC_LINK_LIBS c++fs)
30+
endif()
31+
endif()
32+
33+
if(WIN32)
34+
list(APPEND
35+
ADBC_DRIVER_MANAGER_SHARED_LINK_LIBS
36+
advapi32
37+
uuid
38+
shell32)
39+
list(APPEND
40+
ADBC_DRIVER_MANAGER_STATIC_LINK_LIBS
41+
advapi32
42+
uuid
43+
shell32)
44+
endif()
45+
1846
add_arrow_lib(adbc_driver_manager
1947
SOURCES
2048
adbc_driver_manager.cc
@@ -25,9 +53,9 @@ add_arrow_lib(adbc_driver_manager
2553
PKG_CONFIG_NAME
2654
adbc-driver-manager
2755
SHARED_LINK_LIBS
28-
${CMAKE_DL_LIBS}
56+
${ADBC_DRIVER_MANAGER_SHARED_LINK_LIBS}
2957
STATIC_LINK_LIBS
30-
${CMAKE_DL_LIBS}
58+
${ADBC_DRIVER_MANAGER_STATIC_LINK_LIBS}
3159
SHARED_LINK_FLAGS
3260
${ADBC_LINK_FLAGS})
3361

@@ -62,6 +90,20 @@ if(ADBC_BUILD_TESTS)
6290
adbc_validation
6391
${TEST_LINK_LIBS})
6492
target_compile_features(adbc-driver-manager-test PRIVATE cxx_std_17)
93+
94+
if(ADBC_DRIVER_SQLITE)
95+
target_compile_definitions(adbc-driver-manager-test
96+
PRIVATE ADBC_DRIVER_MANAGER_TEST_LIB="${CMAKE_BINARY_DIR}/driver/sqlite/libadbc_driver_sqlite${CMAKE_SHARED_LIBRARY_SUFFIX}"
97+
)
98+
endif()
99+
if(ADBC_DRIVER_MANAGER_TEST_MANIFEST_USER_LEVEL)
100+
target_compile_definitions(adbc-driver-manager-test
101+
PRIVATE ADBC_DRIVER_MANAGER_TEST_MANIFEST_USER_LEVEL=1)
102+
endif()
103+
if(ADBC_DRIVER_MANAGER_TEST_MANIFEST_SYSTEM_LEVEL)
104+
target_compile_definitions(adbc-driver-manager-test
105+
PRIVATE ADBC_DRIVER_MANAGER_TEST_MANIFEST_SYSTEM_LEVEL=1)
106+
endif()
65107
target_include_directories(adbc-driver-manager-test SYSTEM
66108
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
67109
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)

0 commit comments

Comments
 (0)