Skip to content

Commit

Permalink
Can specify include directories to compiler tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpakkane committed Dec 23, 2016
1 parent a97291d commit 775729e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mesonbuild/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,15 @@ def determine_args(self, kwargs):
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)
Expand Down
3 changes: 3 additions & 0 deletions test cases/linuxlike/1 pkg-config/incdir/myinc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#include<zlib.h>
20 changes: 20 additions & 0 deletions test cases/linuxlike/1 pkg-config/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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.')

0 comments on commit 775729e

Please sign in to comment.