From 0755ac2723738640505986ac6fc446b9b40e4d4a Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 31 Oct 2019 17:27:08 +0800 Subject: giscanner/ccompiler.py: Fix macro defines with quotes on MSVC When we save the macros to pass to distutils to compile the dumper program, the quotes were not properly preserved for Visual Studio builds, causing items such as -DG_LOG_DOMAIN to fail as quotes are used in there. When we use quotes in macro definitions, we escape the escape character in ccompiler._set_cpp_options() when we are running g-ir-scanner with Visual Studio, so that distutils won't be too eager to drop those prematurely. --- giscanner/ccompiler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py index 35549da2..4ad572c3 100644 --- a/giscanner/ccompiler.py +++ b/giscanner/ccompiler.py @@ -444,6 +444,13 @@ class CCompiler(object): else: macro_name = macro[:macro_index] macro_value = macro[macro_index + 1:] + + # Somehow the quotes used in defining + # macros for compiling using distutils + # get dropped for MSVC builds, so + # escape the escape character. + if isinstance(self.compiler, MSVCCompiler): + macro_value = macro_value.replace('\"', '\\\"') macros.append((macro_name, macro_value)) elif option.startswith('-U'): macros.append((option[len('-U'):],)) -- cgit v1.2.1