Improve error message for `include_directories(abs_path_intree)`

This error message was quite confusing when triggered by
use of an absolute path to the include dir of an external dependency
(numpy in my case). Changing that to a relative dir also isn't
a solution, because Meson will *not* do the "busywork to make paths
work" that the error message says it will.
pull/10573/head
Ralf Gommers 2 years ago committed by Eli Schwartz
parent af846a109f
commit 17936686d4
  1. 9
      mesonbuild/interpreter/interpreter.py
  2. 2
      test cases/failing/44 abspath to srcdir/test.json

@ -2583,8 +2583,9 @@ class Interpreter(InterpreterBase, HoldableObject):
for a in incdir_strings:
if a.startswith(src_root):
raise InvalidArguments(textwrap.dedent('''\
Tried to form an absolute path to a source dir.
You should not do that but use relative paths instead.
Tried to form an absolute path to a dir in the source tree.
You should not do that but use relative paths instead, for
directories that are part of your project.
To get include path to any directory relative to the current dir do
@ -2599,6 +2600,10 @@ class Interpreter(InterpreterBase, HoldableObject):
put in the include directories by default so you only need to do
include_directories('.') if you intend to use the result in a
different subdirectory.
Note that this error message can also be triggered by
external dependencies being installed within your source
tree - it's not recommended to do this.
'''))
else:
try:

@ -1,7 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/44 abspath to srcdir/meson.build:3:0: ERROR: Tried to form an absolute path to a source dir."
"line": "test cases/failing/44 abspath to srcdir/meson.build:3:0: ERROR: Tried to form an absolute path to a dir in the source tree."
}
]
}

Loading…
Cancel
Save