git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 2/4] meson: move headers definition from 'contrib/coccinelle'

From
Karthik Nayak <karthik.188@gmail.com>
Date
Apr 14, 2025, 21:16 UTC
Message-ID
<20250414-505-wire-up-sparse-via-meson-v3-2-edc6e7f26745@gmail.com>
In-Reply-To
<20250414-505-wire-up-sparse-via-meson-v3-0-edc6e7f26745@gmail.com>

The Meson build for coccinelle static analysis lists all headers to analyse. Due to the way Meson exports variables between subdirs, this variable is also available in the root Meson build.

An upcoming commit, will add a new check complimenting 'hdr-check' in the Makefile. This would require the list of headers. So move the 'coccinelle_headers' to the root Meson build and rename it to 'headers', remove the root path being appended to each header and retain that in the coccinelle Meson build since it is specific to the coccinelle build.

Also move the 'third_party_sources' variable to the root Meson build since it is also a dependency for the 'headers' variable. This also makes it easier to understand as the variable is now propagated from the top level to the bottom.

Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
---
 contrib/coccinelle/meson.build | 17 +----------------
 meson.build                    | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build
index 03ce52d752..32568c5103 100644
--- a/contrib/coccinelle/meson.build
+++ b/contrib/coccinelle/meson.build
@@ -8,21 +8,6 @@ if not spatch.found()
   subdir_done()
 endif
 
-third_party_sources = [
-  ':!contrib',
-  ':!compat/inet_ntop.c',
-  ':!compat/inet_pton.c',
-  ':!compat/nedmalloc',
-  ':!compat/obstack.*',
-  ':!compat/poll',
-  ':!compat/regex',
-  ':!sha1collisiondetection',
-  ':!sha1dc',
-  ':!t/unit-tests/clar',
-  ':!t/unit-tests/clar',
-  ':!t/t[0-9][0-9][0-9][0-9]*',
-]
-
 rules = [
   'array.cocci',
   'commit.cocci',
@@ -61,7 +46,7 @@ foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files',
 endforeach
 
 coccinelle_headers = []
-foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()
+foreach header : headers
   coccinelle_headers += meson.project_source_root() / header
 endforeach
 
diff --git a/meson.build b/meson.build
index e98cfa4909..3ca5d01071 100644
--- a/meson.build
+++ b/meson.build
@@ -633,6 +633,28 @@ builtin_sources = [
   'builtin/write-tree.c',
 ]
 
+third_party_sources = [
+  ':!contrib',
+  ':!compat/inet_ntop.c',
+  ':!compat/inet_pton.c',
+  ':!compat/nedmalloc',
+  ':!compat/obstack.*',
+  ':!compat/poll',
+  ':!compat/regex',
+  ':!sha1collisiondetection',
+  ':!sha1dc',
+  ':!t/unit-tests/clar',
+  ':!t/unit-tests/clar',
+  ':!t/t[0-9][0-9][0-9][0-9]*',
+]
+
+if git.found()
+  headers = []
+  foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split()
+    headers += header
+  endforeach
+endif
+
 if not get_option('breaking_changes')
   builtin_sources += 'builtin/pack-redundant.c'
 endif
-- 
2.48.1
Previous: Karthik NayakNext: Phillip Wood
Message 3 of 13 in “meson: add corresponding target for Makefile's hdr-check”
  1. 0/4 meson: add corresponding target for Makefile's hdr-checkKarthik Nayak, Apr 14, 2025
  2. 1/4 coccinelle: meson: rename variables to be more specificKarthik Nayak, Apr 14, 2025
  3. 2/4 meson: move headers definition from 'contrib/coccinelle'Karthik Nayak, Apr 14, 2025
  4. Phillip WoodApr 15, 2025
  5. Karthik NayakApr 20, 2025
  6. 3/4 meson: add support for 'hdr-check'Karthik Nayak, Apr 14, 2025
  7. Junio C HamanoApr 14, 2025
  8. Karthik NayakApr 15, 2025
  9. phillip.wood123@gmail.comApr 15, 2025
  10. Karthik NayakApr 20, 2025
  11. 4/4 makefile/meson: add 'check-headers' as alias for 'hdr-check'Karthik Nayak, Apr 14, 2025
  12. phillip.wood123@gmail.comApr 15, 2025
  13. Karthik NayakApr 20, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.