Merge pull request #2885 from BeChris/fix_vs_pch

Fix MSVC backend crashes when `c_pch` or `cpp_pch` is not an array
pull/2866/merge
Jussi Pakkanen 7 years ago committed by GitHub
commit 4f948ccf45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mesonbuild/backend/ninjabackend.py
  2. 8
      mesonbuild/backend/vs2010backend.py

@ -2258,7 +2258,7 @@ rule FORTRAN_DEP_HACK
def generate_msvc_pch_command(self, target, compiler, pch): def generate_msvc_pch_command(self, target, compiler, pch):
if len(pch) != 2: if len(pch) != 2:
raise RuntimeError('MSVC requires one header and one source to produce precompiled headers.') raise MesonException('MSVC requires one header and one source to produce precompiled headers.')
header = pch[0] header = pch[0]
source = pch[1] source = pch[1]
pchname = compiler.get_pch_name(header) pchname = compiler.get_pch_name(header)

@ -861,7 +861,14 @@ class Vs2010Backend(backends.Backend):
if not pch: if not pch:
continue continue
pch_node.text = 'Use' pch_node.text = 'Use'
if compiler.id == 'msvc':
if len(pch) != 2:
raise MesonException('MSVC requires one header and one source to produce precompiled headers.')
pch_sources[lang] = [pch[0], pch[1], lang] pch_sources[lang] = [pch[0], pch[1], lang]
else:
# I don't know whether its relevant but let's handle other compilers
# used with a vs backend
pch_sources[lang] = [pch[0], None, lang]
if len(pch_sources) == 1: if len(pch_sources) == 1:
# If there is only 1 language with precompiled headers, we can use it for the entire project, which # If there is only 1 language with precompiled headers, we can use it for the entire project, which
# is cleaner than specifying it for each source file. # is cleaner than specifying it for each source file.
@ -1016,6 +1023,7 @@ class Vs2010Backend(backends.Backend):
self.add_include_dirs(lang, inc_cl, file_inc_dirs) self.add_include_dirs(lang, inc_cl, file_inc_dirs)
for lang in pch_sources: for lang in pch_sources:
header, impl, suffix = pch_sources[lang] header, impl, suffix = pch_sources[lang]
if impl:
relpath = os.path.join(proj_to_src_dir, impl) relpath = os.path.join(proj_to_src_dir, impl)
inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath) inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath)
pch = ET.SubElement(inc_cl, 'PrecompiledHeader') pch = ET.SubElement(inc_cl, 'PrecompiledHeader')

Loading…
Cancel
Save