@@ -675,6 +675,28 @@ builtin_sources = [
675
675
' builtin/write-tree.c' ,
676
676
]
677
677
678
+ third_party_excludes = [
679
+ ' :!contrib' ,
680
+ ' :!compat/inet_ntop.c' ,
681
+ ' :!compat/inet_pton.c' ,
682
+ ' :!compat/nedmalloc' ,
683
+ ' :!compat/obstack.*' ,
684
+ ' :!compat/poll' ,
685
+ ' :!compat/regex' ,
686
+ ' :!sha1collisiondetection' ,
687
+ ' :!sha1dc' ,
688
+ ' :!t/unit-tests/clar' ,
689
+ ' :!t/t[0-9][0-9][0-9][0-9]*' ,
690
+ ' :!xdiff' ,
691
+ ]
692
+
693
+ headers_to_check = []
694
+ if git.found() and fs.exists(meson .project_source_root() / ' .git' )
695
+ foreach header : run_command (git, ' -C' , meson .project_source_root(), ' ls-files' , ' --deduplicate' , ' *.h' , third_party_excludes, check : true ).stdout().split()
696
+ headers_to_check += header
697
+ endforeach
698
+ endif
699
+
678
700
if not get_option (' breaking_changes' )
679
701
builtin_sources += ' builtin/pack-redundant.c'
680
702
endif
@@ -2019,6 +2041,70 @@ endif
2019
2041
2020
2042
subdir (' contrib' )
2021
2043
2044
+ exclude_from_check_headers = [
2045
+ ' compat/' ,
2046
+ ' unicode-width.h' ,
2047
+ ]
2048
+
2049
+ if sha1_backend != ' openssl'
2050
+ exclude_from_check_headers += ' sha1/openssl.h'
2051
+ endif
2052
+ if sha256_backend != ' openssl'
2053
+ exclude_from_check_headers += ' sha256/openssl.h'
2054
+ endif
2055
+ if sha256_backend != ' nettle'
2056
+ exclude_from_check_headers += ' sha256/nettle.h'
2057
+ endif
2058
+ if sha256_backend != ' gcrypt'
2059
+ exclude_from_check_headers += ' sha256/gcrypt.h'
2060
+ endif
2061
+
2062
+ if headers_to_check.length() != 0 and compiler.get_argument_syntax() == ' gcc'
2063
+ hco_targets = []
2064
+ foreach h : headers_to_check
2065
+ skip_header = false
2066
+ foreach exclude : exclude_from_check_headers
2067
+ if h.startswith(exclude)
2068
+ skip_header = true
2069
+ break
2070
+ endif
2071
+ endforeach
2072
+
2073
+ if skip_header
2074
+ continue
2075
+ endif
2076
+
2077
+ hcc = custom_target (
2078
+ input : h,
2079
+ output : h.underscorify() + ' cc' ,
2080
+ command : [
2081
+ shell,
2082
+ ' -c' ,
2083
+ ' echo \' #include "git-compat-util.h"\' > @OUTPUT@ && echo \' #include "' + h + ' "\' >> @OUTPUT@'
2084
+ ]
2085
+ )
2086
+
2087
+ hco = custom_target (
2088
+ input : hcc,
2089
+ output : fs.replace_suffix(h.underscorify(), ' .hco' ),
2090
+ command : [
2091
+ compiler.cmd_array(),
2092
+ libgit_c_args,
2093
+ ' -I' , meson .project_source_root(),
2094
+ ' -I' , meson .project_source_root() / ' t/unit-tests' ,
2095
+ ' -o' , ' /dev/null' ,
2096
+ ' -c' , ' -xc' ,
2097
+ ' @INPUT@'
2098
+ ]
2099
+ )
2100
+ hco_targets += hco
2101
+ endforeach
2102
+
2103
+ # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+
2104
+ hdr_check = alias_target (' hdr-check' , hco_targets)
2105
+ alias_target (' check-headers' , hdr_check)
2106
+ endif
2107
+
2022
2108
foreach key, value : {
2023
2109
' DIFF' : diff.full_path(),
2024
2110
' GIT_SOURCE_DIR' : meson .project_source_root(),
0 commit comments