aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2019-11-20 18:41:18 +0200
committerGitHub <noreply@github.com>2019-11-20 18:41:18 +0200
commit5920344b9283a55939ef322ca39fdd70f5aafd31 (patch)
tree56a7a59e616f961f6fffc7f359abdf0ef7dc8483 /mesonbuild
parent294b33144fbf5628d2a672f907c1f5460577234a (diff)
parent9435f11b17ac428c80ac8af80724aced6c02133a (diff)
downloadmeson-5920344b9283a55939ef322ca39fdd70f5aafd31.zip
meson-5920344b9283a55939ef322ca39fdd70f5aafd31.tar.gz
meson-5920344b9283a55939ef322ca39fdd70f5aafd31.tar.bz2
Merge pull request #6199 from mensinda/cmSysInc
cmake: Handle CMake system include dirs (closes #6079)
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/ninjabackend.py1
-rw-r--r--mesonbuild/cmake/common.py5
-rw-r--r--mesonbuild/cmake/fileapi.py6
-rw-r--r--mesonbuild/cmake/interpreter.py15
-rw-r--r--mesonbuild/interpreter.py1
-rw-r--r--mesonbuild/mlog.py10
6 files changed, 30 insertions, 8 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 50ac44f..3c5cdf0 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -334,6 +334,7 @@ int dummy;
# Only overwrite the old build file after the new one has been
# fully created.
os.replace(tempfilename, outfilename)
+ mlog.cmd_ci_include(outfilename) # For CI debugging
self.generate_compdb()
# http://clang.llvm.org/docs/JSONCompilationDatabase.html
diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py
index 70ef622..7a0e784 100644
--- a/mesonbuild/cmake/common.py
+++ b/mesonbuild/cmake/common.py
@@ -73,9 +73,10 @@ class CMakeFileGroup:
tmp = []
for i in self.includes:
if isinstance(i, dict) and 'path' in i:
- tmp += [i['path']]
- elif isinstance(i, str):
+ i['isSystem'] = i.get('isSystem', False)
tmp += [i]
+ elif isinstance(i, str):
+ tmp += [{'path': i, 'isSystem': False}]
self.includes = tmp
def log(self) -> None:
diff --git a/mesonbuild/cmake/fileapi.py b/mesonbuild/cmake/fileapi.py
index 5ee6ad0..c62eadb 100644
--- a/mesonbuild/cmake/fileapi.py
+++ b/mesonbuild/cmake/fileapi.py
@@ -14,6 +14,7 @@
from .common import CMakeException, CMakeBuildFile, CMakeConfiguration
from typing import Any, List, Tuple
+from .. import mlog
import os
import json
import re
@@ -76,6 +77,7 @@ class CMakeFileAPI:
debug_json = os.path.normpath(os.path.join(self.build_dir, '..', 'fileAPI.json'))
with open(debug_json, 'w') as fp:
json.dump(index, fp, indent=2)
+ mlog.cmd_ci_include(debug_json)
# parse the JSON
for i in index['objects']:
@@ -186,9 +188,7 @@ class CMakeFileAPI:
'language': cg.get('language', 'C'),
'isGenerated': None, # Set later, flag is stored per source file
'sources': [],
-
- # TODO handle isSystem
- 'includePath': [x.get('path', '') for x in cg.get('includes', [])],
+ 'includePath': cg.get('includes', []),
}
normal_src, generated_src, src_idx = parse_sources(cg, tgt)
diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py
index cb63bb9..12db810 100644
--- a/mesonbuild/cmake/interpreter.py
+++ b/mesonbuild/cmake/interpreter.py
@@ -157,6 +157,7 @@ class ConverterTarget:
self.sources = []
self.generated = []
self.includes = []
+ self.sys_includes = []
self.link_with = []
self.object_libs = []
self.compile_opts = {}
@@ -180,7 +181,8 @@ class ConverterTarget:
self.compile_opts[lang] += [x for x in args if x not in self.compile_opts[lang]]
# Handle include directories
- self.includes += [x for x in i.includes if x not in self.includes]
+ self.includes += [x['path'] for x in i.includes if x not in self.includes and not x['isSystem']]
+ self.sys_includes += [x['path'] for x in i.includes if x not in self.sys_includes and x['isSystem']]
# Add sources to the right array
if i.is_generated:
@@ -295,6 +297,7 @@ class ConverterTarget:
build_dir_rel = os.path.relpath(self.build_dir, os.path.join(self.env.get_build_dir(), subdir))
self.includes = list(set([rel_path(x, True, False) for x in set(self.includes)] + [build_dir_rel]))
+ self.sys_includes = list(set([rel_path(x, True, False) for x in set(self.sys_includes)]))
self.sources = [rel_path(x, False, False) for x in self.sources]
self.generated = [rel_path(x, False, True) for x in self.generated]
@@ -303,6 +306,7 @@ class ConverterTarget:
# Remove delete entries
self.includes = [x for x in self.includes if x is not None]
+ self.sys_includes = [x for x in self.sys_includes if x is not None]
self.sources = [x for x in self.sources if x is not None]
self.generated = [x for x in self.generated if x is not None]
@@ -359,6 +363,7 @@ class ConverterTarget:
mlog.log(' -- link_flags: ', mlog.bold(str(self.link_flags)))
mlog.log(' -- languages: ', mlog.bold(str(self.languages)))
mlog.log(' -- includes: ', mlog.bold(str(self.includes)))
+ mlog.log(' -- sys_includes: ', mlog.bold(str(self.sys_includes)))
mlog.log(' -- sources: ', mlog.bold(str(self.sources)))
mlog.log(' -- generated: ', mlog.bold(str(self.generated)))
mlog.log(' -- pie: ', mlog.bold('true' if self.pie else 'false'))
@@ -845,6 +850,8 @@ class CMakeInterpreter:
base_name = str(tgt.name)
base_name = base_name.replace('-', '_')
inc_var = '{}_inc'.format(base_name)
+ dir_var = '{}_dir'.format(base_name)
+ sys_var = '{}_sys'.format(base_name)
src_var = '{}_src'.format(base_name)
dep_var = '{}_dep'.format(base_name)
tgt_var = base_name
@@ -879,8 +886,10 @@ class CMakeInterpreter:
}
# Generate the function nodes
- inc_node = assign(inc_var, function('include_directories', tgt.includes))
- node_list = [inc_node]
+ dir_node = assign(dir_var, function('include_directories', tgt.includes))
+ sys_node = assign(sys_var, function('include_directories', tgt.sys_includes, {'is_system': True}))
+ inc_node = assign(inc_var, array([id_node(dir_var), id_node(sys_var)]))
+ node_list = [dir_node, sys_node, inc_node]
if tgt_func == 'header_only':
del dep_kwargs['link_with']
dep_node = assign(dep_var, function('declare_dependency', kwargs=dep_kwargs))
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 6deff7a..03a79aa 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2597,6 +2597,7 @@ external dependencies (including libraries) must go to "dependencies".''')
f.write(printer.result)
mlog.log('Build file:', meson_filename)
+ mlog.cmd_ci_include(meson_filename)
mlog.log()
result = self._do_subproject_meson(dirname, subdir, default_options, kwargs, ast, cm_int.bs_files)
diff --git a/mesonbuild/mlog.py b/mesonbuild/mlog.py
index 14ad92f..ace47f4 100644
--- a/mesonbuild/mlog.py
+++ b/mesonbuild/mlog.py
@@ -56,6 +56,7 @@ log_timestamp_start = None # type: Optional[float]
log_fatal_warnings = False # type: bool
log_disable_stdout = False # type: bool
log_errors_only = False # type: bool
+_in_ci = 'CI' in os.environ # type: bool
def disable() -> None:
global log_disable_stdout
@@ -186,6 +187,15 @@ def debug(*args: Union[str, AnsiDecorator], **kwargs: Any) -> None:
print(*arr, file=log_file, **kwargs)
log_file.flush()
+def _debug_log_cmd(cmd: str, args: List[str]) -> None:
+ if not _in_ci:
+ return
+ args = ['"{}"'.format(x) for x in args] # Quote all args, just in case
+ debug('!meson_ci!/{} {}'.format(cmd, ' '.join(args)))
+
+def cmd_ci_include(file: str) -> None:
+ _debug_log_cmd('ci_include', [file])
+
def log(*args: Union[str, AnsiDecorator], is_error: bool = False,
**kwargs: Any) -> None:
global log_errors_only