meson: add source dir to include_directories automatically

Quite often we need to specify include_directories('.'). Normally, meson
does this automatically, but we specify implicit_include_directories : false,
see 30d20907bd for an explanation.
Passing the include_directories argument through the template layers was rather
cumbersome. Let's simplify things by always including the directory of the
first source file. This makes the definitions simpler, at the cost of having an
unnecessary include directory in the list in some cases.

(Tests are excluded from this change, because they happen to not need this, but
also because some tests have source[0] which is a custom target, and we'd need
newer meson to support that.)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-12-01 15:35:22 +01:00
parent 4c3c60c270
commit 963bebd7b0
10 changed files with 12 additions and 21 deletions

View File

@@ -2334,7 +2334,6 @@ else
}
endif
fuzz_additional_kwargs += {
'include_directories' : include_directories('src/fuzz'),
'c_args' : test_cflags,
}
@@ -2565,9 +2564,9 @@ foreach dict : executables
kwargs = {}
foreach key, val : dict
if key in ['name', 'dbus', 'public', 'conditions',
'type', 'suite', 'timeout', 'parallel',
'objects', 'sources', 'extract']
if key in ['name', 'dbus', 'public', 'conditions', 'type', 'suite',
'timeout', 'parallel', 'objects', 'sources', 'extract',
'include_directories']
continue
endif
@@ -2578,15 +2577,15 @@ foreach dict : executables
kwargs += { key : [ kwargs.get(key, []), val ]}
endforeach
include_directories = dict['include_directories']
if not is_test
include_directories += fs.parent(exe_sources[0])
endif
foreach val : dict.get('objects', [])
obj = objects_by_name[val]
kwargs += {
'objects' : obj['objects'],
'include_directories' : [
kwargs.get('include_directories', []),
obj['include_directories'],
],
}
kwargs += { 'objects' : obj['objects'] }
include_directories += obj['include_directories']
endforeach
if is_test
@@ -2597,6 +2596,7 @@ foreach dict : executables
endif
if is_fuzz
include_directories += include_directories('src/fuzz')
foreach key, val : fuzz_additional_kwargs
if key == 'sources'
exe_sources += val
@@ -2611,6 +2611,7 @@ foreach dict : executables
sources : exe_sources,
kwargs : kwargs,
implicit_include_directories : false,
include_directories : include_directories,
)
executables_by_name += { name : exe }