[gobject-introspection/clang-cl] giscanner: Support additional clang-cl arguments
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/clang-cl] giscanner: Support additional clang-cl arguments
- Date: Fri, 21 Aug 2020 07:17:12 +0000 (UTC)
commit 0dde6cf8b4ed4d229aa4f4c8a9c037cb8f57c2ab
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 | 10 ++++++----
giscanner/msvccompiler.py | 12 ++++++++++--
2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
index 4d6ada324..a0ec21678 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,10 @@ 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') is not None and
+ os.environ.get('CXX') is not None and
+ 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..360ebd571 100644
--- a/giscanner/msvccompiler.py
+++ b/giscanner/msvccompiler.py
@@ -45,10 +45,18 @@ 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') is not None and \
+ os.environ.get('CXX') is not None and \
+ 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]