[gtk-doc/win-no-msys: 3/3] Support MSVC for the scangobj tests
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc/win-no-msys: 3/3] Support MSVC for the scangobj tests
- Date: Thu, 16 Apr 2020 08:23:51 +0000 (UTC)
commit 413858d52d171f4b67c9bbf70bed5c39045a9a7f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Apr 15 12:04:21 2020 +0800
Support MSVC for the scangobj tests
Use a scaled-down check using distutils on whether we are doing a Visual Studio build and
use appropriate flags when this is the case.
The scangobj test now passes on Visual Studio builds.
tests/helpers/gtkdoc_scangobj_runner.py | 43 ++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/tests/helpers/gtkdoc_scangobj_runner.py b/tests/helpers/gtkdoc_scangobj_runner.py
index 5bcf4b0..406ed57 100644
--- a/tests/helpers/gtkdoc_scangobj_runner.py
+++ b/tests/helpers/gtkdoc_scangobj_runner.py
@@ -3,9 +3,12 @@
from __future__ import print_function
import argparse
+import distutils
import os
+import shutil
import sys
+from distutils import ccompiler
from subprocess import call, PIPE, Popen
if __name__ == '__main__':
@@ -25,13 +28,35 @@ if __name__ == '__main__':
options, arguments = parser.parse_known_args()
arg_pos = 0
+ is_msvc = False
+ pkg_config_extra_flags = ''
if os.name == 'nt':
arguments.insert(arg_pos, sys.executable)
arg_pos += 1
+ # The compiler used here on Windows may well not be
+ # the same compiler that was used to build Python,
+ # as the official Python binaries are built with
+ # Visual Studio
+ compiler_name = os.environ.get('CC')
+ if compiler_name is None:
+ if os.environ.get('MSYSTEM') == 'MINGW32' or os.environ.get('MSYSTEM') == 'MINGW64':
+ compiler_name = 'mingw32'
+ else:
+ compiler_name = distutils.ccompiler.get_default_compiler()
- arguments.insert(arg_pos, os.path.join(options.binary_dir, 'gtkdoc-scangobj'))
+ if compiler_name != 'msvc' and \
+ compiler_name != 'mingw32' and \
+ compiler_name != 'clang' and \
+ compiler_name != 'clang-cl':
+ raise SystemExit('Specified Compiler \'%s\' is unsupported.' % compiler_name)
+
+ is_msvc = (compiler_name == 'msvc')
- process = Popen([options.pkg_config,
+ if is_msvc:
+ pkg_config_extra_flags = '--msvc-syntax'
+
+ arguments.insert(arg_pos, os.path.join(options.binary_dir, 'gtkdoc-scangobj'))
+ process = Popen([options.pkg_config, pkg_config_extra_flags,
'--cflags'] + options.extra_pkg,
stdout=PIPE, stderr=PIPE)
@@ -43,7 +68,7 @@ if __name__ == '__main__':
for flag in options.extra_cflags:
arguments.append('--cflags={0}'.format(flag))
- process = Popen([options.pkg_config,
+ process = Popen([options.pkg_config, pkg_config_extra_flags,
'--libs'] + options.extra_pkg,
stdout=PIPE, stderr=PIPE)
@@ -52,8 +77,14 @@ if __name__ == '__main__':
arguments.append('--ldflags={0}'.format(output.rstrip().decode('utf-8')))
for lib in options.extra_lib:
- arguments.append('--ldflags=-l{0}'.format(os.path.basename(lib).split('.')[0].lstrip('lib')))
- arguments.append('--ldflags=-L{0}'.format(os.path.dirname(lib)))
- arguments.append('--ldflags=-Wl,-rpath,{0}'.format(os.path.dirname(lib)))
+ if is_msvc:
+ arguments.append('--ldflags={0}'.format(lib.replace('\\', '/').replace('.dll', '.lib')))
+ os.environ['PATH'] = os.path.join(os.getcwd(),lib[:lib.rfind('\\')]) + \
+ os.pathsep + \
+ os.environ['PATH']
+ else:
+ arguments.append('--ldflags=-l{0}'.format(os.path.basename(lib).split('.')[0].lstrip('lib')))
+ arguments.append('--ldflags=-L{0}'.format(os.path.dirname(lib)))
+ arguments.append('--ldflags=-Wl,-rpath,{0}'.format(os.path.dirname(lib)))
sys.exit(call(arguments))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]