diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-08 20:34:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-08 20:34:53 +0200 |
commit | 4f948ccf45e31acdbccd5e03d0c5e2860e71d62c (patch) | |
tree | 08cff78b11b8cfc34b7f6e46defda700a3a69378 /mesonbuild | |
parent | ca2db0f482e17b89d1b05ad056e4815bac4ad95d (diff) | |
parent | 412315f8aeafc545c9d532df5a420b957883b00e (diff) | |
download | meson-4f948ccf45e31acdbccd5e03d0c5e2860e71d62c.zip meson-4f948ccf45e31acdbccd5e03d0c5e2860e71d62c.tar.gz meson-4f948ccf45e31acdbccd5e03d0c5e2860e71d62c.tar.bz2 |
Merge pull request #2885 from BeChris/fix_vs_pch
Fix MSVC backend crashes when `c_pch` or `cpp_pch` is not an array
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rw-r--r-- | mesonbuild/backend/vs2010backend.py | 36 |
2 files changed, 23 insertions, 15 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 85ed232..2429fba 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -2258,7 +2258,7 @@ rule FORTRAN_DEP_HACK def generate_msvc_pch_command(self, target, compiler, pch): 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] source = pch[1] pchname = compiler.get_pch_name(header) diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py index 6a587ac..367f391 100644 --- a/mesonbuild/backend/vs2010backend.py +++ b/mesonbuild/backend/vs2010backend.py @@ -861,7 +861,14 @@ class Vs2010Backend(backends.Backend): if not pch: continue pch_node.text = 'Use' - pch_sources[lang] = [pch[0], pch[1], lang] + 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] + 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 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. @@ -1016,19 +1023,20 @@ class Vs2010Backend(backends.Backend): self.add_include_dirs(lang, inc_cl, file_inc_dirs) for lang in pch_sources: header, impl, suffix = pch_sources[lang] - relpath = os.path.join(proj_to_src_dir, impl) - inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath) - pch = ET.SubElement(inc_cl, 'PrecompiledHeader') - pch.text = 'Create' - pch_out = ET.SubElement(inc_cl, 'PrecompiledHeaderOutputFile') - pch_out.text = '$(IntDir)$(TargetName)-%s.pch' % suffix - pch_file = ET.SubElement(inc_cl, 'PrecompiledHeaderFile') - # MSBuild searches for the header relative from the implementation, so we have to use - # just the file name instead of the relative path to the file. - pch_file.text = os.path.split(header)[1] - self.add_additional_options(lang, inc_cl, file_args) - self.add_preprocessor_defines(lang, inc_cl, file_defines) - self.add_include_dirs(lang, inc_cl, file_inc_dirs) + if impl: + relpath = os.path.join(proj_to_src_dir, impl) + inc_cl = ET.SubElement(inc_src, 'CLCompile', Include=relpath) + pch = ET.SubElement(inc_cl, 'PrecompiledHeader') + pch.text = 'Create' + pch_out = ET.SubElement(inc_cl, 'PrecompiledHeaderOutputFile') + pch_out.text = '$(IntDir)$(TargetName)-%s.pch' % suffix + pch_file = ET.SubElement(inc_cl, 'PrecompiledHeaderFile') + # MSBuild searches for the header relative from the implementation, so we have to use + # just the file name instead of the relative path to the file. + pch_file.text = os.path.split(header)[1] + self.add_additional_options(lang, inc_cl, file_args) + self.add_preprocessor_defines(lang, inc_cl, file_defines) + self.add_include_dirs(lang, inc_cl, file_inc_dirs) if self.has_objects(objects, additional_objects, gen_objs): inc_objs = ET.SubElement(root, 'ItemGroup') |