Skip to content
Open
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
94 changes: 94 additions & 0 deletions .github/actions/odbc-mac/action.yml
Comment thread
alinaliBQ marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: ODBC macOS Reusable
description: Install dependencies and build the Flight SQL ODBC driver on macOS
inputs:
architecture:
description: 'Architecture to build for (AMD64 or ARM64)'
required: true
generate-installer:
description: 'Whether to run cpack to generate the .pkg installer after the build'
required: false
default: 'false'
runs:
using: "composite"
steps:
- name: Install Dependencies
shell: bash
run: |
brew bundle --file=cpp/Brewfile

# We want to use bundled RE2 for static linking. If
# Homebrew's RE2 is installed, its header file may be used.
# We uninstall Homebrew's RE2 to ensure using bundled RE2.
brew uninstall grpc || : # gRPC depends on RE2
brew uninstall grpc@1.54 || : # gRPC 1.54 may be installed too
brew uninstall re2

# We want to use bundled Protobuf for static linking. If
# Homebrew's Protobuf is installed, its library file may be
# used on test. We uninstall Homebrew's Protobuf to ensure using
# bundled Protobuf.
brew uninstall protobuf

# We want to use bundled Boost for static linking.
brew uninstall boost
- name: Setup ccache
shell: bash
run: |
ci/scripts/ccache_setup.sh
- name: ccache info
id: ccache-info
shell: bash
run: |
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
- name: Restore ccache
uses: apache/infrastructure-actions/stash/restore@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5
with:
path: ${{ steps.ccache-info.outputs.cache-dir }}
key: cpp-odbc-ccache-macos-${{ inputs.architecture }}-${{ env.ARROW_BUILD_TYPE }}
- name: Build
shell: bash
run: |
# Homebrew uses /usr/local as prefix. So packages
# installed by Homebrew also use /usr/local/include. We
# want to include headers for packages installed by
# Homebrew as system headers to ignore warnings in them.
# But "-isystem /usr/local/include" isn't used by CMake
# because /usr/local/include is marked as the default
# include path. So we disable -Werror to avoid build error
# by warnings from packages installed by Homebrew.
export BUILD_WARNING_LEVEL=PRODUCTION
LIBIODBC_DIR="$(brew --cellar libiodbc)/$(brew list --versions libiodbc | awk '{print $2}')"
ODBC_INCLUDE_DIR=$LIBIODBC_DIR/include
export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR"
export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR"
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
- name: Save ccache
if: ${{ !cancelled() }}
continue-on-error: true
uses: apache/infrastructure-actions/stash/save@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5
with:
path: ${{ steps.ccache-info.outputs.cache-dir }}
key: cpp-odbc-ccache-macos-${{ inputs.architecture }}-${{ env.ARROW_BUILD_TYPE }}
- name: Generate macOS Installer
if: inputs.generate-installer == 'true'
shell: bash
run: |
cd build/cpp
cpack
4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
directories:
- "/"
- "/.github/actions/*"
schedule:
interval: "weekly"
commit-message:
Expand Down
118 changes: 34 additions & 84 deletions .github/workflows/cpp_extra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ on:
- 'ci/scripts/install_gcs_testbench.sh'
- 'ci/scripts/install_minio.sh'
- 'ci/scripts/msys2_*'
- 'ci/scripts/odbc_macos_universal_pkg.sh'
- 'ci/scripts/util_*'
- 'cpp/**'
- 'compose.yaml'
Expand Down Expand Up @@ -576,60 +577,10 @@ jobs:
persist-credentials: false
fetch-depth: 0
submodules: recursive
- name: Install Dependencies
run: |
brew bundle --file=cpp/Brewfile

# We want to use bundled RE2 for static linking. If
# Homebrew's RE2 is installed, its header file may be used.
# We uninstall Homebrew's RE2 to ensure using bundled RE2.
brew uninstall grpc || : # gRPC depends on RE2
brew uninstall grpc@1.54 || : # gRPC 1.54 may be installed too
brew uninstall re2

# We want to use bundled Protobuf for static linking. If
# Homebrew's Protobuf is installed, its library file may be
# used on test We uninstall Homebrew's Protobuf to ensure using
# bundled Protobuf.
brew uninstall protobuf

# We want to use bundled Boost for static linking.
brew uninstall boost
- name: Setup ccache
run: |
ci/scripts/ccache_setup.sh
- name: ccache info
id: ccache-info
run: |
echo "cache-dir=$(ccache --get-config cache_dir)" >> $GITHUB_OUTPUT
- name: Restore ccache
uses: apache/infrastructure-actions/stash/restore@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5
- name: Build ODBC macOS
uses: ./.github/actions/odbc-mac
with:
path: ${{ steps.ccache-info.outputs.cache-dir }}
key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}
- name: Build
run: |
# Homebrew uses /usr/local as prefix. So packages
# installed by Homebrew also use /usr/local/include. We
# want to include headers for packages installed by
# Homebrew as system headers to ignore warnings in them.
# But "-isystem /usr/local/include" isn't used by CMake
# because /usr/local/include is marked as the default
# include path. So we disable -Werror to avoid build error
# by warnings from packages installed by Homebrew.
export BUILD_WARNING_LEVEL=PRODUCTION
LIBIODBC_DIR="$(brew --cellar libiodbc)/$(brew list --versions libiodbc | awk '{print $2}')"
ODBC_INCLUDE_DIR=$LIBIODBC_DIR/include
export ARROW_CMAKE_ARGS="-DODBC_INCLUDE_DIR=$ODBC_INCLUDE_DIR"
export CXXFLAGS="$CXXFLAGS -I$ODBC_INCLUDE_DIR"
ci/scripts/cpp_build.sh $(pwd) $(pwd)/build
- name: Save ccache
if: ${{ !cancelled() }}
continue-on-error: true
uses: apache/infrastructure-actions/stash/save@762a01f36a09ab9e0e4c8af8f4b0f2ed12683df5
with:
path: ${{ steps.ccache-info.outputs.cache-dir }}
key: cpp-odbc-ccache-macos-${{ matrix.macos-version }}-${{ matrix.build-type }}
architecture: ${{ matrix.architecture }}
- name: Setup Python
uses: actions/setup-python@v7
with:
Expand Down Expand Up @@ -661,12 +612,18 @@ jobs:
name: flight-sql-odbc-pkg-installer-${{ matrix.architecture }}
path: build/cpp/ArrowFlightSQLODBC-*.pkg
if-no-files-found: error
- name: Upload AMD64 ODBC dylib to the job
if: matrix.build-type == 'release' && matrix.architecture == 'AMD64'
- name: Copy ODBC dylib
if: matrix.build-type == 'release'
run: |
mkdir ${{ matrix.architecture }}-dylib
cp "$(realpath build/cpp/${{ matrix.build-type }}/libarrow_flight_sql_odbc.dylib)" \
${{ matrix.architecture }}-dylib/
- name: Upload ODBC dylib to the job
if: matrix.build-type == 'release'
uses: actions/upload-artifact@v7
with:
name: flight-sql-odbc-dylib-${{ matrix.architecture }}
path: build/cpp/${{ matrix.build-type }}/libarrow_flight_sql_odbc.dylib
path: ${{ matrix.architecture }}-dylib/libarrow_flight_sql_odbc.*.dylib
if-no-files-found: error
- name: Register Flight SQL ODBC Driver
run: |
Expand All @@ -688,53 +645,46 @@ jobs:
runs-on: macos-26
timeout-minutes: 30
steps:
- name: Checkout Arrow
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download ARM64 PKG
uses: actions/download-artifact@v8
with:
name: flight-sql-odbc-pkg-installer-ARM64
path: arm64-pkg
- name: Download ARM64 dylib
uses: actions/download-artifact@v8
with:
name: flight-sql-odbc-dylib-ARM64
path: arm64-dylib
- name: Download AMD64 dylib
uses: actions/download-artifact@v8
with:
name: flight-sql-odbc-dylib-AMD64
path: amd64-dylib
- name: Create universal dylib
run: |
set -euo pipefail

arm64_dylib="$(ls arm64-dylib/libarrow_flight_sql_odbc.*.dylib)"
amd64_dylib="$(ls amd64-dylib/libarrow_flight_sql_odbc.*.dylib)"
mkdir universal-dylib
lipo -create "${arm64_dylib}" "${amd64_dylib}" \
-output "universal-dylib/$(basename "${arm64_dylib}")"
- name: Build universal macOS installer
run: |
set -euo pipefail

pkg_path="$(ls arm64-pkg/ArrowFlightSQLODBC-*.pkg)"
pkg_name="$(basename "${pkg_path}" .pkg)"
universal_dylib="$(ls universal-dylib/libarrow_flight_sql_odbc.*.dylib)"

# Use the ARM64 .pkg and swap in a universal ODBC dylib
# that works on ARM64 and AMD64.
pkgutil --expand-full "${pkg_path}" expanded

# The unversioned name libarrow_flight_sql_odbc.dylib is a symlink
# to the versioned dylib that the
# install name (@rpath/libarrow_flight_sql_odbc.<SOVERSION>.dylib)
# resolves to. Run lipo on the real file so the symlinks stay intact.
symlink_path="$(find expanded -name libarrow_flight_sql_odbc.dylib)"
lib_dir="$(dirname "${symlink_path}")"
dylib_path="$(realpath "${symlink_path}")"
echo "Merging into ${dylib_path} (via ${symlink_path})"
lipo -create "${dylib_path}" amd64-dylib/libarrow_flight_sql_odbc.dylib \
-output "${dylib_path}"

# Verify every dylib (including the symlinks) is universal before re-packaging.
# Check one architecture at a time with `lipo -archs`,
# as macOS 27 support only one architecture search at a time.
for lib in "${lib_dir}"/libarrow_flight_sql_odbc*.dylib; do
dylib_archs="$(lipo -archs "${lib}")"
echo "${lib}: ${dylib_archs}"
for arch in arm64 x86_64; do
if ! grep -qw "${arch}" <<< "${dylib_archs}"; then
echo "${lib} is missing '${arch}' (got: ${dylib_archs})"
exit 1
fi
done
done

pkgutil --flatten-full expanded "${pkg_name}.pkg"
ci/scripts/odbc_macos_universal_pkg.sh \
"${pkg_path}" "${universal_dylib}" "${pkg_name}.pkg"
- name: Upload universal ODBC PKG
uses: actions/upload-artifact@v7
with:
Expand Down
Loading
Loading