6

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?

oz10
  • 153,307
  • 27
  • 93
  • 128

1 Answers1

6

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()
oz10
  • 153,307
  • 27
  • 93
  • 128
  • Something "disturbing" is that current_source_dir() gives a relative path to the source_root(), so I always need to do `join_paths(meson.source_root(), meson.current_source_dir())`. – Salamandar Nov 28 '17 at 17:09
  • @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])` – Loss Mentality Sep 03 '18 at 00:12
  • 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. – Loss Mentality Sep 03 '18 at 00:20