Re: [PATCH 4/4] meson: add rule to run 'git clang-format'
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jun 27, 2025, 08:12 UTC
- Message-ID
- <CAOLa=ZSJH-Wji+-oU+ku5aojYzEuC96tUu+24UTuTxCxt9LYNQ@mail.gmail.com>
- In-Reply-To
- <iutm4xxkhchcpfygtqo2s4nit42sclzen63465ljtovzgdsebr@okpj5jtw62r6>
Justin Tobler <jltobler@gmail.com> writes:
Show 28 quoted lines
> On 25/06/25 06:43PM, Karthik Nayak wrote:
>> The Makefile has a 'style' rule to run 'git clang-format'. While Meson
>> intrinsically supports a 'clang-format' target, which can be run when
>> using the ninja backend by running 'ninja clang-format', this runs the
>> formatting on all existing files.
>>
>> Our Meson build doesn't yet support a way to run 'git clang-format',
>> which runs the formatter between the working directory and commit
>> provided. Add a new 'style' target to Meson to mimic the target in the
>> Makefile.
>>
>> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
>> ---
>> meson.build | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/meson.build b/meson.build
>> index 7fea4a34d6..578db26df2 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -2144,6 +2144,18 @@ if headers_to_check.length() != 0 and compiler.get_argument_syntax() == 'gcc'
>> alias_target('check-headers', hdr_check)
>> endif
>>
>> +clang_format = find_program('clang-format', required: false)
>
> Should we be checking for `git-clang-format` instead?
>Yeah. While `git-clang-format` is packaged with `clang-format`, it does make more sense to check for the former.
Thanks