public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Toon Claes <toon@iotcl•com>
To: Karthik Nayak <karthik.188@gmail•com>, git@vger•kernel.org
Cc: chriscool@tuxfamily•org, jltobler@gmail•com, gitster@pobox•com,
	Karthik Nayak <karthik.188@gmail•com>
Subject: Re: [PATCH v2 3/3] meson: add rule to run 'git clang-format'
Date: Tue, 01 Jul 2025 15:26:49 +0200	[thread overview]
Message-ID: <87bjq4qbxi.fsf@iotcl.com> (raw)
In-Reply-To: <20250630-525-make-clang-format-more-robust-v2-3-05cbcdbf7817@gmail.com>

Karthik Nayak <karthik.188@gmail•com> writes:

> 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..20ce0525a1 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
>  
> +git_clang_format = find_program('git-clang-format', required: false)

I think we should include `native: true` as well.

> +if git_clang_format.found()
> +  run_target('style',
> +    command: [
> +      'git', 'clang-format',

We should be using the `git_clang_format` variable here to ensure we
call the tool we've found.

> +      '--style', 'file',
> +      '--diff',
> +      '--extensions', 'c,h'
> +    ]
> +  )
> +endif
> +
>  foreach key, value : {
>    'DIFF': diff.full_path(),
>    'GIT_SOURCE_DIR': meson.project_source_root(),
>
> -- 
> 2.49.0
>
>

-- 
Cheers,
Toon

  parent reply	other threads:[~2025-07-01 13:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 16:43 [PATCH 0/4] clang-format: modify rules to reduce false-positives Karthik Nayak
2025-06-25 16:43 ` [PATCH 1/4] editorconfig: set maximum line length to 120 characters Karthik Nayak
2025-06-25 18:41   ` Junio C Hamano
2025-06-26  8:27     ` Karthik Nayak
2025-06-26 14:25       ` Junio C Hamano
2025-06-27  8:38         ` Karthik Nayak
2025-06-26 16:22   ` Justin Tobler
2025-06-27  8:51     ` Karthik Nayak
2025-06-27 15:12       ` Justin Tobler
2025-06-30  8:29         ` Karthik Nayak
2025-06-25 16:43 ` [PATCH 2/4] clang-format: set 'ColumnLimit' to 0 Karthik Nayak
2025-06-25 16:43 ` [PATCH 3/4] clang-format: add 'RemoveBracesLLVM' to the main config Karthik Nayak
2025-06-25 16:43 ` [PATCH 4/4] meson: add rule to run 'git clang-format' Karthik Nayak
2025-06-26 16:35   ` Justin Tobler
2025-06-27  8:12     ` Karthik Nayak
2025-06-27 14:25       ` Junio C Hamano
2025-06-30  8:34         ` Karthik Nayak
2025-06-30 15:24           ` Junio C Hamano
2025-06-30  8:38 ` [PATCH v2 0/3] clang-format: modify rules to reduce false-positives Karthik Nayak
2025-06-30  8:38   ` [PATCH v2 1/3] clang-format: set 'ColumnLimit' to 0 Karthik Nayak
2025-06-30  8:38   ` [PATCH v2 2/3] clang-format: add 'RemoveBracesLLVM' to the main config Karthik Nayak
2025-06-30  8:38   ` [PATCH v2 3/3] meson: add rule to run 'git clang-format' Karthik Nayak
2025-07-01 10:13     ` Patrick Steinhardt
2025-07-01 15:08       ` Karthik Nayak
2025-07-01 16:02       ` Junio C Hamano
2025-07-01 13:26     ` Toon Claes [this message]
2025-07-01 15:12       ` Karthik Nayak
2025-07-02  2:54         ` Patrick Steinhardt
2025-06-30 15:27   ` [PATCH v2 0/3] clang-format: modify rules to reduce false-positives Junio C Hamano
2025-07-01 13:36   ` Toon Claes
2025-07-01 15:19     ` Karthik Nayak
2025-07-01 20:49     ` Junio C Hamano
2025-07-02  9:23 ` [PATCH v3 " Karthik Nayak
2025-07-02  9:23   ` [PATCH v3 1/3] clang-format: set 'ColumnLimit' to 0 Karthik Nayak
2025-07-02  9:23   ` [PATCH v3 2/3] clang-format: add 'RemoveBracesLLVM' to the main config Karthik Nayak
2025-07-02  9:23   ` [PATCH v3 3/3] meson: add rule to run 'git clang-format' Karthik Nayak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bjq4qbxi.fsf@iotcl.com \
    --to=toon@iotcl$(echo .)com \
    --cc=chriscool@tuxfamily$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=jltobler@gmail$(echo .)com \
    --cc=karthik.188@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox