[gtk-doc/win-no-msys: 8/8] WIP: 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: 8/8] WIP: Support MSVC for the scangobj tests
- Date: Wed, 15 Apr 2020 04:05:43 +0000 (UTC)
commit a01123b31e91d5a8e71cca69d9756a54d062284f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Apr 15 12:04:21 2020 +0800
WIP: Support MSVC for the scangobj tests
tests/helpers/gtkdoc_scangobj_runner.py | 44 ++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/tests/helpers/gtkdoc_scangobj_runner.py b/tests/helpers/gtkdoc_scangobj_runner.py
index 5bcf4b0..b0971f6 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,36 @@ 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)
+
+ if compiler_name == 'msvc':
+ is_msvc = True
+
+ if is_msvc:
+ pkg_config_extra_flags = '--msvc-syntax'
- process = Popen([options.pkg_config,
+ 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,17 +69,23 @@ 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)
output, error = process.communicate()
+
+ print('pkg-config output: %s' % output.rstrip().decode('utf-8'))
if process.returncode == 0:
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')))
+ shutil.copyfile(lib, os.path.join(os.getcwd(),lib[lib.rfind('\\') + 1:]))
+ 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]