From a176588151bd5809ed85929d5513cfd5a8791473 Mon Sep 17 00:00:00 2001 From: Philipp Ittershagen Date: Wed, 25 Oct 2017 19:58:57 +0200 Subject: [PATCH] fix include_directories handling in subprojects for compiler tests. --- mesonbuild/interpreter.py | 3 ++- .../common/163 includedir subproj/meson.build | 9 +++++++++ test cases/common/163 includedir subproj/prog.c | 4 ++++ .../subprojects/inctest/include/incfile.h | 2 ++ .../subprojects/inctest/meson.build | 13 +++++++++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test cases/common/163 includedir subproj/meson.build create mode 100644 test cases/common/163 includedir subproj/prog.c create mode 100644 test cases/common/163 includedir subproj/subprojects/inctest/include/incfile.h create mode 100644 test cases/common/163 includedir subproj/subprojects/inctest/meson.build diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 28cb5ad27..b90a88c38 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -696,7 +696,8 @@ class CompilerHolder(InterpreterObject): if not isinstance(i, IncludeDirsHolder): raise InterpreterException('Include directories argument must be an include_directories object.') for idir in i.held_object.get_incdirs(): - idir = os.path.join(self.environment.get_source_dir(), idir) + idir = os.path.join(self.environment.get_source_dir(), + i.held_object.get_curdir(), idir) args += self.compiler.get_include_args(idir, False) if not nobuiltins: opts = self.environment.coredata.compiler_options diff --git a/test cases/common/163 includedir subproj/meson.build b/test cases/common/163 includedir subproj/meson.build new file mode 100644 index 000000000..b3de5af6c --- /dev/null +++ b/test cases/common/163 includedir subproj/meson.build @@ -0,0 +1,9 @@ +project('include dir in subproj test', 'c') + + +subproject('inctest') + + +exe = executable('prog', 'prog.c') + +test('dummy', exe) diff --git a/test cases/common/163 includedir subproj/prog.c b/test cases/common/163 includedir subproj/prog.c new file mode 100644 index 000000000..772681ea8 --- /dev/null +++ b/test cases/common/163 includedir subproj/prog.c @@ -0,0 +1,4 @@ + +int main(int argc, char **argv) { + return 0; +} diff --git a/test cases/common/163 includedir subproj/subprojects/inctest/include/incfile.h b/test cases/common/163 includedir subproj/subprojects/inctest/include/incfile.h new file mode 100644 index 000000000..ec740dab0 --- /dev/null +++ b/test cases/common/163 includedir subproj/subprojects/inctest/include/incfile.h @@ -0,0 +1,2 @@ + +/* file which is used in the subproject */ diff --git a/test cases/common/163 includedir subproj/subprojects/inctest/meson.build b/test cases/common/163 includedir subproj/subprojects/inctest/meson.build new file mode 100644 index 000000000..74aabcb6d --- /dev/null +++ b/test cases/common/163 includedir subproj/subprojects/inctest/meson.build @@ -0,0 +1,13 @@ + +project('subproj with includedir', 'c') + + + +compile_check = ''' +#include "incfile.h" +''' + +if not meson.get_compiler('c').compiles(compile_check, name : 'include in subproj', + include_directories: include_directories('include')) + error('failed') +endif