Assume that above situation, I configured meson build like the code below.
project('tutorial', ['c'], version : '1.0v')
src = files(['file1.c', 'file2.c', 'file3.c'])
executable('tutorial',
sources : [src],
c_args : [CFLAGS],
link_args : [LDFLAGS, LDFLAGS_OUTPUT])
how can i specific directory build using regular expression like as
src = files(['*.c']) or
or useful meson fuction? (method)? like as
meson.src_dir('src/')
is that possible?
CodePudding user response:
Yes, there is a subdir() function that you can use to "include" folder with another meson.build file.
src = ...
subdir('src')
executable(...)
In that sub-directory you should have separate meson.build file with files():
src = files('a.c', 'b.c')
- just file names, no need adding parent directory here
- you don't need brackets as files function accepts infinite number of arguments
- regular expressions, globbing are not supported by meson - this is to have defined result, i.e. no unexpected or implicit behavior.
PS
Regarding file globbing check this question; apparently there is a workaround by running external shell scripts and using then result, but this is not recommended anyway (and most probably that's the reason why it's not possible with files() ): it wouldn't be possible for meson to notice added files - user needs to remember to re-run meson project build (which is long and not how it's meant to be), not just ninja.