diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-06-21 00:18:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-21 00:18:09 +0300 |
commit | 642b4ddf71bd2865739570c80135687a8f9bac13 (patch) | |
tree | f781ff2c16348182278a352e1472067463dba78c | |
parent | cd509043e097a44f6f5195b6e842dfefbaa79104 (diff) | |
parent | 0623f71e3629fa4e736086cf7b61aeddf623ed0c (diff) | |
download | meson-642b4ddf71bd2865739570c80135687a8f9bac13.zip meson-642b4ddf71bd2865739570c80135687a8f9bac13.tar.gz meson-642b4ddf71bd2865739570c80135687a8f9bac13.tar.bz2 |
Merge pull request #607 from centricular/subdir-include-order
Add subdir includes before external dep includes
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 15 | ||||
-rw-r--r-- | test cases/linuxlike/6 subdir include order/meson.build | 12 | ||||
-rw-r--r-- | test cases/linuxlike/6 subdir include order/prog.c | 7 | ||||
-rw-r--r-- | test cases/linuxlike/6 subdir include order/subdir/glib.h | 1 |
4 files changed, 28 insertions, 7 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index eb2579d..6ec5e3d 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1422,21 +1422,21 @@ rule FORTRAN_DEP_HACK commands = [] # The first thing is implicit include directories: source, build and private. commands += compiler.get_include_args(self.get_target_private_dir(target), False) + # Compiler args for compiling this target commands += compilers.get_base_compile_args(self.environment.coredata.base_options, compiler) + # Add the root source and build directories as include dirs curdir = target.get_subdir() tmppath = os.path.normpath(os.path.join(self.build_to_src, curdir)) commands += compiler.get_include_args(tmppath, False) if curdir == '': curdir = '.' commands += compiler.get_include_args(curdir, False) - commands += self.generate_basic_compiler_args(target, compiler) - # -I args work differently than other ones. In them the - # first found directory is used whereas for other flags - # (such as -ffoo -fno-foo) the latest one is used. - # Therefore put the internal include directories here - # at the beginning so they override args coming from - # e.g. pkg-config. + # -I args work differently than other ones. In them the first found + # directory is used whereas for other flags (such as -ffoo -fno-foo) the + # latest one is used. Therefore put the internal include directories + # here before generating the "basic compiler args" so they override args + # coming from e.g. pkg-config. for i in target.get_include_dirs(): basedir = i.get_curdir() for d in i.get_incdirs(): @@ -1448,6 +1448,7 @@ rule FORTRAN_DEP_HACK commands += sargs for d in i.get_extra_build_dirs(): commands += compiler.get_include_args(d, i.is_system) + commands += self.generate_basic_compiler_args(target, compiler) for d in target.external_deps: if d.need_threads(): commands += compiler.thread_flags() diff --git a/test cases/linuxlike/6 subdir include order/meson.build b/test cases/linuxlike/6 subdir include order/meson.build new file mode 100644 index 0000000..fea3984 --- /dev/null +++ b/test cases/linuxlike/6 subdir include order/meson.build @@ -0,0 +1,12 @@ +project('subdir include order', 'c') + +# Ensure that headers in subdirs override external dependencies +cc = meson.get_compiler('c') + +glib = dependency('glib-2.0') + +# This will fail to compile if it picks up the system-installed glib instead of +# the glib in the subdir +executable('prog', 'prog.c', + include_directories : include_directories('subdir'), + dependencies : glib) diff --git a/test cases/linuxlike/6 subdir include order/prog.c b/test cases/linuxlike/6 subdir include order/prog.c new file mode 100644 index 0000000..9c8af35 --- /dev/null +++ b/test cases/linuxlike/6 subdir include order/prog.c @@ -0,0 +1,7 @@ +#include <glib.h> + +#ifndef MESON_OUR_GLIB +#error "Failed" +#endif + +int main() { return 0; } diff --git a/test cases/linuxlike/6 subdir include order/subdir/glib.h b/test cases/linuxlike/6 subdir include order/subdir/glib.h new file mode 100644 index 0000000..444b2d0 --- /dev/null +++ b/test cases/linuxlike/6 subdir include order/subdir/glib.h @@ -0,0 +1 @@ +#define MESON_OUR_GLIB 1 |