{"thread":{"id":"63294","subject":"[PATCH v3 1/4] coccinelle: meson: rename variables to be more specific","startedAt":"2025-04-14T21:16:05Z","lastAt":"2025-04-20T11:02:09Z","messageCount":13,"participants":["Karthik Nayak","Junio C Hamano","Phillip Wood","phillip.wood123@gmail.com"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"516144","messageId":"20250414-505-wire-up-sparse-via-meson-v3-0-edc6e7f26745@gmail.com","threadId":"63294","inReplyTo":"20250408-505-wire-up-sparse-via-meson-v1-0-17476e5cea3f@gmail.com","subject":"[PATCH v3 0/4] meson: add corresponding target for Makefile's hdr-check","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-14T21:15:58Z","receivedAt":"2025-04-14T21:16:05Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"To bridge the remaining gaps between Makefile and Meson, this patch\nseries adds 'hdr-check' to Meson to compliment the Makefile's\n'hdr-check'.\n\nWe also introduce 'headers-check' as an alias to 'hdr-check' as a better\nnamed replacement in both Meson and make and add a note to deprecate\n'hdr-check' in the future.\n\nThe first two commits are small cleanups, where we re-organize existing\nvariables to make it easier to add the target. The third commit adds the\n'hdr-check' target to Meson. The last commit introduces the\n'headers-check' alias to both Meson and the makefile and marks\n'hdr-check' to be deprecated.\n\nThis is based on master 9d22ac5122 (The third batch, 2025-04-07) with\n'es/meson-build-skip-coccinelle' merged in.\n\n---\nChanges in v3:\n- Some renames:\n  - headers_generated -> generated_headers\n  - meson -> Meson\n  - headers-check -> check-headers\n  - headers_check_exclude -> exclude_from_check_headers\n- Rewrite 'headers_check_exclude' to also contain dirs so we can skip\n  listing individual header files.\n- Move 'xdiff/*' to 'third_party_sources' and cleanup\n  'exclude_from_check_headers'.\n- Use 'echo' instead of 'echo -n'.\n- Use `fs.replace_suffix` instead of `str.replace`.\n- Link to v2: https://lore.kernel.org/r/20250410-505-wire-up-sparse-via-meson-v2-0-acb45cc8a2e5@gmail.com\n\nChanges in v2:\n- Add 'hdr-check' to meson, while introducing 'headers-check' as\n  a replacement alias. Schedule 'hdr-check' to be deprecated in the future.\n- Link to v1: https://lore.kernel.org/r/20250408-505-wire-up-sparse-via-meson-v1-0-17476e5cea3f@gmail.com\n\n---\n Makefile                       |  4 +-\n ci/run-static-analysis.sh      |  2 +-\n contrib/coccinelle/meson.build | 29 ++++---------\n meson.build                    | 94 ++++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 105 insertions(+), 24 deletions(-)\n\nKarthik Nayak (4):\n      coccinelle: meson: rename variables to be more specific\n      meson: move headers definition from 'contrib/coccinelle'\n      meson: add support for 'hdr-check'\n      makefile/meson: add 'check-headers' as alias for 'hdr-check'\n\nRange-diff versus v2:\n\n1:  ca94103a13 ! 1:  3386caeaf5 coccinelle: meson: rename variables to be more specific\n    @@ Metadata\n      ## Commit message ##\n         coccinelle: meson: rename variables to be more specific\n     \n    -    In meson, included subdirs export their variables to top level meson\n    +    In Meson, included subdirs export their variables to top level Meson\n         builds. In 'contrib/coccinelle/meson.build', we define two such\n         variables `sources` and `headers`. While these variables are specific to\n         the checks in the 'contrib/coccinelle/' directory, they also pollute the\n2:  2549f1a5df ! 2:  35f5a580e4 meson: move headers definition from 'contrib/coccinelle'\n    @@ Metadata\n      ## Commit message ##\n         meson: move headers definition from 'contrib/coccinelle'\n     \n    -    The meson build for coccinelle static analysis lists all headers to\n    -    analyse. Due to the way meson exports variables between subdirs, this\n    -    variable is also available in the root meson build.\n    +    The Meson build for coccinelle static analysis lists all headers to\n    +    analyse. Due to the way Meson exports variables between subdirs, this\n    +    variable is also available in the root Meson build.\n     \n         An upcoming commit, will add a new check complimenting 'hdr-check' in\n         the Makefile. This would require the list of headers. So move the\n    -    'coccinelle_headers' to the root meson build and rename it to 'headers',\n    +    'coccinelle_headers' to the root Meson build and rename it to 'headers',\n         remove the root path being appended to each header and retain that in\n    -    the coccinelle meson build since it is specific to the coccinelle build.\n    +    the coccinelle Meson build since it is specific to the coccinelle build.\n     \n    -    Also move the 'third_party_sources' variable to the root meson build\n    +    Also move the 'third_party_sources' variable to the root Meson build\n         since it is also a dependency for the 'headers' variable. This also\n         makes it easier to understand as the variable is now propagated from the\n         top level to the bottom.\n    @@ meson.build: builtin_sources = [\n     +  ':!t/t[0-9][0-9][0-9][0-9]*',\n     +]\n     +\n    -+headers = []\n     +if git.found()\n    ++  headers = []\n     +  foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()\n     +    headers += header\n     +  endforeach\n3:  a46db4a81c < -:  ---------- meson: add support for 'hdr-check'\n-:  ---------- > 3:  0df83087ac meson: add support for 'hdr-check'\n4:  fe0160b6fe ! 4:  b5d10772ff makefile/meson: add 'headers-check' as alias for 'hdr-check'\n    @@ Metadata\n     Author: Karthik Nayak <karthik.188@gmail.com>\n     \n      ## Commit message ##\n    -    makefile/meson: add 'headers-check' as alias for 'hdr-check'\n    +    makefile/meson: add 'check-headers' as alias for 'hdr-check'\n     \n    -    The 'hdr-check' target in meson and makefile is used to check if headers\n    +    The 'hdr-check' target in Meson and makefile is used to check if headers\n         can be compiled individually. The naming however isn't readable as 'hdr'\n         is not a common shortforme for 'header', neither is it an abbreviation.\n     \n    -    Let's introduce 'headers-check' as an alternative target for 'hdr-check'\n    +    Let's introduce 'check-headers' as an alternative target for 'hdr-check'\n         and add a `TODO` to deprecate the latter after 2 releases. Since this\n         is an internal tool, we can use a shorter deprecation cycle.\n     \n         Change existing usage of 'hdr-check' in 'ci/run-static-analysis.sh' to\n    -    also use 'headers-check'.\n    +    also use 'check-headers'.\n     \n         Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n     \n    @@ Makefile: HCC = $(HCO:hco=hcc)\n      \t$(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $<\n      \n     -.PHONY: hdr-check $(HCO)\n    -+# TODO: deprecate 'hdr-check' in lieu of 'headers-check' in Git 2.51+\n    -+.PHONY: hdr-check headers-check $(HCO)\n    ++# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n    ++.PHONY: hdr-check check-headers $(HCO)\n      hdr-check: $(HCO)\n    -+headers-check: hdr-check\n    ++check-headers: hdr-check\n      \n      .PHONY: style\n      style:\n    @@ ci/run-static-analysis.sh: then\n      fi\n      \n     -make hdr-check ||\n    -+make headers-check ||\n    ++make check-headers ||\n      exit 1\n      \n      make check-pot\n     \n      ## meson.build ##\n    -@@ meson.build: if headers.length() != 0 and compiler.get_argument_syntax() == 'gcc'\n    +@@ meson.build: if git.found() and compiler.get_argument_syntax() == 'gcc'\n          hco_targets += hco\n        endforeach\n      \n    -+  # TODO: deprecate 'hdr-check' in lieu of 'headers-check' in Git 2.51+\n    ++  # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n        alias_target('hdr-check', hco_targets)\n    -+  alias_target('headers-check', hco_targets)\n    ++  alias_target('check-headers', hco_targets)\n      endif\n      \n      foreach key, value : {\n\n\nbase-commit: 3a956c5f69873611ae5f8dcb9acd117f66b95ddc\nchange-id: 20250330-505-wire-up-sparse-via-meson-2e32dd31208b\n\nThanks\n- Karthik\n\n"},{"id":"516143","messageId":"20250414-505-wire-up-sparse-via-meson-v3-1-edc6e7f26745@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-0-edc6e7f26745@gmail.com","subject":"[PATCH v3 1/4] coccinelle: meson: rename variables to be more specific","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-14T21:15:59Z","receivedAt":"2025-04-14T21:16:07Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"In Meson, included subdirs export their variables to top level Meson\nbuilds. In 'contrib/coccinelle/meson.build', we define two such\nvariables `sources` and `headers`. While these variables are specific to\nthe checks in the 'contrib/coccinelle/' directory, they also pollute the\ntop level 'meson.build'.\n\nRename them to be more specific, this ensures that they aren't\nmistakenly used in the upper levels and avoid variable name collisions.\n\nWhile here, change the empty list denotation to be consistent with other\nplaces.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n contrib/coccinelle/meson.build | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build\nindex ea054c924f..03ce52d752 100644\n--- a/contrib/coccinelle/meson.build\n+++ b/contrib/coccinelle/meson.build\n@@ -55,18 +55,18 @@ concatenated_rules = custom_target(\n   capture: true,\n )\n \n-sources = [ ]\n+coccinelle_sources = []\n foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_sources, check: true).stdout().split()\n-  sources += source\n+  coccinelle_sources += source\n endforeach\n \n-headers = [ ]\n+coccinelle_headers = []\n foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()\n-  headers += meson.project_source_root() / header\n+  coccinelle_headers += meson.project_source_root() / header\n endforeach\n \n patches = [ ]\n-foreach source : sources\n+foreach source : coccinelle_sources\n   patches += custom_target(\n     command: [\n       spatch,\n@@ -78,7 +78,7 @@ foreach source : sources\n     input: meson.project_source_root() / source,\n     output: source.underscorify() + '.patch',\n     capture: true,\n-    depend_files: headers,\n+    depend_files: coccinelle_headers,\n   )\n endforeach\n \n\n-- \n2.48.1\n\n"},{"id":"516145","messageId":"20250414-505-wire-up-sparse-via-meson-v3-2-edc6e7f26745@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-0-edc6e7f26745@gmail.com","subject":"[PATCH v3 2/4] meson: move headers definition from 'contrib/coccinelle'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-14T21:16:00Z","receivedAt":"2025-04-14T21:16:07Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The Meson build for coccinelle static analysis lists all headers to\nanalyse. Due to the way Meson exports variables between subdirs, this\nvariable is also available in the root Meson build.\n\nAn upcoming commit, will add a new check complimenting 'hdr-check' in\nthe Makefile. This would require the list of headers. So move the\n'coccinelle_headers' to the root Meson build and rename it to 'headers',\nremove the root path being appended to each header and retain that in\nthe coccinelle Meson build since it is specific to the coccinelle build.\n\nAlso move the 'third_party_sources' variable to the root Meson build\nsince it is also a dependency for the 'headers' variable. This also\nmakes it easier to understand as the variable is now propagated from the\ntop level to the bottom.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n contrib/coccinelle/meson.build | 17 +----------------\n meson.build                    | 22 ++++++++++++++++++++++\n 2 files changed, 23 insertions(+), 16 deletions(-)\n\ndiff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build\nindex 03ce52d752..32568c5103 100644\n--- a/contrib/coccinelle/meson.build\n+++ b/contrib/coccinelle/meson.build\n@@ -8,21 +8,6 @@ if not spatch.found()\n   subdir_done()\n endif\n \n-third_party_sources = [\n-  ':!contrib',\n-  ':!compat/inet_ntop.c',\n-  ':!compat/inet_pton.c',\n-  ':!compat/nedmalloc',\n-  ':!compat/obstack.*',\n-  ':!compat/poll',\n-  ':!compat/regex',\n-  ':!sha1collisiondetection',\n-  ':!sha1dc',\n-  ':!t/unit-tests/clar',\n-  ':!t/unit-tests/clar',\n-  ':!t/t[0-9][0-9][0-9][0-9]*',\n-]\n-\n rules = [\n   'array.cocci',\n   'commit.cocci',\n@@ -61,7 +46,7 @@ foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files',\n endforeach\n \n coccinelle_headers = []\n-foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()\n+foreach header : headers\n   coccinelle_headers += meson.project_source_root() / header\n endforeach\n \ndiff --git a/meson.build b/meson.build\nindex e98cfa4909..3ca5d01071 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -633,6 +633,28 @@ builtin_sources = [\n   'builtin/write-tree.c',\n ]\n \n+third_party_sources = [\n+  ':!contrib',\n+  ':!compat/inet_ntop.c',\n+  ':!compat/inet_pton.c',\n+  ':!compat/nedmalloc',\n+  ':!compat/obstack.*',\n+  ':!compat/poll',\n+  ':!compat/regex',\n+  ':!sha1collisiondetection',\n+  ':!sha1dc',\n+  ':!t/unit-tests/clar',\n+  ':!t/unit-tests/clar',\n+  ':!t/t[0-9][0-9][0-9][0-9]*',\n+]\n+\n+if git.found()\n+  headers = []\n+  foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()\n+    headers += header\n+  endforeach\n+endif\n+\n if not get_option('breaking_changes')\n   builtin_sources += 'builtin/pack-redundant.c'\n endif\n\n-- \n2.48.1\n\n"},{"id":"516146","messageId":"20250414-505-wire-up-sparse-via-meson-v3-3-edc6e7f26745@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-0-edc6e7f26745@gmail.com","subject":"[PATCH v3 3/4] meson: add support for 'hdr-check'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-14T21:16:01Z","receivedAt":"2025-04-14T21:16:08Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The Makefile supports a target called 'hdr-check', which checks if\nindividual header files can be independently compiled. Let's port this\nfunctionality to Meson, our new build system too. The implementation\nresembles that of the Makefile and provides the same check.\n\nSince meson builds are out-of-tree, header dependencies are not\nautomatically met. So unlike the Makefile version, we also need to add\nthe required dependencies.\n\nAlso add the 'xdiff/' dir to the list of 'third_party_sources' as those\nheaders must be skipped from the checks too!\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n meson.build | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 70 insertions(+)\n\ndiff --git a/meson.build b/meson.build\nindex 3ca5d01071..b1be2b3cbb 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -646,6 +646,7 @@ third_party_sources = [\n   ':!t/unit-tests/clar',\n   ':!t/unit-tests/clar',\n   ':!t/t[0-9][0-9][0-9][0-9]*',\n+  ':!xdiff',\n ]\n \n if git.found()\n@@ -655,6 +656,10 @@ if git.found()\n   endforeach\n endif\n \n+generated_headers = [\n+  'command-list.h',\n+]\n+\n if not get_option('breaking_changes')\n   builtin_sources += 'builtin/pack-redundant.c'\n endif\n@@ -669,6 +674,7 @@ builtin_sources += custom_target(\n   ],\n   env: script_environment,\n )\n+generated_headers += 'config-list.h'\n \n builtin_sources += custom_target(\n   input: 'Documentation/githooks.adoc',\n@@ -681,6 +687,7 @@ builtin_sources += custom_target(\n   ],\n   env: script_environment,\n )\n+generated_headers += 'hook-list.h'\n \n # This contains the variables for GIT-BUILD-OPTIONS, which we use to propagate\n # build options to our tests.\n@@ -1995,6 +2002,69 @@ endif\n \n subdir('contrib')\n \n+exclude_from_check_headers = generated_headers\n+exclude_from_check_headers += [\n+  'compat/',\n+  'unicode-width.h',\n+]\n+\n+if sha1_backend != 'openssl'\n+  exclude_from_check_headers += 'sha1/openssl.h'\n+endif\n+if sha256_backend != 'openssl'\n+  exclude_from_check_headers += 'sha256/openssl.h'\n+endif\n+if sha256_backend != 'nettle'\n+  exclude_from_check_headers += 'sha256/nettle.h'\n+endif\n+if sha256_backend != 'gcrpyt'\n+  exclude_from_check_headers += 'sha256/gcrypt.h'\n+endif\n+\n+if git.found() and compiler.get_argument_syntax() == 'gcc'\n+  hco_targets = []\n+  foreach h : headers\n+    skip_header = false\n+    foreach exclude : exclude_from_check_headers\n+      if h.startswith(exclude)\n+        skip_header = true\n+        break\n+      endif\n+    endforeach\n+\n+    if skip_header\n+      continue\n+    endif\n+\n+    hcc = custom_target(\n+      input: h,\n+      output: h.underscorify() + 'cc',\n+      command: [\n+        shell,\n+        '-c',\n+        'echo \\'#include \"git-compat-util.h\"\\' > @OUTPUT@ && echo \\'#include \"' + h + '\"\\' >> @OUTPUT@'\n+      ]\n+    )\n+\n+    hco = custom_target(\n+      input: hcc,\n+      output: fs.replace_suffix(h.underscorify(), '.hco'),\n+      command: [\n+        compiler.cmd_array(),\n+        libgit_c_args,\n+        '-I', meson.project_source_root(),\n+        '-I', meson.project_source_root() / 't/unit-tests',\n+        '-o', '/dev/null',\n+        '-c', '-xc',\n+        '@INPUT@'\n+      ]\n+    )\n+    hco_targets += hco\n+  endforeach\n+\n+  alias_target('hdr-check', hco_targets)\n+endif\n+\n foreach key, value : {\n   'DIFF': diff.full_path(),\n   'GIT_SOURCE_DIR': meson.project_source_root(),\n\n-- \n2.48.1\n\n"},{"id":"516147","messageId":"20250414-505-wire-up-sparse-via-meson-v3-4-edc6e7f26745@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-0-edc6e7f26745@gmail.com","subject":"[PATCH v3 4/4] makefile/meson: add 'check-headers' as alias for 'hdr-check'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-14T21:16:02Z","receivedAt":"2025-04-14T21:16:09Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The 'hdr-check' target in Meson and makefile is used to check if headers\ncan be compiled individually. The naming however isn't readable as 'hdr'\nis not a common shortforme for 'header', neither is it an abbreviation.\n\nLet's introduce 'check-headers' as an alternative target for 'hdr-check'\nand add a `TODO` to deprecate the latter after 2 releases. Since this\nis an internal tool, we can use a shorter deprecation cycle.\n\nChange existing usage of 'hdr-check' in 'ci/run-static-analysis.sh' to\nalso use 'check-headers'.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Makefile                  | 4 +++-\n ci/run-static-analysis.sh | 2 +-\n meson.build               | 2 ++\n 3 files changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex ac32d2d0bd..961ee508be 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -3326,8 +3326,10 @@ HCC = $(HCO:hco=hcc)\n $(HCO): %.hco: %.hcc $(GENERATED_H) FORCE\n \t$(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $<\n \n-.PHONY: hdr-check $(HCO)\n+# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n+.PHONY: hdr-check check-headers $(HCO)\n hdr-check: $(HCO)\n+check-headers: hdr-check\n \n .PHONY: style\n style:\ndiff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh\nindex 0d51e5ce0e..60c175a094 100755\n--- a/ci/run-static-analysis.sh\n+++ b/ci/run-static-analysis.sh\n@@ -26,7 +26,7 @@ then\n \texit 1\n fi\n \n-make hdr-check ||\n+make check-headers ||\n exit 1\n \n make check-pot\ndiff --git a/meson.build b/meson.build\nindex b1be2b3cbb..745cb30165 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -2062,7 +2062,9 @@ if git.found() and compiler.get_argument_syntax() == 'gcc'\n     hco_targets += hco\n   endforeach\n \n+  # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n   alias_target('hdr-check', hco_targets)\n+  alias_target('check-headers', hco_targets)\n endif\n \n foreach key, value : {\n\n-- \n2.48.1\n\n"},{"id":"516152","messageId":"xmqqy0w2o0l0.fsf@gitster.g","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-3-edc6e7f26745@gmail.com","subject":"Re: [PATCH v3 3/4] meson: add support for 'hdr-check'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-04-14T22:11:23Z","receivedAt":"2025-04-14T22:11:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> +if sha256_backend != 'gcrpyt'\n\nThat's a bit unexpected name; relative to this one ...\n\n> +  exclude_from_check_headers += 'sha256/gcrypt.h'\n> +endif\n\n... I have to suspect that it is a typo?\n\n"},{"id":"516162","messageId":"CAOLa=ZTjXetN3GNyvRSHb7mjxhnVd3VLSstnHxw8bAsO6S4wqA@mail.gmail.com","threadId":"63294","inReplyTo":"xmqqy0w2o0l0.fsf@gitster.g","subject":"Re: [PATCH v3 3/4] meson: add support for 'hdr-check'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-15T06:43:03Z","receivedAt":"2025-04-15T06:43:05Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> +if sha256_backend != 'gcrpyt'\n>\n> That's a bit unexpected name; relative to this one ...\n>\n>> +  exclude_from_check_headers += 'sha256/gcrypt.h'\n>> +endif\n>\n> ... I have to suspect that it is a typo?\n\nIndeed, I had to double check cause I couldn't spot it when you\nmentioned. Will fix. Thanks\n"},{"id":"516193","messageId":"23493ec4-fd9f-44ae-a81a-8851e495b427@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-2-edc6e7f26745@gmail.com","subject":"Re: [PATCH v3 2/4] meson: move headers definition from 'contrib/coccinelle'","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-04-15T13:28:16Z","receivedAt":"2025-04-15T13:28:22Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Karthik\n\nOn 14/04/2025 22:16, Karthik Nayak wrote:\n> diff --git a/meson.build b/meson.build\n> index e98cfa4909..3ca5d01071 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -633,6 +633,28 @@ builtin_sources = [\n>     'builtin/write-tree.c',\n>   ]\n>   \n> +third_party_sources = [\n\nThis is not the fault of this patch but I found this name rather \nconfusing as it is not a list of sources but a list of exclude patterns. \nCalling it \"third_party_excludes\" would be clearer to me at least.\n\n> +  ':!contrib',\n> +  ':!compat/inet_ntop.c',\n> +  ':!compat/inet_pton.c',\n> +  ':!compat/nedmalloc',\n> +  ':!compat/obstack.*',\n> +  ':!compat/poll',\n> +  ':!compat/regex',\n> +  ':!sha1collisiondetection',\n> +  ':!sha1dc',\n> +  ':!t/unit-tests/clar',\n> +  ':!t/unit-tests/clar',\n\nAgain not a new problem but this line is a duplicate\n\n> +  ':!t/t[0-9][0-9][0-9][0-9]*',\n> +]\n> +\n> +if git.found()\n> +  headers = []\n\nThis is called \"headers\" but it is only really the subset of our headers \nthat we want to run static analysis on. Maybe we could call it \n\"headers_to_check\" or something that makes it clearer what the list is for.\n\nBest Wishes\n\nPhillip\n\n> +  foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()\n> +    headers += header\n> +  endforeach\n> +endif\n> +\n>   if not get_option('breaking_changes')\n>     builtin_sources += 'builtin/pack-redundant.c'\n>   endif\n> \n"},{"id":"516194","messageId":"958aee61-23eb-4562-af9d-48108e6fe581@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-3-edc6e7f26745@gmail.com","subject":"Re: [PATCH v3 3/4] meson: add support for 'hdr-check'","fromName":"","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-04-15T13:28:40Z","receivedAt":"2025-04-15T13:28:46Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Karthik\n\nOn 14/04/2025 22:16, Karthik Nayak wrote:\n> The Makefile supports a target called 'hdr-check', which checks if\n> individual header files can be independently compiled. Let's port this\n> functionality to Meson, our new build system too. The implementation\n> resembles that of the Makefile and provides the same check.\n> \n> Since meson builds are out-of-tree, header dependencies are not\n> automatically met. So unlike the Makefile version, we also need to add\n> the required dependencies.\n> \n> Also add the 'xdiff/' dir to the list of 'third_party_sources' as those\n> headers must be skipped from the checks too!\n\nDoesn't this mean we'll skip all the xdiff files when running coccinelle \nas well? If so the commit message should point that out and explain why \nthat is an improvement.\n\n> +exclude_from_check_headers = generated_headers\n\nI'm not sure this is necessary. The list of headers that we filter is \ngenerated with \"git ls-files\" and so wont contain generated headers in \nthe first place.\n\n> +exclude_from_check_headers += [\n> +  'compat/',\n> +  'unicode-width.h',\n> +]\n> +\n> +if sha1_backend != 'openssl'\n> +  exclude_from_check_headers += 'sha1/openssl.h'\n> +endif\n> +if sha256_backend != 'openssl'\n> +  exclude_from_check_headers += 'sha256/openssl.h'\n> +endif\n> +if sha256_backend != 'nettle'\n> +  exclude_from_check_headers += 'sha256/nettle.h'\n> +endif\n> +if sha256_backend != 'gcrpyt'\n> +  exclude_from_check_headers += 'sha256/gcrypt.h'\n> +endif\n> +\n> +if git.found() and compiler.get_argument_syntax() == 'gcc'\n> +  hco_targets = []\n> +  foreach h : headers\n> +    skip_header = false\n> +    foreach exclude : exclude_from_check_headers\n> +      if h.startswith(exclude)\n> +        skip_header = true\n> +        break\n> +      endif\n> +    endforeach\n\nThis part looks much more maintainable than than the previous version\n\nThanks\n\nPhillip\n\n> +    if skip_header\n> +      continue\n> +    endif\n> +\n> +    hcc = custom_target(\n> +      input: h,\n> +      output: h.underscorify() + 'cc',\n> +      command: [\n> +        shell,\n> +        '-c',\n> +        'echo \\'#include \"git-compat-util.h\"\\' > @OUTPUT@ && echo \\'#include \"' + h + '\"\\' >> @OUTPUT@'\n> +      ]\n> +    )\n> +\n> +    hco = custom_target(\n> +      input: hcc,\n> +      output: fs.replace_suffix(h.underscorify(), '.hco'),\n> +      command: [\n> +        compiler.cmd_array(),\n> +        libgit_c_args,\n> +        '-I', meson.project_source_root(),\n> +        '-I', meson.project_source_root() / 't/unit-tests',\n> +        '-o', '/dev/null',\n> +        '-c', '-xc',\n> +        '@INPUT@'\n> +      ]\n> +    )\n> +    hco_targets += hco\n> +  endforeach\n> +\n> +  alias_target('hdr-check', hco_targets)\n> +endif\n> +\n>   foreach key, value : {\n>     'DIFF': diff.full_path(),\n>     'GIT_SOURCE_DIR': meson.project_source_root(),\n\n"},{"id":"516195","messageId":"f7d086eb-e616-4bf6-a679-6894ad6eaa85@gmail.com","threadId":"63294","inReplyTo":"20250414-505-wire-up-sparse-via-meson-v3-4-edc6e7f26745@gmail.com","subject":"Re: [PATCH v3 4/4] makefile/meson: add 'check-headers' as alias for 'hdr-check'","fromName":"","fromEmail":"phillip.wood123@gmail.com","sentAt":"2025-04-15T13:28:47Z","receivedAt":"2025-04-15T13:28:53Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Karthik\n\nOn 14/04/2025 22:16, Karthik Nayak wrote:\n> The 'hdr-check' target in Meson and makefile is used to check if headers\n> can be compiled individually. The naming however isn't readable as 'hdr'\n> is not a common shortforme for 'header', neither is it an abbreviation.\n> \n> Let's introduce 'check-headers' as an alternative target for 'hdr-check'\n> and add a `TODO` to deprecate the latter after 2 releases. Since this\n> is an internal tool, we can use a shorter deprecation cycle.\n\nThanks for renaming this. I've left one small question at below but this \nbasically looks good to me.\n\n> diff --git a/Makefile b/Makefile\n> index ac32d2d0bd..961ee508be 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -3326,8 +3326,10 @@ HCC = $(HCO:hco=hcc)\n>   $(HCO): %.hco: %.hcc $(GENERATED_H) FORCE\n>   \t$(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $<\n>   \n> -.PHONY: hdr-check $(HCO)\n> +# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n> +.PHONY: hdr-check check-headers $(HCO)\n>   hdr-check: $(HCO)\n> +check-headers: hdr-check\n>   \n>   .PHONY: style\n>   style:\n> diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh\n> index 0d51e5ce0e..60c175a094 100755\n> --- a/ci/run-static-analysis.sh\n> +++ b/ci/run-static-analysis.sh\n> @@ -26,7 +26,7 @@ then\n>   \texit 1\n>   fi\n>   \n> -make hdr-check ||\n> +make check-headers ||\n>   exit 1\n>   \n>   make check-pot\n> diff --git a/meson.build b/meson.build\n> index b1be2b3cbb..745cb30165 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -2062,7 +2062,9 @@ if git.found() and compiler.get_argument_syntax() == 'gcc'\n>       hco_targets += hco\n>     endforeach\n>   \n> +  # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n>     alias_target('hdr-check', hco_targets)\n> +  alias_target('check-headers', hco_targets)\n\nThis looks good. One minor question which isn't worth a re-roll on its \nown - in the Makefile the check-headers target depends on the hdr-check \ntarget which means the two will always use the same dependencies. Here \nwe make check-headers depend on hco_targets instead which means that in \ntheory the two targets could get out of sync if the dependencies of \nhdr-check changed. Is it possible to have a meson target that depends on \nhdr-check directly?\n\nBest Wishes\n\nPhillip\n\n>   endif\n>   \n>   foreach key, value : {\n> \n\n"},{"id":"516400","messageId":"CAOLa=ZRchwJWQfLDCMASEe9RWMOKDQvTfXaKqO=Shy=jhWMNaQ@mail.gmail.com","threadId":"63294","inReplyTo":"23493ec4-fd9f-44ae-a81a-8851e495b427@gmail.com","subject":"Re: [PATCH v3 2/4] meson: move headers definition from 'contrib/coccinelle'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-20T10:09:01Z","receivedAt":"2025-04-20T10:09:03Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n> Hi Karthik\n>\n> On 14/04/2025 22:16, Karthik Nayak wrote:\n>> diff --git a/meson.build b/meson.build\n>> index e98cfa4909..3ca5d01071 100644\n>> --- a/meson.build\n>> +++ b/meson.build\n>> @@ -633,6 +633,28 @@ builtin_sources = [\n>>     'builtin/write-tree.c',\n>>   ]\n>>\n>> +third_party_sources = [\n>\n> This is not the fault of this patch but I found this name rather\n> confusing as it is not a list of sources but a list of exclude patterns.\n> Calling it \"third_party_excludes\" would be clearer to me at least.\n>\n\nThis seems to map what the Makefile has, but I would agree, that this\nshould be renamed.\n\n>> +  ':!contrib',\n>> +  ':!compat/inet_ntop.c',\n>> +  ':!compat/inet_pton.c',\n>> +  ':!compat/nedmalloc',\n>> +  ':!compat/obstack.*',\n>> +  ':!compat/poll',\n>> +  ':!compat/regex',\n>> +  ':!sha1collisiondetection',\n>> +  ':!sha1dc',\n>> +  ':!t/unit-tests/clar',\n>> +  ':!t/unit-tests/clar',\n>\n> Again not a new problem but this line is a duplicate\n>\n\nFair, considering we're touching these fields, I will add an additional\ncommit to simply cleanup these two issues.\n\n>> +  ':!t/t[0-9][0-9][0-9][0-9]*',\n>> +]\n>> +\n>> +if git.found()\n>> +  headers = []\n>\n> This is called \"headers\" but it is only really the subset of our headers\n> that we want to run static analysis on. Maybe we could call it\n> \"headers_to_check\" or something that makes it clearer what the list is for.\n>\n\nAgreed, will rename. Thanks!\n\n> Best Wishes\n>\n> Phillip\n>\n>> +  foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()\n>> +    headers += header\n>> +  endforeach\n>> +endif\n>> +\n>>   if not get_option('breaking_changes')\n>>     builtin_sources += 'builtin/pack-redundant.c'\n>>   endif\n>>\n"},{"id":"516401","messageId":"CAOLa=ZSYgdY0YnP1Uw83N7oT9R+AUt034ecgPt0ak+RCD3f_6Q@mail.gmail.com","threadId":"63294","inReplyTo":"958aee61-23eb-4562-af9d-48108e6fe581@gmail.com","subject":"Re: [PATCH v3 3/4] meson: add support for 'hdr-check'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-20T10:57:43Z","receivedAt":"2025-04-20T10:57:45Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"phillip.wood123@gmail.com writes:\n\n> Hi Karthik\n>\n> On 14/04/2025 22:16, Karthik Nayak wrote:\n>> The Makefile supports a target called 'hdr-check', which checks if\n>> individual header files can be independently compiled. Let's port this\n>> functionality to Meson, our new build system too. The implementation\n>> resembles that of the Makefile and provides the same check.\n>>\n>> Since meson builds are out-of-tree, header dependencies are not\n>> automatically met. So unlike the Makefile version, we also need to add\n>> the required dependencies.\n>>\n>> Also add the 'xdiff/' dir to the list of 'third_party_sources' as those\n>> headers must be skipped from the checks too!\n>\n> Doesn't this mean we'll skip all the xdiff files when running coccinelle\n> as well? If so the commit message should point that out and explain why\n> that is an improvement.\n>\n\nYes, let me add it to the commit message.\n\n>> +exclude_from_check_headers = generated_headers\n>\n> I'm not sure this is necessary. The list of headers that we filter is\n> generated with \"git ls-files\" and so wont contain generated headers in\n> the first place.\n>\n\nGood point, since generated headers are part of the '.gitignore', we can\nskip the 'generated_headers' variable entirely.\n\n>> +exclude_from_check_headers += [\n>> +  'compat/',\n>> +  'unicode-width.h',\n>> +]\n>> +\n>> +if sha1_backend != 'openssl'\n>> +  exclude_from_check_headers += 'sha1/openssl.h'\n>> +endif\n>> +if sha256_backend != 'openssl'\n>> +  exclude_from_check_headers += 'sha256/openssl.h'\n>> +endif\n>> +if sha256_backend != 'nettle'\n>> +  exclude_from_check_headers += 'sha256/nettle.h'\n>> +endif\n>> +if sha256_backend != 'gcrpyt'\n>> +  exclude_from_check_headers += 'sha256/gcrypt.h'\n>> +endif\n>> +\n>> +if git.found() and compiler.get_argument_syntax() == 'gcc'\n>> +  hco_targets = []\n>> +  foreach h : headers\n>> +    skip_header = false\n>> +    foreach exclude : exclude_from_check_headers\n>> +      if h.startswith(exclude)\n>> +        skip_header = true\n>> +        break\n>> +      endif\n>> +    endforeach\n>\n> This part looks much more maintainable than than the previous version\n>\n\nIndeed. Thanks!\n\n>\n> Thanks\n>\n> Phillip\n>\n>> +    if skip_header\n>> +      continue\n>> +    endif\n>> +\n>> +    hcc = custom_target(\n>> +      input: h,\n>> +      output: h.underscorify() + 'cc',\n>> +      command: [\n>> +        shell,\n>> +        '-c',\n>> +        'echo \\'#include \"git-compat-util.h\"\\' > @OUTPUT@ && echo \\'#include \"' + h + '\"\\' >> @OUTPUT@'\n>> +      ]\n>> +    )\n>> +\n>> +    hco = custom_target(\n>> +      input: hcc,\n>> +      output: fs.replace_suffix(h.underscorify(), '.hco'),\n>> +      command: [\n>> +        compiler.cmd_array(),\n>> +        libgit_c_args,\n>> +        '-I', meson.project_source_root(),\n>> +        '-I', meson.project_source_root() / 't/unit-tests',\n>> +        '-o', '/dev/null',\n>> +        '-c', '-xc',\n>> +        '@INPUT@'\n>> +      ]\n>> +    )\n>> +    hco_targets += hco\n>> +  endforeach\n>> +\n>> +  alias_target('hdr-check', hco_targets)\n>> +endif\n>> +\n>>   foreach key, value : {\n>>     'DIFF': diff.full_path(),\n>>     'GIT_SOURCE_DIR': meson.project_source_root(),\n"},{"id":"516402","messageId":"CAOLa=ZRPjeGP-yF_p-vve22mW8SrtqV_i_4JrjmGt1hRSqrGPg@mail.gmail.com","threadId":"63294","inReplyTo":"f7d086eb-e616-4bf6-a679-6894ad6eaa85@gmail.com","subject":"Re: [PATCH v3 4/4] makefile/meson: add 'check-headers' as alias for 'hdr-check'","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2025-04-20T11:02:08Z","receivedAt":"2025-04-20T11:02:09Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"phillip.wood123@gmail.com writes:\n\n> Hi Karthik\n>\n> On 14/04/2025 22:16, Karthik Nayak wrote:\n>> The 'hdr-check' target in Meson and makefile is used to check if headers\n>> can be compiled individually. The naming however isn't readable as 'hdr'\n>> is not a common shortforme for 'header', neither is it an abbreviation.\n>>\n>> Let's introduce 'check-headers' as an alternative target for 'hdr-check'\n>> and add a `TODO` to deprecate the latter after 2 releases. Since this\n>> is an internal tool, we can use a shorter deprecation cycle.\n>\n> Thanks for renaming this. I've left one small question at below but this\n> basically looks good to me.\n>\n>> diff --git a/Makefile b/Makefile\n>> index ac32d2d0bd..961ee508be 100644\n>> --- a/Makefile\n>> +++ b/Makefile\n>> @@ -3326,8 +3326,10 @@ HCC = $(HCO:hco=hcc)\n>>   $(HCO): %.hco: %.hcc $(GENERATED_H) FORCE\n>>   \t$(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $<\n>>\n>> -.PHONY: hdr-check $(HCO)\n>> +# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n>> +.PHONY: hdr-check check-headers $(HCO)\n>>   hdr-check: $(HCO)\n>> +check-headers: hdr-check\n>>\n>>   .PHONY: style\n>>   style:\n>> diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh\n>> index 0d51e5ce0e..60c175a094 100755\n>> --- a/ci/run-static-analysis.sh\n>> +++ b/ci/run-static-analysis.sh\n>> @@ -26,7 +26,7 @@ then\n>>   \texit 1\n>>   fi\n>>\n>> -make hdr-check ||\n>> +make check-headers ||\n>>   exit 1\n>>\n>>   make check-pot\n>> diff --git a/meson.build b/meson.build\n>> index b1be2b3cbb..745cb30165 100644\n>> --- a/meson.build\n>> +++ b/meson.build\n>> @@ -2062,7 +2062,9 @@ if git.found() and compiler.get_argument_syntax() == 'gcc'\n>>       hco_targets += hco\n>>     endforeach\n>>\n>> +  # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n>>     alias_target('hdr-check', hco_targets)\n>> +  alias_target('check-headers', hco_targets)\n>\n> This looks good. One minor question which isn't worth a re-roll on its\n> own - in the Makefile the check-headers target depends on the hdr-check\n> target which means the two will always use the same dependencies. Here\n> we make check-headers depend on hco_targets instead which means that in\n> theory the two targets could get out of sync if the dependencies of\n> hdr-check changed. Is it possible to have a meson target that depends on\n> hdr-check directly?\n>\n\nThat's a good question, I didn't think much about it then, but looking\ninto it, seems like we can do\n\n  diff --git a/meson.build b/meson.build\n  index 3bf3d65e8b..39319e2610 100644\n  --- a/meson.build\n  +++ b/meson.build\n  @@ -2055,8 +2055,8 @@ if git.found() and\ncompiler.get_argument_syntax() == 'gcc'\n     endforeach\n\n     # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+\n  -  alias_target('hdr-check', hco_targets)\n  -  alias_target('check-headers', hco_targets)\n  +  hdr_check = alias_target('hdr-check', hco_targets)\n  +  alias_target('check-headers', hdr_check)\n   endif\n\n   foreach key, value : {\n\nNot sure if there is a more idiomatic way, but this works. Will add in\nthe next version.\n\n> Best Wishes\n>\n> Phillip\n>\n>>   endif\n>>\n>>   foreach key, value : {\n>>\n"}]}