CI: homebrew: workaround again issue with pkg-config vs pkgconf #7005
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# build GDAL library and to run test with CMake | |
name: Build and test with CMake | |
on: | |
push: | |
paths-ignore: | |
- 'doc/**' | |
- 'docker/**' | |
branches-ignore: | |
- 'backport**' | |
- 'dependabot**' | |
pull_request: | |
paths-ignore: | |
- 'doc/**' | |
- 'docker/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
env: | |
CMAKE_UNITY_BUILD: OFF | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
build-mac: | |
# M1 MacOS runner: https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/ | |
runs-on: macOS-14 | |
env: | |
# Disable Arrow/Parquet because the VM provides libraries in /usr/local/lib/ | |
# that cause Illegal instruction error when running tests. I suspect the | |
# Arrow/Parquet libraries to be built with AVX2 support but the VM worker | |
# doesn't support it. | |
# Disable use of libkml since boost headers cannot be found | |
# Disable ODBC since the postinstall checks don't manage to find sql.h | |
CMAKE_OPTIONS: -DCFITSIO_ROOT=/opt/homebrew/Cellar/cfitsio -DPoppler_ROOT=/opt/homebrew/Cellar/poppler -DPROJ_ROOT=/opt/homebrew/Cellar/proj -DSPATIALITE_ROOT=/opt/homebrew/Cellar/libspatialite -DPostgreSQL_ROOT=/opt/homebrew/Cellar/libpq -DEXPAT_ROOT=/opt/homebrew/Cellar/expat -DXercesC_ROOT=/opt/homebrew/Cellar/xerces-c -DSQLite3_ROOT=/opt/homebrew/Cellar/sqlite -DOpenSSL_ROOT=/opt/homebrew/Cellar/openssl -DPNG_ROOT=/opt/homebrew/Cellar/libpng -DJPEG_ROOT=/opt/homebrew/Cellar/jpeg-turbo -DEXPECTED_JPEG_LIB_VERSION=80 -DOpenJPEG_ROOT=/opt/homebrew/Cellar/openjpeg -DCURL_ROOT=/opt/homebrew/Cellar/curl -DGDAL_USE_LIBKML=OFF -DGDAL_USE_ODBC=OFF | |
cache-name: cmake-macos | |
steps: | |
- name: Setup xcode | |
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0 | |
with: | |
xcode-version: '15.4.0' | |
- name: Checkout GDAL | |
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
- name: Setup cache | |
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2 | |
id: cache | |
with: | |
path: ${{ github.workspace }}/.ccache | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }}${{ github.ref_name }}-${{ github.run_id }} | |
restore-keys: | | |
${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }} | |
${{ runner.os }}-${{ env.cache-name }} | |
- run: | | |
cmake --version | |
- name: Install dependency | |
run: | | |
rm -rf /opt/homebrew/lib/node_modules # conflicts with node@18 from brew | |
brew update | |
brew outdated | |
mv /opt/homebrew/bin/pkg-config /opt/homebrew/bin/pkg-config.old | |
mv /opt/homebrew/share/aclocal/pkg.m4 /opt/homebrew/share/aclocal/pkg.m4.old | |
mv /opt/homebrew/share/man/man1/pkg-config.1 /opt/homebrew/share/man/man1/pkg-config.1.old | |
brew install --overwrite python@3.11 python@3.12 | |
brew install postgresql || brew link postgresql | |
brew install pkg-config freexl libxml2 libspatialite geos proj libgeotiff openjpeg giflib libaec postgis poppler doxygen unixodbc jpeg-turbo aom jpeg-xl libheif libarchive libkml boost | |
brew install ccache swig | |
brew link --force sqlite | |
# gdal is automatically installed as a dependency for postgis | |
brew uninstall --ignore-dependencies gdal | |
# Workaround for https://github.com/Homebrew/homebrew-core/pull/170959#issuecomment-2379606442 | |
sed -i .bak 's/hdf5_hl;hdf5;/hdf5_hl-shared;hdf5-shared;/g' "$(brew --prefix netcdf)/lib/cmake/netCDF/netCDFTargets.cmake" | |
mv /opt/homebrew/bin/pkg-config.old /opt/homebrew/bin/pkg-config | |
mv /opt/homebrew/share/aclocal/pkg.m4.old /opt/homebrew/share/aclocal/pkg.m4 | |
mv /opt/homebrew/share/man/man1/pkg-config.1.old /opt/homebrew/share/man/man1/pkg-config.1 | |
- name: Configure ccache | |
run: | | |
echo CCACHE_BASEDIR=$PWD >> ${GITHUB_ENV} | |
echo CCACHE_DIR=$PWD/.ccache >> ${GITHUB_ENV} | |
echo CCACHE_MAXSIZE=250M >> ${GITHUB_ENV} | |
ccache -z | |
working-directory: ${{ github.workspace }} | |
- name: Configure | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/build | |
export PKG_CONFIG_PATH=/opt/homebrew/Cellar/libxml2/lib/pkgconfig | |
# FIXME: remove -DBUILD_PYTHON_BINDINGS=OFF. Python tests fail with "ModuleNotFoundError: No module named '_gdal'" with macos-12 | |
cmake -Werror=dev -DCMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install-gdal ${CMAKE_OPTIONS} -DCMAKE_C_FLAGS=-Werror -DCMAKE_CXX_FLAGS=-Werror -DUSE_CCACHE=ON -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD} -S "$GITHUB_WORKSPACE" -B "$GITHUB_WORKSPACE/build" -DWERROR_DEV_FLAG="-Werror=dev" -DBUILD_PYTHON_BINDINGS=OFF | |
#$(cat $GITHUB_WORKSPACE/build/python_executable.txt) -m pip install --user -r $GITHUB_WORKSPACE/autotest/requirements.txt | |
- name: Build | |
run: | | |
cmake --build $GITHUB_WORKSPACE/build -j 3 | |
otool -L $GITHUB_WORKSPACE/build/libgdal.dylib | |
- name: test | |
run: cmake --build $GITHUB_WORKSPACE/build --target quicktest | |
- name: test (with ctest) | |
run: | | |
ctest --test-dir $GITHUB_WORKSPACE/build -V -j 3 | |
env: | |
BUILD_NAME: "macos_build_brew" | |
- name: Install | |
run: cmake --build $GITHUB_WORKSPACE/build --target install -j 3 | |
- name: Test post-install usage (with pkg-config) | |
run: | | |
./autotest/postinstall/test_pkg-config.sh $GITHUB_WORKSPACE/install-gdal | |
- name: Test post-install usage (with gdal-config) | |
run: | | |
./autotest/postinstall/test_gdal-config.sh $GITHUB_WORKSPACE/install-gdal | |
- name: Test post-install usage (with CMake) | |
run: | | |
./autotest/postinstall/test_cmake.sh $GITHUB_WORKSPACE/install-gdal --dynamic --disable-odbc | |
- name: ccache statistics | |
run: ccache -s |