Skip to content

Commit 5247da0

Browse files
pks-tgitster
authored andcommitted
meson: ensure correct "clar-decls.h" header is used
The "clar-decls.h" header gets generated by us to extract prototypes of unit test functions from our clar-based tests. This generated file is then written into "t/unit-tests/" and included via "unit-test.h". The intent of all this is that we can keep "-Wmissing-prototype" warnings enabled. If we had that warning disabled, it would be easy to miss in case any of the non-static functions had a typo in its name and thus wasn't picked up by our test case extractor. Including the file directly has a big downside though: if a source tree was built both with our Makefile and with Meson, then the Meson build would include the "clar-decls.h" file from our Makefile. And if those are out of sync we get compiler errors. We already fixed a similar issue in 4771501 (meson: ensure correct version-def.h is used, 2025-01-14). Let's do the same and pass the absolute path to "clar-decls.h" via a preprocessor define. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16bd9f2 commit 5247da0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

t/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ clar_sources += custom_target(
4949

5050
clar_unit_tests = executable('unit-tests',
5151
sources: clar_sources + clar_test_suites,
52+
c_args: [
53+
'-DGIT_CLAR_DECLS_H="' + clar_decls_h.full_path() + '"',
54+
],
5255
dependencies: [libgit_commonmain],
5356
)
5457
test('unit-tests', clar_unit_tests)

t/unit-tests/unit-test.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#include "git-compat-util.h"
22
#include "clar/clar.h"
3-
#include "clar-decls.h"
43
#include "strbuf.h"
54

5+
#ifndef GIT_CLAR_DECLS_H
6+
# include "clar-decls.h"
7+
#else
8+
# include GIT_CLAR_DECLS_H
9+
#endif
10+
611
#define cl_failf(fmt, ...) do { \
712
char desc[4096]; \
813
snprintf(desc, sizeof(desc), fmt, __VA_ARGS__); \

0 commit comments

Comments
 (0)