Subject: Re: [PATCH v2 3/4] meson: add support for 'hdr-check'

From: Toon Claes <[email-masked]>
Date: Mon, 14 Apr 2025 10:45:49 +0200

Karthik Nayak <[email-masked]> writes:

> The Makefile supports a target called 'hdr-check', which checks if
> individual header files can be independently compiled. Let's port this
> functionality to meson, our new build system too. The implementation
> resembles that of the Makefile and provides the same check.
>
> Signed-off-by: Karthik Nayak <[email-masked]>
> ---
>  meson.build | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 107 insertions(+)
>
> diff --git a/meson.build b/meson.build
> index 790d178007..6fce1aa618 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -655,6 +655,12 @@ if git.found()
>    endforeach
>  endif
>  
> +headers_generated = [
> +  'command-list.h',
> +  'config-list.h',
> +  'hook-list.h'
> +]

Can we maybe compose this list by instead doing:

    generated_headers = []
    foreach f : builtin_sources + libgit_sources + third_party_sources
      if f.endswith(".h")
        generated_headers += f
      endif
    endforeach

(This would take `third_party_sources` into account as suggested by
Patrick[1]).

If we consider that too much magic, I would suggest:

    generated_headers = []
    builtin_sources += custom_target(
      output: 'config-list.h',
      command: [
        shell,
        meson.current_source_dir() + '/generate-configlist.sh',
        meson.current_source_dir(),
        '@OUTPUT@',
      ],
      env: script_environment,
    )
    generated_headers += 'config-list.h'

I hope this would reduce the chance to forget to add more headers to
this list (assuming people copy the code blurb from another location).

--
Toon