Can specify include directories to compiler tests.

pull/1256/head
Jussi Pakkanen 8 years ago
parent a97291dc6d
commit 775729eb59
  1. 9
      mesonbuild/interpreter.py
  2. 3
      test cases/linuxlike/1 pkg-config/incdir/myinc.h
  3. 20
      test cases/linuxlike/1 pkg-config/meson.build

@ -636,6 +636,15 @@ class CompilerHolder(InterpreterObject):
if not isinstance(nobuiltins, bool):
raise InterpreterException('Type of no_builtin_args not a boolean.')
args = []
incdirs = kwargs.get('include_directories', [])
if not isinstance(incdirs, list):
incdirs = [incdirs]
for i in incdirs:
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)
args += self.compiler.get_include_args(idir, False)
if not nobuiltins:
opts = self.environment.coredata.compiler_options
args += self.compiler.get_option_compile_args(opts)

@ -0,0 +1,3 @@
#pragma once
#include<zlib.h>

@ -26,3 +26,23 @@ test('zlibtest2', exe2)
# Try to find a nonexistant library to ensure requires:false works.
dep = dependency('nvakuhrabnsdfasdf', required : false)
# Try to compile a test that takes a dep and an include_directories
cc = meson.get_compiler('c')
zlibdep = cc.find_library('z')
code = '''#include<myinc.h>
int main(int argc, char **argv) {
void * something = deflate;
if(something != 0)
return 0;
return 1;
}
'''
inc = include_directories('incdir')
r = cc.run(code, include_directories : inc, dependencies : zlibdep)
assert(r.returncode() == 0, 'Running manual zlib test failed.')

Loading…
Cancel
Save