Conversation
There was a problem hiding this comment.
Pull request overview
Updates local scripts, Xcode project settings, and CI configuration around PostgreSQL/libpq linking and default runtime host, plus ignores the libpqxx submodule directory.
Changes:
- Switch runtime/test host from a hard-coded IP to
localhost(run script + Xcode scheme). - Update CI/build scripts to build libpqxx via CMake and adjust linker flags/search paths.
- Add
external/libpqxxto.gitignore.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/test.sh |
Simplifies the xcodebuild invocation and leaves prior flags commented out. |
scripts/run.sh |
Defaults the executable’s QuestDB host argument to localhost. |
backtesting-engine-cpp.xcodeproj/xcshareddata/xcschemes/source.xcscheme |
Updates launch argument host to localhost. |
backtesting-engine-cpp.xcodeproj/project.pbxproj |
Adjusts library search paths for libpqxx/PostgreSQL. |
.gitignore |
Ignores external/libpqxx. |
.github/workflows/sonarcloud.yml |
Updates OTHER_LDFLAGS to use brew --prefix ... substitutions. |
.github/workflows/build.sh |
Builds libpqxx with CMake and exports libpq-related env vars. |
.github/workflows/brew.sh |
Tweaks dependency install comments for PostgreSQL/libpq. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| clean build test | ||
| # HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/" \ | ||
| # LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/" \ | ||
| # OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkgconf)/lib -L$(brew --prefix pkgconf)/lib/pkgconfig -L$(brew --prefix postgresql@18)/lib/postgresql -L$(brew --prefix postgresql@18)/lib/postgresql/pgxs -L$(brew --prefix postgresql@18)/lib/postgresql/pkgconfig" \ |
There was a problem hiding this comment.
The commented-out HEADER_SEARCH_PATHS / LIBRARY_SEARCH_PATHS / OTHER_LDFLAGS lines are placed after clean build test, so uncommenting them later won’t affect the xcodebuild invocation (the command already ended). If these are meant to be optional overrides, keep them within the continued xcodebuild command (before clean build test) with the appropriate line continuations.
| clean build test | |
| # HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/" \ | |
| # LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/" \ | |
| # OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkgconf)/lib -L$(brew --prefix pkgconf)/lib/pkgconfig -L$(brew --prefix postgresql@18)/lib/postgresql -L$(brew --prefix postgresql@18)/lib/postgresql/pgxs -L$(brew --prefix postgresql@18)/lib/postgresql/pkgconfig" \ | |
| # HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/" \ | |
| # LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/" \ | |
| # OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkgconf)/lib -L$(brew --prefix pkgconf)/lib/pkgconfig -L$(brew --prefix postgresql@18)/lib/postgresql -L$(brew --prefix postgresql@18)/lib/postgresql/pgxs -L$(brew --prefix postgresql@18)/lib/postgresql/pkgconfig" \ | |
| clean build test |
| HEADER_SEARCH_PATHS="./external/libpqxx/include/pqxx/internal ./external/libpqxx/include/ ./external/libpqxx/build/include/ ./external/" | ||
| LIBRARY_SEARCH_PATHS="./external/libpqxx/src/ ./external/libpqxx/build/src/" | ||
| OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib -L/opt/homebrew/Cellar/pkgconf/2.3.0_1/lib/pkgconfig -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14 -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pgxs -L/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14/pkgconfig" | ||
| OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkgconf)/lib -L$(brew --prefix pkgconf)/lib/pkgconfig -L$(brew --prefix postgresql@18)/lib/postgresql -L$(brew --prefix postgresql@18)/lib/postgresql/pgxs -L$(brew --prefix postgresql@18)/lib/postgresql/pkgconfig" |
There was a problem hiding this comment.
OTHER_LDFLAGS uses $(brew --prefix pkgconf) and $(brew --prefix postgresql@18), but this workflow installs pkg-config and postgresql in brew.sh. As-is, brew --prefix pkgconf / brew --prefix postgresql@18 will fail on runners unless those formulas are installed. Either (a) update the prefixes to match installed formulas (pkg-config, postgresql or libpq), or (b) update brew.sh to install pkgconf and postgresql@18 explicitly.
| OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkgconf)/lib -L$(brew --prefix pkgconf)/lib/pkgconfig -L$(brew --prefix postgresql@18)/lib/postgresql -L$(brew --prefix postgresql@18)/lib/postgresql/pgxs -L$(brew --prefix postgresql@18)/lib/postgresql/pkgconfig" | |
| OTHER_LDFLAGS="-L./external/libpqxx/build/src -lpqxx -lpq -L$(brew --prefix pkg-config)/lib -L$(brew --prefix pkg-config)/lib/pkgconfig -L$(brew --prefix postgresql)/lib/postgresql -L$(brew --prefix postgresql)/lib/postgresql/pgxs -L$(brew --prefix postgresql)/lib/postgresql/pkgconfig" |
| export PATH="$(brew --prefix libpq)/bin:$PATH" | ||
| export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH" | ||
| export PostgreSQL_ROOT="$(brew --prefix libpq)" |
There was a problem hiding this comment.
This script now relies on brew --prefix libpq, but the CI install step (brew.sh) installs postgresql (and not the libpq formula). On a clean runner, brew --prefix libpq will fail unless libpq is installed. Either install libpq in brew.sh (and use its prefix), or switch these exports to use the installed postgresql prefix instead.
| export PATH="$(brew --prefix libpq)/bin:$PATH" | |
| export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH" | |
| export PostgreSQL_ROOT="$(brew --prefix libpq)" | |
| POSTGRESQL_PREFIX="$(brew --prefix postgresql)" | |
| export PATH="$POSTGRESQL_PREFIX/bin:$PATH" | |
| export PKG_CONFIG_PATH="$POSTGRESQL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH" | |
| export PostgreSQL_ROOT="$POSTGRESQL_PREFIX" |
|
|
||
| # Install packages if they don't exist | ||
| check_and_install postgresql # Check and install PostgreSQL | ||
| check_and_install postgresql # Check and install PostgreSQL (which includes libpq) |
There was a problem hiding this comment.
The workflow scripts reference the separate Homebrew libpq formula (e.g., brew --prefix libpq in build.sh). Installing postgresql doesn’t guarantee brew --prefix libpq will work, so CI can still fail unless libpq is installed explicitly (or the other scripts are updated to use postgresql’s prefix).
| check_and_install postgresql # Check and install PostgreSQL (which includes libpq) | |
| check_and_install postgresql # Check and install PostgreSQL | |
| check_and_install libpq # Check and install the standalone libpq formula used by other workflow scripts |
| LIBRARY_SEARCH_PATHS = ( | ||
| "\"$(SRCROOT)/external/libpqxx/src\"", | ||
| "$(SRCROOT)/build/external/libpqxx/src", | ||
| "/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14", | ||
| "\"$(SRCROOT)/external/libpqxx/build/src\"", | ||
| "/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql", | ||
| ); |
There was a problem hiding this comment.
This hard-codes a Homebrew Cellar path to postgresql@18/18.3, which is machine- and version-specific and will break for anyone without that exact installation. Prefer using a stable path via build settings (e.g., $(shell brew --prefix ...) in a script-driven xcconfig, or linking against libpq via pkg-config) rather than committing a Cellar versioned path into the project.
| LIBRARY_SEARCH_PATHS = ( | ||
| "\"$(SRCROOT)/external/libpqxx/src\"", | ||
| "$(SRCROOT)/build/external/libpqxx/src", | ||
| "/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14", | ||
| "\"$(SRCROOT)/external/libpqxx/build/src\"", | ||
| "/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql", | ||
| ); |
There was a problem hiding this comment.
This build configuration hard-codes a Homebrew Cellar path for postgresql@18/18.3, which isn’t portable across machines/CI and will break on version bumps. Use a stable prefix (Homebrew opt path / brew --prefix ...) or pkg-config-driven linking instead of committing a versioned Cellar path.
| LIBRARY_SEARCH_PATHS = ( | ||
| "\"$(SRCROOT)/external/libpqxx/src\"", | ||
| "$(PROJECT_DIR)/build/external/libpqxx/src", | ||
| "/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14", | ||
| "\"$(SRCROOT)/external/libpqxx/build/src\"", | ||
| "/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql", | ||
| ); |
There was a problem hiding this comment.
LIBRARY_SEARCH_PATHS includes a versioned Homebrew Cellar path (/opt/homebrew/Cellar/postgresql@18/18.3/...). That path will differ across developer machines and will change on upgrades, making the project brittle. Prefer referencing a stable prefix (e.g., Homebrew opt symlink) or resolving via pkg-config/xcconfig rather than a Cellar version path.
| "$(PROJECT_DIR)/build/external/libpqxx/src", | ||
| "/opt/homebrew/Cellar/postgresql@14/14.15/lib/postgresql@14", | ||
| "\"$(SRCROOT)/external/libpqxx/build/src\"", | ||
| "/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql", |
There was a problem hiding this comment.
Hard-coding /opt/homebrew/Cellar/postgresql@18/18.3/... into LIBRARY_SEARCH_PATHS ties the project to one specific Homebrew install/version. This is likely to break in CI and for other developers. Use a stable opt path (or brew --prefix resolved via an xcconfig/script) or pkg-config to locate libpq instead.
| "/opt/homebrew/Cellar/postgresql@18/18.3/lib/postgresql", | |
| "/opt/homebrew/opt/postgresql@18/lib/postgresql", |
No description provided.