Use Postgres as meson wrap subproject

From: Niyaz Hazigaleyev <hazigaleevniaz(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Use Postgres as meson wrap subproject
Date: 2025-12-23 15:21:16
Message-ID: F28283CF-AC9C-4930-9D84-56CD9E105504@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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=(at)SOURCE_ROOT@/src/include',
+ '--include-path=' + (meson.project_source_root() / 'src/include'),
'--set-version=' + pg_version_major.to_string(),
'--output=(at)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?

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marcos Pegoraro 2025-12-23 15:58:47 Re: Get rid of "Section.N.N.N" on DOCs
Previous Message Tom Lane 2025-12-23 15:07:32 Re: Change some Datum to void * for opaque pass-through pointer