Always flatten include_directories lists

pull/4729/head
Xavier Claessens 6 years ago committed by Jussi Pakkanen
parent 90c9b868b2
commit aa840afb3a
  1. 14
      mesonbuild/interpreter.py
  2. 2
      test cases/common/19 includedir/src/meson.build
  3. 2
      test cases/common/84 declare dep/entity/meson.build

@ -2209,7 +2209,7 @@ class Interpreter(InterpreterBase):
version = kwargs.get('version', self.project_version)
if not isinstance(version, str):
raise InterpreterException('Version must be a string.')
incs = self.entries_to_incdirs(extract_as_list(kwargs, 'include_directories', unholder=True))
incs = self.extract_incdirs(kwargs)
libs = extract_as_list(kwargs, 'link_with', unholder=True)
libs_whole = extract_as_list(kwargs, 'link_whole', unholder=True)
sources = extract_as_list(kwargs, 'sources')
@ -3698,15 +3698,14 @@ This will become a hard error in the future.''' % kwargs['input'])
self.build.data.append(build.Data([cfile], idir, install_mode))
return mesonlib.File.from_built_file(self.subdir, output)
def entries_to_incdirs(self, prospectives):
if not isinstance(prospectives, list):
return self.entries_to_incdirs([prospectives])[0]
def extract_incdirs(self, kwargs):
prospectives = listify(kwargs.get('include_directories', []), unholder=True)
result = []
for p in prospectives:
if isinstance(p, (IncludeDirsHolder, build.IncludeDirs)):
if isinstance(p, build.IncludeDirs):
result.append(p)
elif isinstance(p, str):
result.append(self.build_incdir_object([p]))
result.append(self.build_incdir_object([p]).held_object)
else:
raise InterpreterException('Include directory objects can only be created from strings or include directories.')
return result
@ -4072,8 +4071,7 @@ Try setting b_lundef to false instead.'''.format(self.coredata.base_options['b_s
# passed to library() when default_library == 'static'.
kwargs = {k: v for k, v in kwargs.items() if k in targetclass.known_kwargs}
if 'include_directories' in kwargs:
kwargs['include_directories'] = self.entries_to_incdirs(kwargs['include_directories'])
kwargs['include_directories'] = self.extract_incdirs(kwargs)
target = targetclass(name, self.subdir, self.subproject, is_cross, sources, objs, self.environment, kwargs)
if is_cross:

@ -1,5 +1,5 @@
exe = executable('prog', 'prog.c', 'func.c', include_directories : inc)
test('inc test', exe)
exe2 = executable('prog2', 'prog.c', 'func.c', include_directories : '../include')
exe2 = executable('prog2', 'prog.c', 'func.c', include_directories : [['../include']])
test('inc test 2', exe2)

@ -1,7 +1,7 @@
entity_lib = static_library('entity', 'entity1.c')
entity_dep = declare_dependency(link_with : [[entity_lib]],
include_directories : '.',
include_directories : [['.']],
sources : 'entity2.c',
compile_args : ['-DUSING_ENT=1'],
version : '1.2.3',

Loading…
Cancel
Save