[gobject-introspection/clang-cl] giscanner: Support additional clang-cl arguments



commit d38e23ca434e507086a6e68129bd3b08e34a432c
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Aug 21 14:52:19 2020 +0800

    giscanner: Support additional clang-cl arguments
    
    We might be setting CC and CXX as `clang-cl <args>...`, for use cases such as
    performing cross builds, so make sure we also pass those flags into
    g-ir-scanner so that they are being picked up as well

 giscanner/ccompiler.py    |  8 ++++----
 giscanner/msvccompiler.py | 10 ++++++++--
 2 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 4d6ada324..172d4ebd3 100644
--- a/giscanner/ccompiler.py
+++ b/giscanner/ccompiler.py
@@ -164,7 +164,7 @@ class CCompiler(object):
                     os.environ['MSSdk'] = os.environ.get('VCInstallDir')
 
             if self.check_is_clang_cl():
-                self.compiler_cmd = 'clang-cl.exe'
+                self.compiler_cmd = os.environ.get('CC').split()[0]
             else:
                 self.compiler_cmd = 'cl.exe'
                 self._cflags_no_deprecation_warnings = "-wd4996"
@@ -338,7 +338,7 @@ class CCompiler(object):
             args.append('dumpbin.exe')
             args.append('-symbols')
 
-        # When we are not using Visual C++ (i.e. we are using GCC)...
+        # When we are not using Visual C++ nor clang-cl (i.e. we are using GCC)...
         else:
             libtool = utils.get_libtool_command(options)
             if libtool:
@@ -429,8 +429,8 @@ class CCompiler(object):
 
     def check_is_clang_cl(self):
         return (isinstance(self.compiler, MSVCCompiler) and
-                os.environ.get('CC') == 'clang-cl' and
-                os.environ.get('CXX') == 'clang-cl')
+                os.environ.get('CC').split()[0] == 'clang-cl' and
+                os.environ.get('CXX').split()[0] == 'clang-cl')
 
     # Private APIs
     def _set_cpp_options(self, options):
diff --git a/giscanner/msvccompiler.py b/giscanner/msvccompiler.py
index 11202a874..63949a250 100644
--- a/giscanner/msvccompiler.py
+++ b/giscanner/msvccompiler.py
@@ -45,10 +45,16 @@ class MSVCCompiler(distutils.msvccompiler.MSVCCompiler):
                 self.__version = distutils.msvc9compiler.VERSION
         self.initialized = False
         self.preprocess_options = None
-        if os.environ.get('CC') == 'clang-cl' and os.environ.get('CXX') == 'clang-cl':
-            self.cc = 'clang-cl'
+        if os.environ.get('CC').split()[0] == 'clang-cl' and \
+           os.environ.get('CXX').split()[0] == 'clang-cl':
+            cc_cmd = os.environ.get('CC').split()
+            self.cc = cc_cmd[0]
             self.linker = 'lld-link'
             self.compile_options = []
+            # Add any arguments added to clang-cl to self.compile_options
+            # such as cross-compilation flags
+            if len(cc_cmd) > 1:
+                self.compile_options.extend(cc_cmd[1:])
             self.initialized = True
 
     def preprocess(self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]