custom_target and globbing 'input': how?

6 views
Skip to first unread message

Max-Julian Pogner

unread,
Apr 14, 2023, 1:50:42 PM4/14/23
to meson...@googlegroups.com
Hello!

i have searches the mesonbuild.com homepage, and any other meson howto i
could find via google, but to no avail. The actual globbing seems not
possible, even outside a custom_target.


I have a custom_target, where the 'input' argument should be (the list
of) every file in a src/template/ directory.
At the moment i found only the option to manually list all the files,
which i want to avoid.

However, what i would like to do is some kind of globbing, where i can
tell meson that "every file in src/template/" is an input.

What i like to achieve with this is, that a change to any of these input
files will tell meson that this custom_target needs to be re-executed,
and if all files remain unchanged, that the previous execution can be
re-used.


In short: how to do `input: files('src/template/*')` in a custom_target
in meson?


best regards!

Max

Eli Schwartz

unread,
Apr 14, 2023, 2:25:17 PM4/14/23
to Max-Julian Pogner, meson...@googlegroups.com
On 4/14/23 1:50 PM, Max-Julian Pogner wrote:
> Hello!
>
> i have searches the mesonbuild.com homepage, and any other meson howto i
> could find via google, but to no avail. The actual globbing seems not
> possible, even outside a custom_target.
>
>
> I have a custom_target, where the 'input' argument should be (the list
> of) every file in a src/template/ directory.
> At the moment i found only the option to manually list all the files,
> which i want to avoid.
>
> However, what i would like to do is some kind of globbing, where i can
> tell meson that "every file in src/template/" is an input.


Here is an argument against the use of wildcards/globbing:
https://mesonbuild.com/FAQ.html#why-cant-i-specify-target-files-with-a-wildcard


Here is a description of how you can do it anyway, along with the caveats:
https://mesonbuild.com/FAQ.html#but-i-really-want-to-use-wildcards


> What i like to achieve with this is, that a change to any of these input
> files will tell meson that this custom_target needs to be re-executed,
> and if all files remain unchanged, that the previous execution can be
> re-used.


I am not certain what you mean by this, since a custom_target doesn't
get "executed", but rather "built".

Changes to the file *contents* of files which are evaluated as build
inputs will always, no matter what, result in the `command:` being rerun
to rebuild that target.

The use of globbing doesn't change that -- globbing only affects the
list of file *names* which are evaluated as build inputs.


--
Eli Schwartz

Max-Julian Pogner

unread,
Apr 16, 2023, 7:39:28 PM4/16/23
to meson...@googlegroups.com


On 14/04/2023 20:25, Eli Schwartz wrote:
> On 4/14/23 1:50 PM, Max-Julian Pogner wrote:
> Here is an argument against the use of wildcards/globbing:
> https://mesonbuild.com/FAQ.html#why-cant-i-specify-target-files-with-a-wildcard
>
>
> Here is a description of how you can do it anyway, along with the caveats:
> https://mesonbuild.com/FAQ.html#but-i-really-want-to-use-wildcards

... apparently i acted like a noob; it was in the faq, i looked in the
faq but could not identify the obvious.

sorry about that.


>> What i like to achieve with this is, that a change to any of these input
>> files will tell meson that this custom_target needs to be re-executed,
>> and if all files remain unchanged, that the previous execution can be
>> re-used.
>
> I am not certain what you mean by this, since a custom_target doesn't
> get "executed", but rather "built".

I meant, that the command of the custom_target is (conditionally)
executed, (re-)building the output(s).


> Changes to the file *contents* of files which are evaluated as build
> inputs will always, no matter what, result in the `command:` being rerun
> to rebuild that target.
>
> The use of globbing doesn't change that -- globbing only affects the
> list of file *names* which are evaluated as build inputs.

I see in the faq the problem with the need to re-evaluate the globbing
and performance. I think i will now be able to make it work somehow.


thank you for the help!

~~ Max
Reply all
Reply to author
Forward
0 new messages