Skip to content

Commit 45cf928

Browse files
authored
GH-47787: [C++][FlightRPC] ODBC msi Windows installer (#48054)
### Rationale for this change Implement ODBC installer code for Windows. The primary platform for ODBC is MSVC Windows. The version is set to 1.0.0. ### What changes are included in this PR? - ODBC msi installer - Added components to other parts of Arrow, so we can select ODBC component for cpack ### Are these changes tested? Tested locally on MSVC Windows ### Are there any user-facing changes? N/A * GitHub Issue: #47787 Authored-by: Alina (Xi) Li <alina.li@improving.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 4cc41f4 commit 45cf928

File tree

12 files changed

+299
-7
lines changed

12 files changed

+299
-7
lines changed

.github/workflows/cpp_extra.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ jobs:
346346
ARROW_BUILD_TYPE: release
347347
ARROW_DEPENDENCY_SOURCE: VCPKG
348348
ARROW_FLIGHT_SQL_ODBC: ON
349+
ARROW_FLIGHT_SQL_ODBC_INSTALLER: ON
349350
ARROW_SIMD_LEVEL: AVX2
350351
CMAKE_GENERATOR: Ninja
351352
CMAKE_INSTALL_PREFIX: /usr
@@ -433,7 +434,25 @@ jobs:
433434
# GH-48269 TODO: Enable Flight & Flight SQL testing in MSVC CI
434435
# GH-48547 TODO: enable ODBC tests after GH-48270 and GH-48269 are resolved.
435436

436-
# GH-47787 TODO: Build ODBC installer
437+
- name: Install WiX Toolset
438+
shell: pwsh
439+
run: |
440+
Invoke-WebRequest -Uri https://github.com/wixtoolset/wix/releases/download/v6.0.0/wix-cli-x64.msi -OutFile wix-cli-x64.msi
441+
Start-Process -FilePath wix-cli-x64.msi -ArgumentList '/quiet', 'Include_freethreaded=1' -Wait
442+
echo "C:\Program Files\WiX Toolset v6.0\bin\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
443+
- name: Build MSI ODBC installer
444+
shell: pwsh
445+
run: |
446+
# Verify WiX version
447+
wix --version
448+
cd build/cpp
449+
cpack
450+
- name: Upload the artifacts to the job
451+
uses: actions/upload-artifact@v6
452+
with:
453+
name: flight-sql-odbc-msi-installer
454+
path: build/cpp/Apache Arrow Flight SQL ODBC-*-win64.msi
455+
if-no-files-found: error
437456

438457
report-extra-cpp:
439458
if: github.event_name == 'schedule' && always()

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,6 @@ java/.mvn/.develocity/
107107
# rat
108108
filtered_rat.txt
109109
rat.txt
110+
111+
# for ODBC DLL
112+
*.rc

ci/scripts/cpp_build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ if [ "${ARROW_ENABLE_THREADING:-ON}" = "OFF" ]; then
6565
ARROW_FLIGHT=OFF
6666
ARROW_FLIGHT_SQL=OFF
6767
ARROW_FLIGHT_SQL_ODBC=OFF
68+
ARROW_FLIGHT_SQL_ODBC_INSTALLER=OFF
6869
ARROW_GCS=OFF
6970
ARROW_JEMALLOC=OFF
7071
ARROW_MIMALLOC=OFF
@@ -213,6 +214,7 @@ else
213214
-DARROW_FLIGHT=${ARROW_FLIGHT:-OFF} \
214215
-DARROW_FLIGHT_SQL=${ARROW_FLIGHT_SQL:-OFF} \
215216
-DARROW_FLIGHT_SQL_ODBC=${ARROW_FLIGHT_SQL_ODBC:-OFF} \
217+
-DARROW_FLIGHT_SQL_ODBC_INSTALLER=${ARROW_FLIGHT_SQL_ODBC_INSTALLER:-OFF} \
216218
-DARROW_FUZZING=${ARROW_FUZZING:-OFF} \
217219
-DARROW_GANDIVA_PC_CXX_FLAGS=${ARROW_GANDIVA_PC_CXX_FLAGS:-} \
218220
-DARROW_GANDIVA=${ARROW_GANDIVA:-OFF} \

cpp/CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@
180180
"ARROW_BUILD_EXAMPLES": "ON",
181181
"ARROW_BUILD_UTILITIES": "ON",
182182
"ARROW_FLIGHT_SQL_ODBC": "ON",
183+
"ARROW_FLIGHT_SQL_ODBC_INSTALLER": "ON",
183184
"ARROW_TENSORFLOW": "ON",
184185
"PARQUET_BUILD_EXAMPLES": "ON",
185186
"PARQUET_BUILD_EXECUTABLES": "ON"

cpp/src/arrow/flight/sql/odbc/CMakeLists.txt

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
# GH-44792: Arrow will switch to C++ 20
2020
set(CMAKE_CXX_STANDARD 20)
2121

22-
add_custom_target(arrow_flight_sql_odbc)
23-
2422
if(WIN32)
2523
if(MSVC_VERSION GREATER_EQUAL 1900)
2624
set(ODBCINST legacy_stdio_definitions odbccp32 shlwapi)
@@ -38,10 +36,29 @@ add_subdirectory(tests)
3836

3937
arrow_install_all_headers("arrow/flight/sql/odbc")
4038

39+
# ODBC Release information
40+
# Flight SQL ODBC version uses Arrow version
41+
set(ODBC_PACKAGE_VERSION_MAJOR "${arrow_VERSION_MAJOR}")
42+
set(ODBC_PACKAGE_VERSION_MINOR "${arrow_VERSION_MINOR}")
43+
set(ODBC_PACKAGE_VERSION_PATCH "${arrow_VERSION_PATCH}")
44+
set(ODBC_PACKAGE_NAME "Apache Arrow Flight SQL ODBC")
45+
set(ODBC_PACKAGE_VENDOR "Apache Software Foundation")
46+
4147
set(ARROW_FLIGHT_SQL_ODBC_SRCS entry_points.cc odbc_api.cc)
4248

4349
if(WIN32)
44-
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def)
50+
set(VER_FILEVERSION
51+
"${ODBC_PACKAGE_VERSION_MAJOR},${ODBC_PACKAGE_VERSION_MINOR},${ODBC_PACKAGE_VERSION_PATCH},0"
52+
)
53+
set(VER_FILEVERSION_STR
54+
${ODBC_PACKAGE_VERSION_MAJOR}.${ODBC_PACKAGE_VERSION_MINOR}.${ODBC_PACKAGE_VERSION_PATCH}
55+
)
56+
set(VER_COMPANYNAME_STR ${ODBC_PACKAGE_VENDOR})
57+
set(VER_PRODUCTNAME_STR ${ODBC_PACKAGE_NAME})
58+
59+
configure_file("install/windows/versioninfo.rc.in" "install/versioninfo.rc" @ONLY)
60+
61+
list(APPEND ARROW_FLIGHT_SQL_ODBC_SRCS odbc.def install/versioninfo.rc)
4562
endif()
4663

4764
add_arrow_lib(arrow_flight_sql_odbc
@@ -75,3 +92,73 @@ add_arrow_lib(arrow_flight_sql_odbc
7592
foreach(LIB_TARGET ${ARROW_FLIGHT_SQL_ODBC_LIBRARIES})
7693
target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_FLIGHT_SQL_ODBC_EXPORTING)
7794
endforeach()
95+
96+
# Construct ODBC Windows installer. Only Release installer is supported
97+
if(ARROW_FLIGHT_SQL_ODBC_INSTALLER)
98+
99+
include(InstallRequiredSystemLibraries)
100+
101+
set(CPACK_RESOURCE_FILE_LICENSE
102+
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../LICENSE.txt")
103+
104+
set(CPACK_PACKAGE_VERSION_MAJOR ${ODBC_PACKAGE_VERSION_MAJOR})
105+
set(CPACK_PACKAGE_VERSION_MINOR ${ODBC_PACKAGE_VERSION_MINOR})
106+
set(CPACK_PACKAGE_VERSION_PATCH ${ODBC_PACKAGE_VERSION_PATCH})
107+
108+
set(CPACK_PACKAGE_NAME ${ODBC_PACKAGE_NAME})
109+
set(CPACK_PACKAGE_VENDOR ${ODBC_PACKAGE_VENDOR})
110+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Apache Arrow Flight SQL ODBC Driver")
111+
set(CPACK_PACKAGE_CONTACT "dev@arrow.apache.org")
112+
113+
# GH-47876 TODO: set up `arrow_flight_sql_odbc` component for macOS Installer
114+
# GH-47877 TODO: set up `arrow_flight_sql_odbc` component for Linux Installer
115+
if(WIN32)
116+
# Install ODBC and its Arrow dependencies
117+
install(PROGRAMS ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
118+
DESTINATION bin
119+
COMPONENT arrow_flight_sql_odbc)
120+
install(TARGETS arrow_shared
121+
arrow_compute_shared
122+
arrow_flight_shared
123+
arrow_flight_sql_shared
124+
arrow_flight_sql_odbc_shared
125+
RUNTIME_DEPENDENCIES
126+
PRE_EXCLUDE_REGEXES
127+
"api-ms-.*"
128+
"ext-ms-.*"
129+
POST_EXCLUDE_REGEXES
130+
".*system32/.*\\.dll"
131+
RUNTIME DESTINATION bin COMPONENT arrow_flight_sql_odbc)
132+
133+
set(CPACK_WIX_EXTRA_SOURCES
134+
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-flight-sql-odbc.wxs")
135+
set(CPACK_WIX_PATCH_FILE
136+
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-flight-sql-odbc-patch.xml")
137+
138+
set(CPACK_WIX_UI_BANNER
139+
"${CMAKE_CURRENT_SOURCE_DIR}/install/windows/arrow-wix-banner.bmp")
140+
endif()
141+
142+
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
143+
set(CPACK_COMPONENTS_ALL "arrow_flight_sql_odbc")
144+
145+
if(WIN32)
146+
# WiX msi installer on Windows
147+
# CPack is compatible with WiX V.5 and V.6
148+
set(CPACK_GENERATOR "WIX")
149+
set(CPACK_WIX_VERSION 4)
150+
151+
# Upgrade GUID is required to be unchanged for ODBC installer to upgrade
152+
set(CPACK_WIX_UPGRADE_GUID "DBF27A18-F8BF-423F-9E3A-957414D52C4B")
153+
set(CPACK_WIX_PRODUCT_GUID "279D087B-93B5-4DC3-BA69-BCF485022A26")
154+
endif()
155+
# GH-47876 TODO: create macOS Installer using cpack
156+
# GH-47877 TODO: create Linux Installer using cpack
157+
158+
# Load CPack after all CPACK* variables are set
159+
include(CPack)
160+
cpack_add_component(arrow_flight_sql_odbc
161+
DISPLAY_NAME "ODBC library"
162+
DESCRIPTION "Apache Arrow Flight SQL ODBC library bin, required to install"
163+
REQUIRED)
164+
endif()
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<!---
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
## Steps to Register the 64-bit Apache Arrow ODBC driver on Windows
21+
22+
After the build succeeds, the ODBC DLL will be located in
23+
`build\debug\Debug` for a debug build and `build\release\Release` for a release build.
24+
25+
1. Open Windows Power Shell as administrator.
26+
27+
2. Register your ODBC DLL:
28+
29+
Need to replace <path\to\repo> with actual path to repository in the commands.
30+
1. `cd to repo.`
31+
2. `cd <path\to\repo>`
32+
3. Run script to register your ODBC DLL as Apache Arrow Flight SQL ODBC Driver
33+
```
34+
.\cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd <path\to\repo>\cpp\build\< release | debug >\< Release | Debug>\arrow_flight_sql_odbc.dll
35+
```
36+
Example command for reference:
37+
```
38+
.\cpp\src\arrow\flight\sql\odbc\tests\install_odbc.cmd C:\path\to\arrow\cpp\build\release\Release\arrow_flight_sql_odbc.dll
39+
```
40+
41+
If the registration is successful, then Apache Arrow Flight SQL ODBC Driver
42+
should show as an available ODBC driver in the x64 ODBC Driver Manager.
43+
44+
## Steps to Generate Windows Installer
45+
1. Install WiX toolset v6 from [GitHub](https://github.com/wixtoolset/wix/releases/).
46+
2. Build with `ARROW_FLIGHT_SQL_ODBC=ON` and `ARROW_FLIGHT_SQL_ODBC_INSTALLER=ON`.
47+
3. `cd` to `build` folder.
48+
4. Run `cpack`.
49+
50+
If the generation is successful, you will find `Apache Arrow Flight SQL ODBC-<version>-win64.msi` generated under the `build` folder.
51+
52+
53+
## Steps to Enable Logging
54+
Arrow Flight SQL ODBC driver uses Arrow's internal logging framework. By default, the log messages are printed to the terminal.
55+
1. Set environment variable `ARROW_ODBC_LOG_LEVEL` to any of the following valid values to enable logging. If `ARROW_ODBC_LOG_LEVEL` is set to a non-empty string that does not match any of the following values, `DEBUG` level is used by default.
56+
57+
The characters are case-insensitive.
58+
- TRACE
59+
- DEBUG
60+
- INFO
61+
- WARNING
62+
- ERROR
63+
- FATAL
64+
65+
The Windows ODBC driver currently does not support writing log files. `ARROW_USE_GLOG` is required to write log files, and `ARROW_USE_GLOG` is disabled on Windows platform since plasma using `glog` is not fully tested on windows.
66+
67+
Note: GH-47670 running more than 1 tests with logging enabled is not fully supported.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one or more
3+
contributor license agreements. See the NOTICE file distributed with
4+
this work for additional information regarding copyright ownership.
5+
The ASF licenses this file to You under the Apache License, Version 2.0
6+
(the "License"); you may not use this file except in compliance with
7+
the License. You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<CPackWiXPatch>
19+
<CPackWiXFragment Id="#PRODUCTFEATURE">
20+
<ComponentRef Id="ODBCRegistryEntries"/>
21+
</CPackWiXFragment>
22+
</CPackWiXPatch>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
-->
19+
20+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
21+
<Fragment>
22+
<DirectoryRef Id="TARGETDIR">
23+
<Component Id="ODBCRegistryEntries" Guid="C348B9F7-5E8D-415D-A001-D92F2D4EA013">
24+
<RegistryValue Root='HKLM' Key='Software\ODBC\ODBCINST.INI\ODBC Drivers' Name='Apache Arrow Flight SQL ODBC Driver' Type='string' Value='Installed'/>
25+
26+
<RegistryKey Root="HKLM"
27+
Key="Software\ODBC\ODBCINST.INI\Apache Arrow Flight SQL ODBC Driver">
28+
<!-- CM_FP_arrow_flight_sql_odbc.bin.arrow_flight_sql_odbc.dll is a generated variable value from build\_CPack_Packages\win64\WIX\files.wxs -->
29+
<RegistryValue Type="string" Name="DriverODBCVer" Value="03.00"/>
30+
<RegistryValue Type="string" Name="Driver" Value="[#CM_FP_arrow_flight_sql_odbc.bin.arrow_flight_sql_odbc.dll]"/>
31+
<RegistryValue Type="string" Name="Setup" Value="[#CM_FP_arrow_flight_sql_odbc.bin.arrow_flight_sql_odbc.dll]"/>
32+
<RegistryValue Type="integer" Name="UsageCount" Value="1"/>
33+
</RegistryKey>
34+
</Component>
35+
</DirectoryRef>
36+
</Fragment>
37+
</Wix>
Binary file not shown.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
#define VER_FILEVERSION @VER_FILEVERSION@
19+
#define VER_FILEVERSION_STR "@VER_FILEVERSION_STR@\0"
20+
21+
#define VER_PRODUCTVERSION @VER_FILEVERSION@
22+
#define VER_PRODUCTVERSION_STR "@VER_FILEVERSION_STR@\0"
23+
24+
#define VER_COMPANYNAME_STR "@VER_COMPANYNAME_STR@\0"
25+
#define VER_PRODUCTNAME_STR "@VER_PRODUCTNAME_STR@\0"
26+
27+
1 VERSIONINFO
28+
FILEVERSION VER_FILEVERSION
29+
PRODUCTVERSION VER_PRODUCTVERSION
30+
BEGIN
31+
BLOCK "StringFileInfo"
32+
BEGIN
33+
BLOCK "040904E4"
34+
BEGIN
35+
VALUE "CompanyName", VER_COMPANYNAME_STR
36+
VALUE "FileVersion", VER_FILEVERSION_STR
37+
VALUE "ProductName", VER_PRODUCTNAME_STR
38+
VALUE "ProductVersion", VER_PRODUCTVERSION_STR
39+
END
40+
END
41+
42+
BLOCK "VarFileInfo"
43+
BEGIN
44+
/* The following line should only be modified for localized versions. */
45+
/* It consists of any number of WORD,WORD pairs, with each pair */
46+
/* describing a language,codepage combination supported by the file. */
47+
/* */
48+
/* For example, a file might have values "0x409,1252" indicating that it */
49+
/* supports English language (0x409) in the Windows ANSI codepage (1252). */
50+
51+
VALUE "Translation", 0x409, 1252
52+
53+
END
54+
END

0 commit comments

Comments
 (0)