Skip to content

The equivalent of Make pattern rules in Meson? #11245

Answered by eli-schwartz
epsilon537 asked this question in Q&A
Discussion options

You must be logged in to vote

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…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@epsilon537
Comment options

@eli-schwartz
Comment options

@epsilon537
Comment options

Answer selected by epsilon537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants