Move _get_include_args from gnome to modules.

pull/1258/head
Elliott Sales de Andrade 8 years ago
parent f56458810d
commit 24b3585318
  1. 32
      mesonbuild/modules/__init__.py
  2. 49
      mesonbuild/modules/gnome.py

@ -1,3 +1,5 @@
import os
from .. import build
from .. import dependencies
from ..mesonlib import MesonException
@ -14,6 +16,36 @@ def find_program(program_name, target_name):
_found_programs[program_name] = program
return program
def get_include_args(environment, include_dirs, prefix='-I'):
if not include_dirs:
return []
dirs_str = []
for incdirs in include_dirs:
if hasattr(incdirs, "held_object"):
dirs = incdirs.held_object
else:
dirs = incdirs
if isinstance(dirs, str):
dirs_str += ['%s%s' % (prefix, dirs)]
continue
# Should be build.IncludeDirs object.
basedir = dirs.get_curdir()
for d in dirs.get_incdirs():
expdir = os.path.join(basedir, d)
srctreedir = os.path.join(environment.get_source_dir(), expdir)
buildtreedir = os.path.join(environment.get_build_dir(), expdir)
dirs_str += ['%s%s' % (prefix, buildtreedir),
'%s%s' % (prefix, srctreedir)]
for d in dirs.get_extra_build_dirs():
dirs_str += ['%s%s' % (prefix, d)]
return dirs_str
class GResourceTarget(build.CustomTarget):
def __init__(self, name, subdir, kwargs):
super().__init__(name, subdir, kwargs)

@ -26,7 +26,9 @@ from .. import mlog
from .. import mesonlib
from .. import compilers
from .. import interpreter
from . import find_program, GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import find_program, get_include_args
# gresource compilation is broken due to the way
# the resource compiler and Ninja clash about it
@ -265,35 +267,6 @@ can not be used with the current version of glib-compiled-resources, due to
depends.append(lib)
return link_command
@staticmethod
def _get_include_args(state, include_dirs, prefix='-I'):
if not include_dirs:
return []
dirs_str = []
for incdirs in include_dirs:
if hasattr(incdirs, "held_object"):
dirs = incdirs.held_object
else:
dirs = incdirs
if isinstance(dirs, str):
dirs_str += ['%s%s' % (prefix, dirs)]
continue
# Should be build.IncludeDirs object.
basedir = dirs.get_curdir()
for d in dirs.get_incdirs():
expdir = os.path.join(basedir, d)
srctreedir = os.path.join(state.environment.get_source_dir(), expdir)
buildtreedir = os.path.join(state.environment.get_build_dir(), expdir)
dirs_str += ['%s%s' % (prefix, buildtreedir),
'%s%s' % (prefix, srctreedir)]
for d in dirs.get_extra_build_dirs():
dirs_str += ['%s%s' % (prefix, d)]
return dirs_str
def _get_dependencies_flags(self, deps, state, depends=None, include_rpath=False):
cflags = set()
ldflags = set()
@ -305,7 +278,7 @@ can not be used with the current version of glib-compiled-resources, due to
if hasattr(dep, 'held_object'):
dep = dep.held_object
if isinstance(dep, InternalDependency):
cflags.update(self._get_include_args(state, dep.include_directories))
cflags.update(get_include_args(state.environment, dep.include_directories))
for lib in dep.libraries:
ldflags.update(self._get_link_args(state, lib.held_object, depends, include_rpath))
libdepflags = self._get_dependencies_flags(lib.held_object.get_external_deps(), state, depends, include_rpath)
@ -396,7 +369,7 @@ can not be used with the current version of glib-compiled-resources, due to
scan_command += extra_args
scan_command += ['-I' + os.path.join(state.environment.get_source_dir(), state.subdir),
'-I' + os.path.join(state.environment.get_build_dir(), state.subdir)]
scan_command += self._get_include_args(state, girtarget.get_include_dirs())
scan_command += get_include_args(state.environment, girtarget.get_include_dirs())
if 'link_with' in kwargs:
link_with = kwargs.pop('link_with')
@ -521,9 +494,9 @@ can not be used with the current version of glib-compiled-resources, due to
if not isinstance(incd.held_object, (str, build.IncludeDirs)):
raise MesonException(
'Gir include dirs should be include_directories().')
scan_command += self._get_include_args(state, inc_dirs)
scan_command += self._get_include_args(state, gir_inc_dirs + inc_dirs,
prefix='--add-include-path=')
scan_command += get_include_args(state.environment, inc_dirs)
scan_command += get_include_args(state.environment, gir_inc_dirs + inc_dirs,
prefix='--add-include-path=')
if isinstance(girtarget, build.Executable):
scan_command += ['--program', girtarget]
@ -543,8 +516,8 @@ can not be used with the current version of glib-compiled-resources, due to
typelib_output = '%s-%s.typelib' % (ns, nsversion)
typelib_cmd = gicompiler.get_command() + [scan_target, '--output', '@OUTPUT@']
typelib_cmd += self._get_include_args(state, gir_inc_dirs,
prefix='--includedir=')
typelib_cmd += get_include_args(state.environment, gir_inc_dirs,
prefix='--includedir=')
for incdir in typelib_includes:
typelib_cmd += ["--includedir=" + incdir]
@ -712,7 +685,7 @@ can not be used with the current version of glib-compiled-resources, due to
if not isinstance(incd.held_object, (str, build.IncludeDirs)):
raise MesonException(
'Gir include dirs should be include_directories().')
cflags.update(self._get_include_args(state, inc_dirs))
cflags.update(get_include_args(state.environment, inc_dirs))
if cflags:
args += ['--cflags=%s' % ' '.join(cflags)]
if ldflags:

Loading…
Cancel
Save