interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / tools / coccinelle / meson.build

85 lines · 2011 bytes Raw Blame History
1coccinelle_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
6spatch = find_program('spatch', required: coccinelle_opt)
7if not spatch.found()
8 subdir_done()
9endif
10
11rules = [
12 'array.cocci',
13 'commit.cocci',
14 'config_fn_ctx.pending.cocci',
15 'equals-null.cocci',
16 'flex_alloc.cocci',
17 'free.cocci',
18 'git_config_number.cocci',
19 'hashmap.cocci',
20 'index-compatibility.cocci',
21 'object_id.cocci',
22 'preincr.cocci',
23 'qsort.cocci',
24 'refs.cocci',
25 'strbuf.cocci',
26 'swap.cocci',
27 'the_repository.cocci',
28 'xcalloc.cocci',
29 'xopen.cocci',
30 'xstrdup_or_null.cocci',
31 'xstrncmpz.cocci',
32]
33
34concatenated_rules = custom_target(
35 command: [
36 'cat', '@INPUT@',
37 ],
38 input: rules,
39 output: 'rules.cocci',
40 capture: true,
41)
42
43coccinelle_sources = []
44foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_excludes, check: true).stdout().split()
45 coccinelle_sources += source
46endforeach
47
48coccinelle_headers = []
49foreach header : headers_to_check
50 coccinelle_headers += meson.project_source_root() / header
51endforeach
52
53coccinelle_includes = []
54foreach path : ['compat', 'ewah', 'refs', 'sha256', 'trace2', 'win32', 'xdiff']
55 coccinelle_includes += ['-I', meson.project_source_root() / path]
56endforeach
57
58patches = [ ]
59foreach source : coccinelle_sources
60 patches += custom_target(
61 command: [
62 spatch,
63 '--all-includes',
64 '--sp-file', concatenated_rules,
65 '--patch', meson.project_source_root(),
66 coccinelle_includes,
67 '@INPUT@',
68 ],
69 input: meson.project_source_root() / source,
70 output: source.underscorify() + '.patch',
71 capture: true,
72 depend_files: coccinelle_headers,
73 )
74endforeach
75
76concatenated_patch = custom_target(
77 command: [
78 'cat', '@INPUT@',
79 ],
80 input: patches,
81 output: 'cocci.patch',
82 capture: true,
83)
84
85alias_target('coccicheck', concatenated_patch)