aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-01-02 21:34:39 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2016-01-02 21:34:39 +0200
commit4c041e2aec22f007b79a314d6f0472a1bc9bae2f (patch)
treec004a878cf825d2408382821f2f195158294fd8a
parentedaf663ee2e7dfc01af3cace2f83a3fca7ef94d3 (diff)
downloadmeson-4c041e2aec22f007b79a314d6f0472a1bc9bae2f.zip
meson-4c041e2aec22f007b79a314d6f0472a1bc9bae2f.tar.gz
meson-4c041e2aec22f007b79a314d6f0472a1bc9bae2f.tar.bz2
Can tag include directories as system dirs to reduce compiler warning noise. Closes #345.
-rw-r--r--backends.py4
-rw-r--r--build.py3
-rw-r--r--compilers.py12
-rw-r--r--interpreter.py8
-rw-r--r--ninjabackend.py14
5 files changed, 26 insertions, 15 deletions
diff --git a/backends.py b/backends.py
index 64d3860..748a742 100644
--- a/backends.py
+++ b/backends.py
@@ -201,7 +201,7 @@ class Backend():
def get_pch_include_args(self, compiler, target):
args = []
pchpath = self.get_target_private_dir(target)
- includeargs = compiler.get_include_args(pchpath)
+ includeargs = compiler.get_include_args(pchpath, False)
for lang in ['c', 'cpp']:
p = target.get_pch(lang)
if len(p) == 0:
@@ -238,7 +238,7 @@ class Backend():
if compiler.language == 'fortran':
for lt in target.link_targets:
priv_dir = os.path.join(self.get_target_dir(lt), lt.get_basename() + lt.type_suffix())
- incflag = compiler.get_include_args(priv_dir)
+ incflag = compiler.get_include_args(priv_dir, False)
commands += incflag
return commands
diff --git a/build.py b/build.py
index eb34fd6..5787734 100644
--- a/build.py
+++ b/build.py
@@ -148,9 +148,10 @@ class Build:
return self.global_args.get(compiler.get_language(), [])
class IncludeDirs():
- def __init__(self, curdir, dirs, extra_build_dirs=None):
+ def __init__(self, curdir, dirs, is_system, extra_build_dirs=None):
self.curdir = curdir
self.incdirs = dirs
+ self.is_system = is_system
# Interpreter has validated that all given directories
# actually exist.
if extra_build_dirs is None:
diff --git a/compilers.py b/compilers.py
index be22d22..55b41dc 100644
--- a/compilers.py
+++ b/compilers.py
@@ -264,9 +264,11 @@ class CCompiler(Compiler):
def get_std_exe_link_args(self):
return []
- def get_include_args(self, path):
+ def get_include_args(self, path, is_system):
if path == '':
path = '.'
+ if is_system:
+ return ['-isystem', path]
return ['-I' + path]
def get_std_shared_lib_link_args(self):
@@ -1174,6 +1176,12 @@ class VisualStudioCCompiler(CCompiler):
result.append(i)
return result
+ def get_include_args(self, path, is_system):
+ if path == '':
+ path = '.'
+ # msvc does not have a concept of system header dirs.
+ return ['-I' + path]
+
class VisualStudioCPPCompiler(VisualStudioCCompiler):
def __init__(self, exelist, version, is_cross, exe_wrap):
VisualStudioCCompiler.__init__(self, exelist, version, is_cross, exe_wrap)
@@ -1588,7 +1596,7 @@ end program prog
return True
return False
- def get_include_args(self, path):
+ def get_include_args(self, path, is_system):
return ['-I' + path]
def get_module_outdir_args(self, path):
diff --git a/interpreter.py b/interpreter.py
index a03c0bb..5a8b5e5 100644
--- a/interpreter.py
+++ b/interpreter.py
@@ -475,7 +475,7 @@ class BuildTargetHolder(InterpreterObject):
return self.held_object.is_cross()
def private_dir_include_method(self, args, kwargs):
- return IncludeDirsHolder(build.IncludeDirs('', [],
+ return IncludeDirsHolder(build.IncludeDirs('', [], False,
[self.interpreter.backend.get_target_private_dir(self.held_object)]))
def outdir_method(self, args, kwargs):
@@ -1821,14 +1821,16 @@ class Interpreter():
return mesonlib.File.from_built_file(self.subdir, output)
@stringArgs
- @noKwargs
def func_include_directories(self, node, args, kwargs):
absbase = os.path.join(self.environment.get_source_dir(), self.subdir)
for a in args:
absdir = os.path.join(absbase, a)
if not os.path.isdir(absdir):
raise InvalidArguments('Include dir %s does not exist.' % a)
- i = IncludeDirsHolder(build.IncludeDirs(self.subdir, args))
+ is_system = kwargs.get('is_system', False)
+ if not isinstance(is_system, bool):
+ raise InvalidArguments('Is_system must be boolean.')
+ i = IncludeDirsHolder(build.IncludeDirs(self.subdir, args, is_system))
return i
@stringArgs
diff --git a/ninjabackend.py b/ninjabackend.py
index abd94e4..2f4aea7 100644
--- a/ninjabackend.py
+++ b/ninjabackend.py
@@ -1429,13 +1429,13 @@ rule FORTRAN_DEP_HACK
extra_orderdeps = []
compiler = self.get_compiler_for_source(src)
commands = self.generate_basic_compiler_args(target, compiler)
- commands += compiler.get_include_args(self.get_target_private_dir(target))
+ commands += compiler.get_include_args(self.get_target_private_dir(target), False)
curdir = target.get_subdir()
tmppath = os.path.normpath(os.path.join(self.build_to_src, curdir))
- commands += compiler.get_include_args(tmppath)
+ commands += compiler.get_include_args(tmppath, False)
if curdir == '':
curdir = '.'
- commands += compiler.get_include_args(curdir)
+ commands += compiler.get_include_args(curdir, False)
for d in target.external_deps:
if d.need_threads():
commands += compiler.thread_flags()
@@ -1482,12 +1482,12 @@ rule FORTRAN_DEP_HACK
for d in i.get_incdirs():
expdir = os.path.join(basedir, d)
srctreedir = os.path.join(self.build_to_src, expdir)
- bargs = compiler.get_include_args(expdir)
- sargs = compiler.get_include_args(srctreedir)
+ bargs = compiler.get_include_args(expdir, i.is_system)
+ sargs = compiler.get_include_args(srctreedir, i.is_system)
commands += bargs
commands += sargs
for d in i.get_extra_build_dirs():
- commands += compiler.get_include_args(d)
+ commands += compiler.get_include_args(d, i.is_system)
custom_target_include_dirs = []
for i in target.generated:
if isinstance(i, build.CustomTarget):
@@ -1495,7 +1495,7 @@ rule FORTRAN_DEP_HACK
if idir not in custom_target_include_dirs:
custom_target_include_dirs.append(idir)
for i in custom_target_include_dirs:
- commands+= compiler.get_include_args(i)
+ commands+= compiler.get_include_args(i, False)
if self.environment.coredata.get_builtin_option('use_pch'):
commands += self.get_pch_include_args(compiler, target)
crstr = ''