Is the directory return by meson.source_root() the project root directory (with the root level meson.build file) or is it the path of the current meson.build file being processed?
Is `meson.source_root()` the project root directory?
Asked Answered
The project root directory is obtained with the following meson syntax:
meson.source_root()
The current source directory can be obtained with the following meson syntax:
meson.current_source_dir()
@slamander I just tried what you suggested and it didn't work for me. It's possible we're talking about different things, but if have source root
/some/dir
and current source dir some/dir/src
then current_source_dir()
gives me /some/dir/./src
and join_paths() as you show above gives me the same thing. I did the following to fix this, but there may be a better/easier way (it's my first day with meson): curDir = meson.current_source_dir()
curDir = curDir.split('.')
curDir = curDir[0] + curDir[1]
curDir = curDir.split('//')
curDir = join_paths(curDir[0], curDir[1])
–
Counts Ran out of space in my previous comment, but the code I provided there is brittle if you have dirtectory names that contain '.' characters. What I did was to encose everything after the
curDir = meson.current_source_dir()
in if ( curDir.contains('/./') )
to ensure it doesn't execute on random '.' chars. –
Counts Please mention that
source_root()
is deprecated in preference of (depending on what you want): current_source_dir()
, project_source_root()
, or global_source_root()
. –
Remittent © 2022 - 2024 — McMap. All rights reserved.
join_paths(meson.source_root(), meson.current_source_dir())
. – Laser