Skip to content

Commit 69c5e72

Browse files
committed
Merge branch 'kn/meson-hdr-check' into seen
* kn/meson-hdr-check: makefile/meson: add 'check-headers' as alias for 'hdr-check' meson: add support for 'hdr-check' meson: rename 'third_party_sources' to 'third_party_excludes' meson: move headers definition from 'contrib/coccinelle' coccinelle: meson: rename variables to be more specific
2 parents 08de218 + c9e21a0 commit 69c5e72

File tree

4 files changed

+98
-25
lines changed

4 files changed

+98
-25
lines changed

Makefile

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

3336-
.PHONY: hdr-check $(HCO)
3336+
# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
3337+
.PHONY: hdr-check check-headers $(HCO)
33373338
hdr-check: $(HCO)
3339+
check-headers: hdr-check
33383340

33393341
.PHONY: style
33403342
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: 8 additions & 23 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 = [ ]
59-
foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_sources, check: true).stdout().split()
60-
sources += source
43+
coccinelle_sources = []
44+
foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_excludes, check: true).stdout().split()
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_to_check
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: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,28 @@ builtin_sources = [
670670
'builtin/write-tree.c',
671671
]
672672

673+
third_party_excludes = [
674+
':!contrib',
675+
':!compat/inet_ntop.c',
676+
':!compat/inet_pton.c',
677+
':!compat/nedmalloc',
678+
':!compat/obstack.*',
679+
':!compat/poll',
680+
':!compat/regex',
681+
':!sha1collisiondetection',
682+
':!sha1dc',
683+
':!t/unit-tests/clar',
684+
':!t/t[0-9][0-9][0-9][0-9]*',
685+
':!xdiff',
686+
]
687+
688+
if git.found()
689+
headers_to_check = []
690+
foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_excludes, check: true).stdout().split()
691+
headers_to_check += header
692+
endforeach
693+
endif
694+
673695
if not get_option('breaking_changes')
674696
builtin_sources += 'builtin/pack-redundant.c'
675697
endif
@@ -2035,6 +2057,70 @@ endif
20352057

20362058
subdir('contrib')
20372059

2060+
exclude_from_check_headers = [
2061+
'compat/',
2062+
'unicode-width.h',
2063+
]
2064+
2065+
if sha1_backend != 'openssl'
2066+
exclude_from_check_headers += 'sha1/openssl.h'
2067+
endif
2068+
if sha256_backend != 'openssl'
2069+
exclude_from_check_headers += 'sha256/openssl.h'
2070+
endif
2071+
if sha256_backend != 'nettle'
2072+
exclude_from_check_headers += 'sha256/nettle.h'
2073+
endif
2074+
if sha256_backend != 'gcrypt'
2075+
exclude_from_check_headers += 'sha256/gcrypt.h'
2076+
endif
2077+
2078+
if git.found() and compiler.get_argument_syntax() == 'gcc'
2079+
hco_targets = []
2080+
foreach h : headers_to_check
2081+
skip_header = false
2082+
foreach exclude : exclude_from_check_headers
2083+
if h.startswith(exclude)
2084+
skip_header = true
2085+
break
2086+
endif
2087+
endforeach
2088+
2089+
if skip_header
2090+
continue
2091+
endif
2092+
2093+
hcc = custom_target(
2094+
input: h,
2095+
output: h.underscorify() + 'cc',
2096+
command: [
2097+
shell,
2098+
'-c',
2099+
'echo \'#include "git-compat-util.h"\' > @OUTPUT@ && echo \'#include "' + h + '"\' >> @OUTPUT@'
2100+
]
2101+
)
2102+
2103+
hco = custom_target(
2104+
input: hcc,
2105+
output: fs.replace_suffix(h.underscorify(), '.hco'),
2106+
command: [
2107+
compiler.cmd_array(),
2108+
libgit_c_args,
2109+
'-I', meson.project_source_root(),
2110+
'-I', meson.project_source_root() / 't/unit-tests',
2111+
'-o', '/dev/null',
2112+
'-c', '-xc',
2113+
'@INPUT@'
2114+
]
2115+
)
2116+
hco_targets += hco
2117+
endforeach
2118+
2119+
# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
2120+
hdr_check = alias_target('hdr-check', hco_targets)
2121+
alias_target('check-headers', hdr_check)
2122+
endif
2123+
20382124
foreach key, value : {
20392125
'DIFF': diff.full_path(),
20402126
'GIT_SOURCE_DIR': meson.project_source_root(),

0 commit comments

Comments
 (0)