backends: Only add pch args that are appropriate for the compiler

Currently we try both C and C++ when determining which PCH files to
include. The problem with this approach is that if there are no C or C++
files (only headers) and the target has both C and C++ sources then the
PCHs will be passed to the wrong compiler.

The solution is less code, we already have the compiler, the compiler
knows what language it is, so we don't need to walk both C and C++.

Fixes #3068
pull/3069/head
Dylan Baker 7 years ago
parent d3d0d4affb
commit b11035693c
  1. 14
      mesonbuild/backend/backends.py

@ -407,16 +407,10 @@ class Backend:
args = []
pchpath = self.get_target_private_dir(target)
includeargs = compiler.get_include_args(pchpath, False)
for lang in ['c', 'cpp']:
p = target.get_pch(lang)
if not p:
continue
if compiler.can_compile(p[-1]):
header = p[0]
args += compiler.get_pch_use_args(pchpath, header)
if len(args) > 0:
args = includeargs + args
return args
p = target.get_pch(compiler.get_language())
if p:
args += compiler.get_pch_use_args(pchpath, p[0])
return includeargs + args
@staticmethod
def escape_extra_args(compiler, args):

Loading…
Cancel
Save