Kilian Hanich via devel wrote:
Meson doesn't allow you do create your own functions. While one
should
try to avoid them in build systems, there are cases where you need them.
I work on a project where they are needed, but it also wouldn't make
sense to upstream it because it's too project specific, and creating a
loop out of every call like Meson's FAQ recommends
(
https://mesonbuild.com/FAQ.html#why-doesnt-meson-have-user-defined-functi...)
would create one heck of spagetthi code.
Yes, that is exactly what makes Meson all hardcoded and not extensible. If
you need to do anything that the Meson developers did not think of, you end
up having to work around the build system (using external commands, or a
Meson file generator that preprocesses macros, or some other ugly hack)
instead of with the build system or just having to switch to a better build
system (such as CMake ;-) ).
Using loops instead of functions or macros also misses one important point:
the function or macro can be shared between projects and even eventually
upstreamed to the build system (both of which happen regularly in the CMake
world).
By the way, CMake allows defining both macros and actual functions, and
macros are what you want to use in most cases. The main reason functions
were introduced is to allow recursion (which is a two-edged sword because it
makes the language Turing-complete with all its implications).
Kevin Kofler