summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2025-08-11 15:14:39 -0400
committerAndres Freund <andres@anarazel.de>2025-08-11 15:18:23 -0400
commit01d6832c109bcc37acb30e934b7c472334b7c291 (patch)
tree8dfe8bb8343e5446f31860b448ebbdcce50d95cc /src
parent71ea0d6795438f95f4ee6e35867058c44b270d51 (diff)
meson: add and use stamp files for generated headers
Without using stamp files, meson lists the generated headers as the dependency for every .c file, bloating build.ninja by more than 2x. Processing all the dependencies also increases the time to generate build.ninja. The immediate benefit is that this makes re-configuring and clean builds a bit faster. The main motivation however is that I have other patches that introduce additional build targets that further would increase the size of build.ninja, making re-configuring more noticeably slower. Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com> Discussion: https://postgr.es/m/cgkdgvzdpinkacf4v33mky7tbmk467oda5dd4dlmucjjockxzi@xkqfvjoq4uiy
Diffstat (limited to 'src')
-rw-r--r--src/backend/meson.build2
-rw-r--r--src/fe_utils/meson.build2
-rw-r--r--src/include/meson.build21
3 files changed, 23 insertions, 2 deletions
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 2b0db214804..b831a541652 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -169,7 +169,7 @@ backend_mod_code = declare_dependency(
compile_args: pg_mod_c_args,
include_directories: postgres_inc,
link_args: pg_mod_link_args,
- sources: generated_headers + generated_backend_headers,
+ sources: generated_backend_headers_stamp,
dependencies: backend_mod_deps,
)
diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build
index a18cbc939e4..5a9ddb73463 100644
--- a/src/fe_utils/meson.build
+++ b/src/fe_utils/meson.build
@@ -29,7 +29,7 @@ generated_sources += psqlscan
fe_utils_sources += psqlscan
fe_utils = static_library('libpgfeutils',
- fe_utils_sources + generated_headers,
+ fe_utils_sources,
c_pch: pch_postgres_fe_h,
include_directories: [postgres_inc, libpq_inc],
c_args: host_system == 'windows' ? ['-DFD_SETSIZE=1024'] : [],
diff --git a/src/include/meson.build b/src/include/meson.build
index 2e4b7aa529e..7cb3075da2a 100644
--- a/src/include/meson.build
+++ b/src/include/meson.build
@@ -177,3 +177,24 @@ install_subdir('catalog',
# autoconf generates the file there, ensure we get a conflict
generated_sources_ac += {'src/include': ['stamp-h']}
+
+
+# Instead of having targets depending directly on a list of all generated
+# headers, have them depend on a stamp files for all of them. Dependencies on
+# headers are implemented as order-only dependencies in meson (and then using
+# compiler generated dependencies during incremental rebuilds ). The benefit
+# of using a stamp file is that it makes ninja.build considerably smaller and
+# meson setup faster, as otherwise the list of headers is repeated for every C
+# file, bloating build.ninja by ~2x.
+generated_headers_stamp = custom_target('generated-headers-stamp.h',
+ output: 'generated-headers-stamp.h',
+ input: generated_headers,
+ command: stamp_cmd,
+)
+
+generated_backend_headers_stamp = custom_target('generated-backend-headers-stamp.h',
+ output: 'generated-backend-headers-stamp.h',
+ input: generated_backend_headers,
+ depends: generated_headers_stamp,
+ command: stamp_cmd,
+)