Rewrite test common/100 manygen using get_argument_syntax()

Rewrite test common/100 manygen using get_argument_syntax(), so it
treats clang-cl as cl, can handle only clang-cl being available, and try
to make it a bit less convoluted.
pull/4250/head
Jon Turney 6 years ago
parent 152ea1a91a
commit d528a8d281
No known key found for this signature in database
GPG Key ID: C7C86F0370285C81
  1. 32
      test cases/common/100 manygen/subdir/manygen.py
  2. 5
      test cases/common/100 manygen/subdir/meson.build

@ -6,38 +6,30 @@ from __future__ import print_function
# file and a header file.
import sys, os
import shutil, subprocess
import subprocess
with open(sys.argv[1]) as f:
funcname = f.readline().strip()
outdir = sys.argv[2]
buildtype_args = sys.argv[3]
compiler_type = sys.argv[4]
compiler = sys.argv[5:]
if not os.path.isdir(outdir):
print('Outdir does not exist.')
sys.exit(1)
# Emulate the environment.detect_c_compiler() logic
compiler = os.environ.get('CC', None)
if not compiler:
compiler = shutil.which('cl') or \
shutil.which('gcc') or \
shutil.which('clang') or \
shutil.which('cc')
compbase = os.path.basename(compiler)
if 'cl' in compbase and 'clang' not in compbase:
if compiler_type == 'msvc':
libsuffix = '.lib'
is_vs = True
compiler = 'cl'
linker = 'lib'
if any(['clang-cl' in c for c in compiler]):
linker = 'llvm-lib'
else:
linker = 'lib'
else:
libsuffix = '.a'
is_vs = False
linker = 'ar'
if compiler is None:
print('No known compilers found.')
sys.exit(1)
objsuffix = '.o'
@ -70,9 +62,9 @@ with open(tmpc, 'w') as f:
''' % funcname)
if is_vs:
subprocess.check_call([compiler, '/nologo', '/c', buildtype_args, '/Fo' + outo, tmpc])
subprocess.check_call(compiler + ['/nologo', '/c', buildtype_args, '/Fo' + outo, tmpc])
else:
subprocess.check_call([compiler, '-c', '-o', outo, tmpc])
subprocess.check_call(compiler + ['-c', '-o', outo, tmpc])
with open(tmpc, 'w') as f:
f.write('''int %s_in_lib() {
@ -81,10 +73,10 @@ with open(tmpc, 'w') as f:
''' % funcname)
if is_vs:
subprocess.check_call([compiler, '/nologo', '/c', '/Fo' + tmpo, tmpc])
subprocess.check_call(compiler + ['/nologo', '/c', '/Fo' + tmpo, tmpc])
subprocess.check_call([linker, '/NOLOGO', '/OUT:' + outa, tmpo])
else:
subprocess.check_call([compiler, '-c', '-o', tmpo, tmpc])
subprocess.check_call(compiler + ['-c', '-o', tmpo, tmpc])
subprocess.check_call([linker, 'csr', outa, tmpo])
os.unlink(tmpo)

@ -3,7 +3,8 @@ py3_bin = import('python3').find_python()
buildtype = get_option('buildtype')
buildtype_args = '-Dfooxxx' # a useless compiler argument
if meson.get_compiler('c').get_id() == 'msvc'
cc = meson.get_compiler('c')
if cc.get_argument_syntax() == 'msvc'
# We need our manually generated code to use the same CRT as the executable.
# Taken from compilers.py since build files do not have access to this.
if buildtype == 'debug'
@ -21,5 +22,5 @@ endif
generated = custom_target('manygen',
output : outfiles,
input : ['funcinfo.def'],
command : [py3_bin, gen[0], '@INPUT@', '@OUTDIR@', buildtype_args],
command : [py3_bin, gen[0], '@INPUT@', '@OUTDIR@', buildtype_args, cc.get_argument_syntax(), cc.cmd_array()],
)

Loading…
Cancel
Save