diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2019-10-31 17:27:08 +0800 |
---|---|---|
committer | Chun-wei Fan <fanc999@yahoo.com.tw> | 2019-11-01 03:31:17 +0000 |
commit | ab93f13b200de8ae9ea62d16af57fc3b84cf0312 (patch) | |
tree | 425a815163590acdfa3b4ca25a882379ef86a9ff | |
parent | 3b9ae74786c9637c058d771dc9509492c3033503 (diff) | |
download | gobject-introspection-ab93f13b200de8ae9ea62d16af57fc3b84cf0312.tar.gz |
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.
-rw-r--r-- | giscanner/ccompiler.py | 7 |
1 files changed, 7 insertions, 0 deletions
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'):],)) |