diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-11-04 19:56:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-04 19:56:08 +0200 |
| commit | 1eb455f8696643b625b10a85551ff9fd28dd7d2a (patch) | |
| tree | f6fa0bb549b609d3db1fea05181e7ff92c6b1fa3 /test cases | |
| parent | 253c581412d7f2b09af353dd83d943454bd555be (diff) | |
| parent | ac6d4338cce68f5040825fb9bfb95dd147390e76 (diff) | |
| download | meson-1eb455f8696643b625b10a85551ff9fd28dd7d2a.tar.gz | |
Merge pull request #4250 from jon-turney/windows-clang-cl
Add support for clang-cl on Windows
Diffstat (limited to 'test cases')
| -rwxr-xr-x | test cases/common/100 manygen/subdir/manygen.py | 32 | ||||
| -rw-r--r-- | test cases/common/100 manygen/subdir/meson.build | 5 | ||||
| -rw-r--r-- | test cases/common/112 spaces backslash/meson.build | 2 | ||||
| -rw-r--r-- | test cases/common/123 llvm ir and assembly/meson.build | 11 | ||||
| -rw-r--r-- | test cases/common/124 cpp and asm/meson.build | 2 | ||||
| -rw-r--r-- | test cases/common/127 no buildincdir/meson.build | 2 | ||||
| -rw-r--r-- | test cases/common/13 pch/mixed/meson.build | 3 | ||||
| -rw-r--r-- | test cases/common/132 generated assembly/meson.build | 4 | ||||
| -rw-r--r-- | test cases/common/138 c cpp and asm/meson.build | 2 | ||||
| -rw-r--r-- | test cases/common/143 C and CPP link/meson.build | 5 | ||||
| -rw-r--r-- | test cases/common/186 has link arg/meson.build | 2 | ||||
| -rw-r--r-- | test cases/common/190 openmp/meson.build | 3 | ||||
| -rw-r--r-- | test cases/common/204 function attributes/meson.build | 6 | ||||
| -rw-r--r-- | test cases/common/206 argument syntax/meson.build | 2 | ||||
| -rw-r--r-- | test cases/common/91 default options/meson.build | 5 | ||||
| -rw-r--r-- | test cases/windows/16 gui app/meson.build | 10 |
16 files changed, 48 insertions, 48 deletions
diff --git a/test cases/common/100 manygen/subdir/manygen.py b/test cases/common/100 manygen/subdir/manygen.py index 7ffd435b2..0fbc2ec0b 100755 --- a/test cases/common/100 manygen/subdir/manygen.py +++ b/test cases/common/100 manygen/subdir/manygen.py @@ -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) diff --git a/test cases/common/100 manygen/subdir/meson.build b/test cases/common/100 manygen/subdir/meson.build index 73b4ff710..56f60e6c1 100644 --- a/test cases/common/100 manygen/subdir/meson.build +++ b/test cases/common/100 manygen/subdir/meson.build @@ -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()], ) diff --git a/test cases/common/112 spaces backslash/meson.build b/test cases/common/112 spaces backslash/meson.build index bf614e8fc..d5904946e 100644 --- a/test cases/common/112 spaces backslash/meson.build +++ b/test cases/common/112 spaces backslash/meson.build @@ -7,7 +7,7 @@ project('comparer', 'c') include_dir = meson.current_source_dir() + '/include' default_c_args = ['-I' + include_dir] -if meson.get_compiler('c').get_id() == 'msvc' +if meson.get_compiler('c').get_argument_syntax() == 'msvc' default_c_args += ['/Faasm output\\'] # Hack to create the 'asm output' directory in the builddir subdir('asm output') diff --git a/test cases/common/123 llvm ir and assembly/meson.build b/test cases/common/123 llvm ir and assembly/meson.build index 51321fb4a..a67c6c623 100644 --- a/test cases/common/123 llvm ir and assembly/meson.build +++ b/test cases/common/123 llvm ir and assembly/meson.build @@ -28,15 +28,18 @@ foreach lang : ['c', 'cpp'] # MSVC cannot directly compile assembly files, so we pass it through the # cl.exe pre-processor first and then assemble it with the ml.exe assembler. # Then we can link it into the executable. - if cc_id == 'msvc' - cl = find_program('cl') + if cc.get_argument_syntax() == 'msvc' + cl = cc.cmd_array() if cpu == 'x86' - ml = find_program('ml') + ml = find_program('ml', required: false) elif cpu == 'x86_64' - ml = find_program('ml64') + ml = find_program('ml64', required: false) else error('Unsupported cpu family: "' + cpu + '"') endif + if not ml.found() + error('MESON_SKIP_TEST: ML (masm) not found') + endif # Preprocess file (ml doesn't support pre-processing) preproc_name = lang + square_base + '.i' square_preproc = custom_target(lang + square_impl + 'preproc', diff --git a/test cases/common/124 cpp and asm/meson.build b/test cases/common/124 cpp and asm/meson.build index 916077535..f0970848e 100644 --- a/test cases/common/124 cpp and asm/meson.build +++ b/test cases/common/124 cpp and asm/meson.build @@ -15,7 +15,7 @@ endif sources = ['trivial.cc'] # If the compiler cannot compile assembly, don't use it -if meson.get_compiler('cpp').get_id() != 'msvc' +if not ['msvc', 'clang-cl'].contains(meson.get_compiler('cpp').get_id()) sources += ['retval-' + cpu + '.S'] cpp_args = ['-DUSE_ASM'] message('Using ASM') diff --git a/test cases/common/127 no buildincdir/meson.build b/test cases/common/127 no buildincdir/meson.build index ac69e8e46..53f1a7f58 100644 --- a/test cases/common/127 no buildincdir/meson.build +++ b/test cases/common/127 no buildincdir/meson.build @@ -1,5 +1,5 @@ project('nobuilddir', 'c', - default_options : 'werror=true') + default_options : ['werror=true', 'buildtype=plain']) cc = meson.get_compiler('c') diff --git a/test cases/common/13 pch/mixed/meson.build b/test cases/common/13 pch/mixed/meson.build index 7f6033dcf..f0c3ecadb 100644 --- a/test cases/common/13 pch/mixed/meson.build +++ b/test cases/common/13 pch/mixed/meson.build @@ -5,8 +5,9 @@ exe = executable( cpp_pch : ['pch/main_pch.cc', 'pch/main.h'], ) +# test pch when only a header is given (not supported by msvc) cc = meson.get_compiler('c') -if cc.get_id() != 'msvc' +if not ['msvc', 'clang-cl'].contains(cc.get_id()) exe2 = executable( 'prog2', files('main.cc', 'func.c'), diff --git a/test cases/common/132 generated assembly/meson.build b/test cases/common/132 generated assembly/meson.build index 6a8744b19..5fb742913 100644 --- a/test cases/common/132 generated assembly/meson.build +++ b/test cases/common/132 generated assembly/meson.build @@ -2,8 +2,8 @@ project('generated assembly', 'c') cc = meson.get_compiler('c') -if cc.get_id() == 'msvc' - error('MESON_SKIP_TEST: assembly files cannot be compiled directly by MSVC') +if ['msvc', 'clang-cl'].contains(cc.get_id()) + error('MESON_SKIP_TEST: assembly files cannot be compiled directly by the compiler') endif cpu = host_machine.cpu_family() diff --git a/test cases/common/138 c cpp and asm/meson.build b/test cases/common/138 c cpp and asm/meson.build index 2c3610ea0..ca820e2ae 100644 --- a/test cases/common/138 c cpp and asm/meson.build +++ b/test cases/common/138 c cpp and asm/meson.build @@ -9,7 +9,7 @@ if not supported_cpus.contains(cpu) error('MESON_SKIP_TEST unsupported cpu:' + cpu) endif -if meson.get_compiler('c').get_id() == 'msvc' +if meson.get_compiler('c').get_argument_syntax() == 'msvc' error('MESON_SKIP_TEST MSVC can\'t compile assembly') endif diff --git a/test cases/common/143 C and CPP link/meson.build b/test cases/common/143 C and CPP link/meson.build index 55c1b87a5..af5c54a1c 100644 --- a/test cases/common/143 C and CPP link/meson.build +++ b/test cases/common/143 C and CPP link/meson.build @@ -25,9 +25,10 @@ libc = static_library('cfoo', ['foo.c', 'foo.h']) # ourselves at configure time and then 'find' it with cxx.find_library(). cxx = meson.get_compiler('cpp') -if cxx.get_id() == 'msvc' +if cxx.get_argument_syntax() == 'msvc' + static_linker = find_program('lib', 'llvm-lib') compile_cmd = ['/c', '@INPUT@', '/Fo@OUTPUT@'] - stlib_cmd = ['lib', '/OUT:@OUTPUT@', '@INPUT@'] + stlib_cmd = [static_linker, '/OUT:@OUTPUT@', '@INPUT@'] else compile_cmd = ['-c', '-fPIC', '@INPUT@', '-o', '@OUTPUT@'] stlib_cmd = ['ar', 'csr', '@OUTPUT@', '@INPUT@'] diff --git a/test cases/common/186 has link arg/meson.build b/test cases/common/186 has link arg/meson.build index e166101ab..10f221857 100644 --- a/test cases/common/186 has link arg/meson.build +++ b/test cases/common/186 has link arg/meson.build @@ -3,7 +3,7 @@ project('has link arg', 'c', 'cpp') cc = meson.get_compiler('c') cpp = meson.get_compiler('cpp') -if cc.get_id() == 'msvc' +if cc.get_argument_syntax() == 'msvc' is_arg = '/OPT:REF' useless = '/DEBUG' isnt_arg = '/iambroken' diff --git a/test cases/common/190 openmp/meson.build b/test cases/common/190 openmp/meson.build index eb270aba6..018bf24c5 100644 --- a/test cases/common/190 openmp/meson.build +++ b/test cases/common/190 openmp/meson.build @@ -10,6 +10,9 @@ endif if cc.get_id() == 'msvc' and cc.version().version_compare('<17') error('MESON_SKIP_TEST msvc is too old to support OpenMP.') endif +if cc.get_id() == 'clang-cl' + error('MESON_SKIP_TEST clang-cl does not support OpenMP.') +endif if host_machine.system() == 'darwin' error('MESON_SKIP_TEST macOS does not support OpenMP.') endif diff --git a/test cases/common/204 function attributes/meson.build b/test cases/common/204 function attributes/meson.build index e46533f8b..c906b4918 100644 --- a/test cases/common/204 function attributes/meson.build +++ b/test cases/common/204 function attributes/meson.build @@ -19,7 +19,7 @@ project('gcc func attributes', ['c', 'cpp']) c = meson.get_compiler('c') cpp = meson.get_compiler('cpp') -expected_result = c.get_id() != 'msvc' +expected_result = not ['msvc', 'clang-cl'].contains(c.get_id()) # Q: Why is ifunc not in this list or any of the below lists? # A: It's too damn hard to figure out if you actually support it, since it @@ -57,8 +57,6 @@ if c.get_id() != 'intel' attributes += 'weakref' endif -expected_result = c.get_id() != 'msvc' - # These are unsupported on darwin with apple clang 9.1.0 if host_machine.system() != 'darwin' attributes += 'alias' @@ -97,7 +95,7 @@ foreach a : ['dllexport', 'dllimport'] endforeach message('checking get_supported_function_attributes') -if c.get_id() != 'msvc' +if not ['msvc', 'clang-cl'].contains(c.get_id()) multi_expected = attributes else multi_expected = [] diff --git a/test cases/common/206 argument syntax/meson.build b/test cases/common/206 argument syntax/meson.build index c884f9086..216da45ba 100644 --- a/test cases/common/206 argument syntax/meson.build +++ b/test cases/common/206 argument syntax/meson.build @@ -7,7 +7,7 @@ cc = meson.get_compiler('c') if ['gcc', 'lcc', 'clang'].contains(cc.get_id()) expected = 'gcc' -elif cc.get_id() == 'msvc' +elif ['msvc', 'clang-cl'].contains(cc.get_id()) expected = 'msvc' elif cc.get_id() == 'intel' if host_machine.system() == 'windows' diff --git a/test cases/common/91 default options/meson.build b/test cases/common/91 default options/meson.build index 9f45df072..c4c72ef83 100644 --- a/test cases/common/91 default options/meson.build +++ b/test cases/common/91 default options/meson.build @@ -6,11 +6,9 @@ project('default options', 'cpp', 'c', default_options : [ 'warning_level=3', ]) -cpp_id = meson.get_compiler('cpp').get_id() - assert(get_option('buildtype') == 'debugoptimized', 'Build type default value wrong.') -if cpp_id == 'msvc' +if meson.get_compiler('cpp').get_argument_syntax() == 'msvc' cpp_eh = get_option('cpp_eh') assert(cpp_eh == 'none', 'MSVC eh value is "' + cpp_eh + '" instead of "none"') else @@ -33,4 +31,3 @@ assert(w_level == '3', 'warning level "' + w_level + '" instead of "3"') # assert(not cc.compiles('int foobar;'), 'Default arg not used in test.') # assert(cc.compiles('int foobar;', no_builtin_args : true), 'No_builtin did not disable builtins.') # endif - diff --git a/test cases/windows/16 gui app/meson.build b/test cases/windows/16 gui app/meson.build index 243521834..224d708ee 100644 --- a/test cases/windows/16 gui app/meson.build +++ b/test cases/windows/16 gui app/meson.build @@ -17,6 +17,10 @@ console_prog = executable('console_prog', 'console_prog.c', gui_app: false) tester = find_program('gui_app_tester.py') -tool = find_program('objdump', 'dumpbin') -test('is_gui', tester, args: [tool.path(), gui_prog, '2']) -test('not_gui', tester, args: [tool.path(), console_prog, '3']) +tool = find_program('objdump', 'dumpbin', required: false) +# TODO: when 'llvm-objdump -f' emits the subsystem type, we could use that also + +if tool.found() + test('is_gui', tester, args: [tool.path(), gui_prog, '2']) + test('not_gui', tester, args: [tool.path(), console_prog, '3']) +endif |
