Skip to content

Commit 9d381d4

Browse files
committed
Merge branch 'kn/meson-hdr-check' into jch
Add an equivalent to "make hdr-check" target to meson based builds. Getting there. cf. <[email protected]> * kn/meson-hdr-check: makefile/meson: add 'check-headers' as alias for 'hdr-check' meson: add support for 'hdr-check' meson: move headers definition from 'contrib/coccinelle' coccinelle: meson: rename variables to be more specific
2 parents c3a4b0c + a58b87a commit 9d381d4

File tree

4 files changed

+105
-24
lines changed

4 files changed

+105
-24
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3331,8 +3331,10 @@ HCC = $(HCO:hco=hcc)
33313331
$(HCO): %.hco: %.hcc $(GENERATED_H) FORCE
33323332
$(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $<
33333333

3334-
.PHONY: hdr-check $(HCO)
3334+
# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
3335+
.PHONY: hdr-check check-headers $(HCO)
33353336
hdr-check: $(HCO)
3337+
check-headers: hdr-check
33363338

33373339
.PHONY: style
33383340
style:

ci/run-static-analysis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ then
2626
exit 1
2727
fi
2828

29-
make hdr-check ||
29+
make check-headers ||
3030
exit 1
3131

3232
make check-pot

contrib/coccinelle/meson.build

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@ if not spatch.found()
88
subdir_done()
99
endif
1010

11-
third_party_sources = [
12-
':!contrib',
13-
':!compat/inet_ntop.c',
14-
':!compat/inet_pton.c',
15-
':!compat/nedmalloc',
16-
':!compat/obstack.*',
17-
':!compat/poll',
18-
':!compat/regex',
19-
':!sha1collisiondetection',
20-
':!sha1dc',
21-
':!t/unit-tests/clar',
22-
':!t/unit-tests/clar',
23-
':!t/t[0-9][0-9][0-9][0-9]*',
24-
]
25-
2611
rules = [
2712
'array.cocci',
2813
'commit.cocci',
@@ -55,18 +40,18 @@ concatenated_rules = custom_target(
5540
capture: true,
5641
)
5742

58-
sources = [ ]
43+
coccinelle_sources = []
5944
foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_sources, check: true).stdout().split()
60-
sources += source
45+
coccinelle_sources += source
6146
endforeach
6247

63-
headers = [ ]
64-
foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()
65-
headers += meson.project_source_root() / header
48+
coccinelle_headers = []
49+
foreach header : headers
50+
coccinelle_headers += meson.project_source_root() / header
6651
endforeach
6752

6853
patches = [ ]
69-
foreach source : sources
54+
foreach source : coccinelle_sources
7055
patches += custom_target(
7156
command: [
7257
spatch,
@@ -78,7 +63,7 @@ foreach source : sources
7863
input: meson.project_source_root() / source,
7964
output: source.underscorify() + '.patch',
8065
capture: true,
81-
depend_files: headers,
66+
depend_files: coccinelle_headers,
8267
)
8368
endforeach
8469

meson.build

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,33 @@ builtin_sources = [
667667
'builtin/write-tree.c',
668668
]
669669

670+
third_party_sources = [
671+
':!contrib',
672+
':!compat/inet_ntop.c',
673+
':!compat/inet_pton.c',
674+
':!compat/nedmalloc',
675+
':!compat/obstack.*',
676+
':!compat/poll',
677+
':!compat/regex',
678+
':!sha1collisiondetection',
679+
':!sha1dc',
680+
':!t/unit-tests/clar',
681+
':!t/unit-tests/clar',
682+
':!t/t[0-9][0-9][0-9][0-9]*',
683+
':!xdiff',
684+
]
685+
686+
if git.found()
687+
headers = []
688+
foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()
689+
headers += header
690+
endforeach
691+
endif
692+
693+
generated_headers = [
694+
'command-list.h',
695+
]
696+
670697
if not get_option('breaking_changes')
671698
builtin_sources += 'builtin/pack-redundant.c'
672699
endif
@@ -681,6 +708,7 @@ builtin_sources += custom_target(
681708
],
682709
env: script_environment,
683710
)
711+
generated_headers += 'config-list.h'
684712

685713
builtin_sources += custom_target(
686714
input: 'Documentation/githooks.adoc',
@@ -693,6 +721,7 @@ builtin_sources += custom_target(
693721
],
694722
env: script_environment,
695723
)
724+
generated_headers += 'hook-list.h'
696725

697726
# This contains the variables for GIT-BUILD-OPTIONS, which we use to propagate
698727
# build options to our tests.
@@ -2013,6 +2042,71 @@ endif
20132042

20142043
subdir('contrib')
20152044

2045+
exclude_from_check_headers = generated_headers
2046+
exclude_from_check_headers += [
2047+
'compat/',
2048+
'unicode-width.h',
2049+
]
2050+
2051+
if sha1_backend != 'openssl'
2052+
exclude_from_check_headers += 'sha1/openssl.h'
2053+
endif
2054+
if sha256_backend != 'openssl'
2055+
exclude_from_check_headers += 'sha256/openssl.h'
2056+
endif
2057+
if sha256_backend != 'nettle'
2058+
exclude_from_check_headers += 'sha256/nettle.h'
2059+
endif
2060+
if sha256_backend != 'gcrpyt'
2061+
exclude_from_check_headers += 'sha256/gcrypt.h'
2062+
endif
2063+
2064+
if git.found() and compiler.get_argument_syntax() == 'gcc'
2065+
hco_targets = []
2066+
foreach h : headers
2067+
skip_header = false
2068+
foreach exclude : exclude_from_check_headers
2069+
if h.startswith(exclude)
2070+
skip_header = true
2071+
break
2072+
endif
2073+
endforeach
2074+
2075+
if skip_header
2076+
continue
2077+
endif
2078+
2079+
hcc = custom_target(
2080+
input: h,
2081+
output: h.underscorify() + 'cc',
2082+
command: [
2083+
shell,
2084+
'-c',
2085+
'echo \'#include "git-compat-util.h"\' > @OUTPUT@ && echo \'#include "' + h + '"\' >> @OUTPUT@'
2086+
]
2087+
)
2088+
2089+
hco = custom_target(
2090+
input: hcc,
2091+
output: fs.replace_suffix(h.underscorify(), '.hco'),
2092+
command: [
2093+
compiler.cmd_array(),
2094+
libgit_c_args,
2095+
'-I', meson.project_source_root(),
2096+
'-I', meson.project_source_root() / 't/unit-tests',
2097+
'-o', '/dev/null',
2098+
'-c', '-xc',
2099+
'@INPUT@'
2100+
]
2101+
)
2102+
hco_targets += hco
2103+
endforeach
2104+
2105+
# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
2106+
alias_target('hdr-check', hco_targets)
2107+
alias_target('check-headers', hco_targets)
2108+
endif
2109+
20162110
foreach key, value : {
20172111
'DIFF': diff.full_path(),
20182112
'GIT_SOURCE_DIR': meson.project_source_root(),

0 commit comments

Comments
 (0)