The equivalent of Make pattern rules in Meson? #11245
-
Hi, I was wondering if it's possible to express the equivalent of a Make pattern rule in Meson?
Can I do this in Meson? I have a feeling that the answer is going to be 'pattern rules are the root of all evil' or something like that, but I couldn't info any info about it in the context of Meson. Thanks for any help/insight. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Pattern rules are just another way to say "use the same commands for multiple targets". Since Meson is a generator of ninja files, and ninja itself is the equivalent of Make, what ends up happening is that you can specify a command pattern in Meson by using foreach loops: targets: [mem, files, from, bender]
foreach t: targets
custom_target(output: t, command: [recipe, to, generate, a, mem, file])
endforeach Technical note: ninja does not support pattern rules, instead reasoning that as you will use a generator anyway, the generator should grok the pattern and then write out the full list of targets. Pattern rules, and the need to expand and validate them, are one cause of slowness in Make, so, Ninja claims that it's able to be faster by not supporting pattern rules. When the build system generator (such as Meson) performs this calculation instead, it can do so once and "freeze" that list during configuration. |
Beta Was this translation helpful? Give feedback.
Pattern rules are just another way to say "use the same commands for multiple targets". Since Meson is a generator of ninja files, and ninja itself is the equivalent of Make, what ends up happening is that you can specify a command pattern in Meson by using foreach loops:
Technical note: ninja does not support pattern rules, instead reasoning that as you will use a generator anyway, the generator should grok the pattern and then write out the full list of targets. Pattern rules, and the need to expand and validate them, are one cause of slowness in…