Use Postgres as meson wrap subproject
Niyaz Hazigaleyev <hazigaleevniaz@gmail.com>
From: Niyaz Hazigaleyev <hazigaleevniaz@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2025-12-23T15:21:16Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix bug in following update chain when locking a heap tuple
- 955f5506863d 19 (unreleased) cited
It is not possible to use Postgres as meson wrap subproject at least out of box. But I think it can be easily fixed. I made a small patch for libpq and it works. There were two problems, first is catalog header generator using @SOURCE_DIR@ as root for paths, which will use main root project as source dir, so I just changed it to meson.project_source_root(). Second was that libpq dependency include_directories had no dependent headers(for example postgres_ext.h) so I just used include_directories that were also used in libpq_so, libpq_st. So the patch looks like this for commit 955f5506863dce0a3416e3fae7c3297dbbaa946d:
diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build
index ec1cf46..2b12e8e 100644
--- a/src/include/catalog/meson.build
+++ b/src/include/catalog/meson.build
@@ -136,7 +136,7 @@ generated_catalog_headers = custom_target('generated_catalog_headers',
command: [
perl,
files('../../backend/catalog/genbki.pl'),
- '--include-path=@SOURCE_ROOT@/src/include',
+ '--include-path=' + (meson.project_source_root() / 'src/include'),
'--set-version=' + pg_version_major.to_string(),
'--output=@OUTDIR@', '@INPUT@'
],
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index b259c99..51e051f 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -82,7 +82,7 @@ libpq_so = shared_library('libpq',
libpq = declare_dependency(
link_with: [libpq_so],
- include_directories: [include_directories('.')]
+ include_directories: [libpq_inc, postgres_inc]
)
# Check for functions that libpq must not call. See libpq_check.pl for the
Example of wrap file that applies patch:
[wrap-git]
url = https://git.postgresql.org/git/postgresql.git
revision = 955f5506863dce0a3416e3fae7c3297dbbaa946d
depth = 1
diff_files = postgres/libpq.patch
[provide]
libpq = libpq
So to use Postgres as wrap subproject u need to change @SOURCE_DIR@ to meson.project_source_root() and check include_directories for all dependencies. Is there any plans to support it?