Обсуждение: Use Postgres as meson wrap subproject

Поиск
Список
Период
Сортировка

Use Postgres as meson wrap subproject

От
Niyaz Hazigaleyev
Дата:
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
madea small patch for libpq and it works. There were two problems, first is catalog header generator using @SOURCE_DIR@
asroot for paths, which will use main root project as source dir, so I just changed it to meson.project_source_root().
Secondwas that libpq dependency include_directories had no dependent headers(for example postgres_ext.h) so I just used
include_directoriesthat 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_directoriesfor all dependencies. Is there any plans to support it? 


Re: Use Postgres as meson wrap subproject

От
Andreas Karlsson
Дата:
On 12/23/25 4:21 PM, Niyaz Hazigaleyev wrote:
> So to use Postgres as wrap subproject u need to change @SOURCE_DIR@ to meson.project_source_root() and check
include_directoriesfor all dependencies. Is there any plans to support it?
 

Thanks for the patch!

There was an earlier patch[1] for this from Elliot Haisley which looks 
more complete that Andres seemed a bit interested in but as far as I 
know no progress has been made on it recently. You could help out by 
testing it out and reviewing it.

Out of curiosity since I am quite new to Meson: what is your personal 
use case for wrap subprojects?

References

1. 
https://www.postgresql.org/message-id/PH0PR84MB1954C7D61C4882403B8258708605A%40PH0PR84MB1954.NAMPRD84.PROD.OUTLOOK.COM

Andreas




Re: Use Postgres as meson wrap subproject

От
Niyaz Hazigaleyev
Дата:
You right Eliot Haisley more complete patch because he replaced all occurrences of @SOURCE_DIR@ but I also added
include_directoriesto dependency, so it will not fail to find headers which are included in libpq headers. So if I
mergemy patch with Eliot’s  it should be fine. I can send complete patch after it’s done. 
About meson wrap subproject. In my projects I really like to have fallback if there is no system lib available or
systemlib have not compatible version. Basically I use it as package manager for my C/C++ projects, I just put the link
togit into wrap file, provide dependency and that’s it, meson does all the work. Ideally everything in my project
shouldbe build from scratch without any prebuilt binaries, so I can cross-compile to any platform that I want and
build/packagingof project becomes much easier.  
> 3 янв. 2026 г., в 04:54, Andreas Karlsson <andreas@proxel.se> написал(а):
>
> On 12/23/25 4:21 PM, Niyaz Hazigaleyev wrote:
>> So to use Postgres as wrap subproject u need to change @SOURCE_DIR@ to meson.project_source_root() and check
include_directoriesfor all dependencies. Is there any plans to support it? 
>
> Thanks for the patch!
>
> There was an earlier patch[1] for this from Elliot Haisley which looks more complete that Andres seemed a bit
interestedin but as far as I know no progress has been made on it recently. You could help out by testing it out and
reviewingit. 
>
> Out of curiosity since I am quite new to Meson: what is your personal use case for wrap subprojects?
>
> References
>
> 1.
https://www.postgresql.org/message-id/PH0PR84MB1954C7D61C4882403B8258708605A%40PH0PR84MB1954.NAMPRD84.PROD.OUTLOOK.COM
>
> Andreas
>




Re: Use Postgres as meson wrap subproject

От
Andreas Karlsson
Дата:
On 1/4/26 8:32 PM, Niyaz Hazigaleyev wrote:
> You right Eliot Haisley more complete patch because he replaced all occurrences of @SOURCE_DIR@ but I also added
include_directoriesto dependency, so it will not fail to find headers which are included in libpq headers. So if I
mergemy patch with Eliot’s  it should be fine. I can send complete patch after it’s done.
 

Did you see that Tristan also just patched his own version which seems 
like it could potentially be even more complete?

https://www.postgresql.org/message-id/DFEOAWQP27I8.3LHIXYEFCXD25%40partin.io

> About meson wrap subproject. In my projects I really like to have fallback if there is no system lib available or
systemlib have not compatible version. Basically I use it as package manager for my C/C++ projects, I just put the link
togit into wrap file, provide dependency and that’s it, meson does all the work. Ideally everything in my project
shouldbe build from scratch without any prebuilt binaries, so I can cross-compile to any platform that I want and
build/packagingof project becomes much easier.
 

Thanks!

Andreas




Re: Use Postgres as meson wrap subproject

От
Niyaz Hazigaleyev
Дата:
You right, Tristan made even more. At this point I just move to the original thread. Thanks Andreas!

> 5 янв. 2026 г., в 04:09, Andreas Karlsson <andreas@proxel.se> написал(а):
>
> On 1/4/26 8:32 PM, Niyaz Hazigaleyev wrote:
>> You right Eliot Haisley more complete patch because he replaced all occurrences of @SOURCE_DIR@ but I also added
include_directoriesto dependency, so it will not fail to find headers which are included in libpq headers. So if I
mergemy patch with Eliot’s  it should be fine. I can send complete patch after it’s done. 
>
> Did you see that Tristan also just patched his own version which seems like it could potentially be even more
complete?
>
> https://www.postgresql.org/message-id/DFEOAWQP27I8.3LHIXYEFCXD25%40partin.io
>
>> About meson wrap subproject. In my projects I really like to have fallback if there is no system lib available or
systemlib have not compatible version. Basically I use it as package manager for my C/C++ projects, I just put the link
togit into wrap file, provide dependency and that’s it, meson does all the work. Ideally everything in my project
shouldbe build from scratch without any prebuilt binaries, so I can cross-compile to any platform that I want and
build/packagingof project becomes much easier. 
>
> Thanks!
>
> Andreas
>