Git fork

Merge branch 'kn/meson-hdr-check'

Add an equivalent to "make hdr-check" target to meson based builds.

* 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
ci/github: install git before checking out the repository

+112 -25
+14
.github/workflows/main.yml
··· 415 415 - name: prepare libc6 for actions 416 416 if: matrix.vector.jobname == 'linux32' 417 417 run: apt -q update && apt -q -y install libc6-amd64 lib64stdc++6 418 + - name: install git in container 419 + run: | 420 + if command -v git 421 + then 422 + : # nothing to do 423 + elif command -v apk 424 + then 425 + apk add --update git 426 + elif command -v dnf 427 + then 428 + dnf -yq update && dnf -yq install git 429 + else 430 + apt-get -q update && apt-get -q -y install git 431 + fi 418 432 - uses: actions/checkout@v4 419 433 - run: ci/install-dependencies.sh 420 434 - run: useradd builder --create-home
+3 -1
Makefile
··· 3334 3334 $(HCO): %.hco: %.hcc $(GENERATED_H) FORCE 3335 3335 $(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $< 3336 3336 3337 - .PHONY: hdr-check $(HCO) 3337 + # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+ 3338 + .PHONY: hdr-check check-headers $(HCO) 3338 3339 hdr-check: $(HCO) 3340 + check-headers: hdr-check 3339 3341 3340 3342 .PHONY: style 3341 3343 style:
+1 -1
ci/run-static-analysis.sh
··· 26 26 exit 1 27 27 fi 28 28 29 - make hdr-check || 29 + make check-headers || 30 30 exit 1 31 31 32 32 make check-pot
+8 -23
contrib/coccinelle/meson.build
··· 8 8 subdir_done() 9 9 endif 10 10 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 - 26 11 rules = [ 27 12 'array.cocci', 28 13 'commit.cocci', ··· 55 40 capture: true, 56 41 ) 57 42 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 61 46 endforeach 62 47 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 66 51 endforeach 67 52 68 53 patches = [ ] 69 - foreach source : sources 54 + foreach source : coccinelle_sources 70 55 patches += custom_target( 71 56 command: [ 72 57 spatch, ··· 78 63 input: meson.project_source_root() / source, 79 64 output: source.underscorify() + '.patch', 80 65 capture: true, 81 - depend_files: headers, 66 + depend_files: coccinelle_headers, 82 67 ) 83 68 endforeach 84 69
+86
meson.build
··· 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 ··· 2018 2040 endif 2019 2041 2020 2042 subdir('contrib') 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 2021 2107 2022 2108 foreach key, value : { 2023 2109 'DIFF': diff.full_path(),