Skip to content

Commit

Permalink
macos tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zachasme committed Nov 6, 2024
1 parent a82472f commit 012676c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ jobs:
strategy:
matrix:
config: [Release, Debug]
pg: [14]
pg: [17, 16, 15, 14, 13]

runs-on: macos-14

name: macos 🐘${{ matrix.pg }} (${{ matrix.config }})

steps:
- uses: actions/checkout@v3

Expand All @@ -27,24 +29,38 @@ jobs:
# - name: Install pg_validate_extupgrade
# run: cargo install --locked --git https://github.com/rjuju/pg_validate_extupgrade.git

- name: Install PostgreSQL and PostGIS
run: brew install postgresql@${{ matrix.pg }} postgis
- name: Setup PostgreSQL
run: |
brew unlink postgresql
brew install postgresql@${{ matrix.pg }}
brew link postgresql@${{ matrix.pg }}
brew services restart postgresql@${{ matrix.pg }}
# brew link --force gettext #building pg>=15 fails without this
- name: Setupl PostGIS (pg 14/17 only)
run: brew install postgis
if: ${{ matrix.pg == 17 || matrix.pg == 14 }}

# - name: Fix gettext linkage for PostgreSQL >= 15
# if: ${{ matrix.pg >= 15 }}
# run: brew unlink gettext && brew link -n --force gettext

- name: Generate
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
run: VERBOSE=true cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DCMAKE_CXX_FLAGS=-I/usr/local/include

- name: Build
run: cmake --build build --config ${{ matrix.config }}

- name: Install
run: sudo cmake --install build --component h3-pg --config ${{ matrix.config }}

- name: Prepare PostgreSQL
run: brew services start postgresql@${{ matrix.pg }}

- name: Test
run: ctest --test-dir build --output-on-failure --build-config ${{ matrix.config }}

- name: Print regression diffs
if: ${{ failure() }}
run: cat build/*/regression.diffs

# env: # something wrong with gettext
# CXXFLAGS: -I/usr/local/include
# CPPFLAGS: -I/usr/local/include
15 changes: 8 additions & 7 deletions cmake/AddPostgreSQLExtension.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ function(PostgreSQL_add_extension LIBRARY_NAME)
# Link extension to PostgreSQL
target_link_libraries(${LIBRARY_NAME} PRIVATE PostgreSQL::PostgreSQL)

# Fix apple missing symbols
# Handle macOS specifics
if(APPLE)
# Fix apple missing symbols
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS ${PostgreSQL_LINK_FLAGS})

# Since Postgres 16, the shared library extension on macOS is `dylib`, not `so`.
# Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a
if (${PostgreSQL_VERSION_MAJOR} VERSION_GREATER_EQUAL "16")
set_target_properties (${LIBRARY_NAME} PROPERTIES SUFFIX ".dylib")
endif()
endif()

# Final touches on output file
Expand All @@ -44,12 +51,6 @@ function(PostgreSQL_add_extension LIBRARY_NAME)
PREFIX "" # Avoid lib* prefix on output file
)

# Since Postgres 16, the shared library extension on macOS is `dylib`, not `so`.
# Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a
if (APPLE AND ${PostgreSQL_VERSION_MAJOR} VERSION_GREATER_EQUAL "16")
set_target_properties (${LIBRARY_NAME} PROPERTIES SUFFIX ".dylib")
endif()

# Install .so/.dll to pkglib-dir
install(
TARGETS ${LIBRARY_NAME}
Expand Down
1 change: 1 addition & 0 deletions cmake/FindPostgreSQL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ execute_process(COMMAND ${PostgreSQL_CONFIG} --libdir OUTPUT_VARIABLE
execute_process(COMMAND ${PostgreSQL_CONFIG} --pkglibdir OUTPUT_VARIABLE PostgreSQL_PKG_LIBRARY_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)

# @TODO: Figure out if we need _INCLUDE_DIR and/or _PKG_INCLUDE_DIR
set(WIP_APPLE_INCLUDE_DIR "/usr/local/include")

# Create include dirs list
list(APPEND PostgreSQL_INCLUDE_DIRS "${PostgreSQL_INCLUDE_DIR}" "${PostgreSQL_PKG_INCLUDE_DIR}" "${PostgreSQL_SERVER_INCLUDE_DIR}")
Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ target_link_libraries(postgresql_h3_shared
PRIVATE PostgreSQL::PostgreSQL
)
target_include_directories(postgresql_h3_shared
INTERFACE ./
INTERFACE ./ /usr/local/include
)
set_target_properties(postgresql_h3_shared PROPERTIES POSITION_INDEPENDENT_CODE True)

0 comments on commit 012676c

Please sign in to comment.