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

[PATCH] meson: disable coccinelle configuration when building from a tarball

From
Eli Schwartz <eschwartz@gentoo.org>
Date
Mar 25, 2025, 20:05 UTC
Message-ID
<20250325200542.197687-1-eschwartz@gentoo.org>

Wiring up coccinelle in the build, depends on running git commands to get the list of files to operate on. Reasonable, for a feature mainly used by people developing on git. If building git itself from a tarball distribution of git's own source code, one likely does not need to run coccinelle.

But running those git commands failed, and caused the build to error out, if `spatch` was installed -- because the build assumed that its presence indicated a desire to use it on this source tree. Instead, we can expand the conditional to check for both `spatch` and the `.git` file or directory.

Meson's `opt.require()` method allows us to add a prerequisite for the
feature option. If the prerequisite fails, then the option either:
- converts autodetection to disabled
- emits an informative error
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
---
 contrib/coccinelle/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build
index 5d76a7fee6..ea054c924f 100644
--- a/contrib/coccinelle/meson.build
+++ b/contrib/coccinelle/meson.build
@@ -1,4 +1,9 @@
-spatch = find_program('spatch', required: get_option('coccinelle'))
+coccinelle_opt = get_option('coccinelle').require(
+  fs.exists(meson.project_source_root() / '.git'),
+  error_message: 'coccinelle can only be run from a git checkout',
+)
+
+spatch = find_program('spatch', required: coccinelle_opt)
 if not spatch.found()
   subdir_done()
 endif

base-commit: c1d6628c9433c09ff62f916f2b933ee12995e9d8
-- 
2.48.1
Next: Eli Schwartz
Message 1 of 5 in “meson: disable coccinelle configuration when building from a tarball”
  1. meson: disable coccinelle configuration when building from a tarballEli Schwartz, Mar 25, 2025
  2. meson: disable coccinelle configuration when building from a tarballEli Schwartz, Mar 25, 2025
  3. Junio C HamanoMar 25, 2025
  4. Eli SchwartzMar 25, 2025
  5. Patrick SteinhardtMar 26, 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.