{"thread":{"id":"63870","subject":"[PATCH] meson: ensure correct \"clar-decls.h\" header is used","startedAt":"2025-07-29T14:10:23Z","lastAt":"2025-07-29T14:10:23Z","messageCount":1,"participants":["Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"522952","messageId":"20250729-b4-pks-meson-unit-tests-stale-decls-v1-1-4a7770c84307@pks.im","threadId":"63870","inReplyTo":null,"subject":"[PATCH] meson: ensure correct \"clar-decls.h\" header is used","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-07-29T14:10:11Z","receivedAt":"2025-07-29T14:10:23Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The \"clar-decls.h\" header gets generated by us to extract prototypes of\nunit test functions from our clar-based tests. This generated file is\nthen written into \"t/unit-tests/\" and included via \"unit-test.h\". The\nintent of all this is that we can keep \"-Wmissing-prototype\" warnings\nenabled. If we had that warning disabled, it would be easy to miss in\ncase any of the non-static functions had a typo in its name and thus\nwasn't picked up by our test case extractor.\n\nIncluding the file directly has a big downside though: if a source tree\nwas built both with our Makefile and with Meson, then the Meson build\nwould include the \"clar-decls.h\" file from our Makefile. And if those\nare out of sync we get compiler errors.\n\nWe already fixed a similar issue in 4771501c0a (meson: ensure correct\nversion-def.h is used, 2025-01-14). Let's do the same and pass the\nabsolute path to \"clar-decls.h\" via a preprocessor define.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n t/meson.build            | 3 +++\n t/unit-tests/unit-test.h | 7 ++++++-\n 2 files changed, 9 insertions(+), 1 deletion(-)\n\ndiff --git a/t/meson.build b/t/meson.build\nindex 660d780dcc6..9d476011347 100644\n--- a/t/meson.build\n+++ b/t/meson.build\n@@ -50,6 +50,9 @@ clar_sources += custom_target(\n \n clar_unit_tests = executable('unit-tests',\n   sources: clar_sources + clar_test_suites,\n+  c_args: [\n+    '-DGIT_CLAR_DECLS_H=\"' + clar_decls_h.full_path() + '\"',\n+  ],\n   dependencies: [libgit_commonmain],\n )\n test('unit-tests', clar_unit_tests, kwargs: test_kwargs)\ndiff --git a/t/unit-tests/unit-test.h b/t/unit-tests/unit-test.h\nindex 85e5d6a948a..39a0b72a05d 100644\n--- a/t/unit-tests/unit-test.h\n+++ b/t/unit-tests/unit-test.h\n@@ -1,8 +1,13 @@\n #include \"git-compat-util.h\"\n #include \"clar/clar.h\"\n-#include \"clar-decls.h\"\n #include \"strbuf.h\"\n \n+#ifndef GIT_CLAR_DECLS_H\n+# include \"clar-decls.h\"\n+#else\n+# include GIT_CLAR_DECLS_H\n+#endif\n+\n #define cl_failf(fmt, ...) do { \\\n \tchar desc[4096]; \\\n \tsnprintf(desc, sizeof(desc), fmt, __VA_ARGS__); \\\n\n---\nbase-commit: e813a0200a7121b97fec535f0d0b460b0a33356c\nchange-id: 20250729-b4-pks-meson-unit-tests-stale-decls-50bb4743eac1\n\n"}]}