diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2016-12-28 17:00:26 -0500 |
---|---|---|
committer | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2016-12-28 17:18:14 -0500 |
commit | 24b3585318b01e1c0e5ea7a6186ee699a07b642d (patch) | |
tree | 1cdb4a80b9abb551688c537706c2e08c703fdb7c /mesonbuild/modules/__init__.py | |
parent | f56458810dcbd61584c85300ca128b1a3a2e6211 (diff) | |
download | meson-24b3585318b01e1c0e5ea7a6186ee699a07b642d.zip meson-24b3585318b01e1c0e5ea7a6186ee699a07b642d.tar.gz meson-24b3585318b01e1c0e5ea7a6186ee699a07b642d.tar.bz2 |
Move _get_include_args from gnome to modules.
Diffstat (limited to 'mesonbuild/modules/__init__.py')
-rw-r--r-- | mesonbuild/modules/__init__.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py index 085b4dd..184d85a 100644 --- a/mesonbuild/modules/__init__.py +++ b/mesonbuild/modules/__init__.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) |