Skip to content

Commit d2827dc

Browse files
eli-schwartzgitster
authored andcommitted
meson: disable coccinelle configuration when building from a tarball
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 if the feature was set to enabled: ``` ERROR: Feature coccinelle cannot be enabled: coccinelle can only be run from a git checkout ``` Signed-off-by: Eli Schwartz <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 683c54c commit d2827dc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/coccinelle/meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
spatch = find_program('spatch', required: get_option('coccinelle'))
1+
coccinelle_opt = get_option('coccinelle').require(
2+
fs.exists(meson.project_source_root() / '.git'),
3+
error_message: 'coccinelle can only be run from a git checkout',
4+
)
5+
6+
spatch = find_program('spatch', required: coccinelle_opt)
27
if not spatch.found()
38
subdir_done()
49
endif

0 commit comments

Comments
 (0)