From 17936686d473fe07b6a7cf1c3b80a21f220ce06e Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Sun, 29 May 2022 23:40:01 +0200 Subject: [PATCH] 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. --- mesonbuild/interpreter/interpreter.py | 9 +++++++-- test cases/failing/44 abspath to srcdir/test.json | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 778a4d601..4191bee33 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -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: diff --git a/test cases/failing/44 abspath to srcdir/test.json b/test cases/failing/44 abspath to srcdir/test.json index 2cc298045..c64ecfbd6 100644 --- a/test cases/failing/44 abspath to srcdir/test.json +++ b/test cases/failing/44 abspath to srcdir/test.json @@ -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." } ] }