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 /run_unittests.py | |
parent | 253c581412d7f2b09af353dd83d943454bd555be (diff) | |
parent | ac6d4338cce68f5040825fb9bfb95dd147390e76 (diff) | |
download | meson-1eb455f8696643b625b10a85551ff9fd28dd7d2a.zip meson-1eb455f8696643b625b10a85551ff9fd28dd7d2a.tar.gz meson-1eb455f8696643b625b10a85551ff9fd28dd7d2a.tar.bz2 |
Merge pull request #4250 from jon-turney/windows-clang-cl
Add support for clang-cl on Windows
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/run_unittests.py b/run_unittests.py index ee80a87..8aa0425 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -601,7 +601,7 @@ class InternalTests(unittest.TestCase): elif is_cygwin(): self._test_all_naming(cc, env, patterns, 'cygwin') elif is_windows(): - if cc.get_id() == 'msvc': + if cc.get_argument_syntax() == 'msvc': self._test_all_naming(cc, env, patterns, 'windows-msvc') else: self._test_all_naming(cc, env, patterns, 'windows-mingw') @@ -624,10 +624,6 @@ class InternalTests(unittest.TestCase): with PatchModule(mesonbuild.compilers.c.for_windows, 'mesonbuild.compilers.c.for_windows', true): self._test_all_naming(cc, env, patterns, 'windows-mingw') - cc.id = 'msvc' - with PatchModule(mesonbuild.compilers.c.for_windows, - 'mesonbuild.compilers.c.for_windows', true): - self._test_all_naming(cc, env, patterns, 'windows-msvc') def test_pkgconfig_parse_libs(self): ''' @@ -679,7 +675,7 @@ class InternalTests(unittest.TestCase): bar_dep = PkgConfigDependency('bar', env, kwargs) self.assertEqual(bar_dep.get_link_args(), [(p2 / 'libbar.a').as_posix()]) internal_dep = PkgConfigDependency('internal', env, kwargs) - if compiler.get_id() == 'msvc': + if compiler.get_argument_syntax() == 'msvc': self.assertEqual(internal_dep.get_link_args(), []) else: link_args = internal_dep.get_link_args() @@ -1602,6 +1598,7 @@ class AllPlatformTests(BasePlatformTests): clang = mesonbuild.compilers.ClangCompiler intel = mesonbuild.compilers.IntelCompiler msvc = mesonbuild.compilers.VisualStudioCCompiler + clangcl = mesonbuild.compilers.ClangClCCompiler ar = mesonbuild.linkers.ArLinker lib = mesonbuild.linkers.VisualStudioLinker langs = [('c', 'CC'), ('cpp', 'CXX')] @@ -1623,6 +1620,9 @@ class AllPlatformTests(BasePlatformTests): if ebase.startswith('g') or ebase.endswith(('-gcc', '-g++')): self.assertIsInstance(ecc, gnu) self.assertIsInstance(elinker, ar) + elif 'clang-cl' in ebase: + self.assertIsInstance(ecc, clangcl) + self.assertIsInstance(elinker, lib) elif 'clang' in ebase: self.assertIsInstance(ecc, clang) self.assertIsInstance(elinker, ar) @@ -1696,6 +1696,8 @@ class AllPlatformTests(BasePlatformTests): wrapperlinker_s += shlex.quote(w) + ' ' os.environ['AR'] = wrapperlinker_s wlinker = env.detect_static_linker(wcc) + # Pop it so we don't use it for the next detection + evalue = os.environ.pop('AR') # Must be the same type since it's a wrapper around the same exelist self.assertIs(type(cc), type(wcc)) self.assertIs(type(linker), type(wlinker)) @@ -1994,7 +1996,7 @@ int main(int argc, char **argv) { def pbcompile(self, compiler, source, objectfile, extra_args=[]): cmd = compiler.get_exelist() - if compiler.id == 'msvc': + if compiler.get_argument_syntax() == 'msvc': cmd += ['/nologo', '/Fo' + objectfile, '/c', source] + extra_args else: cmd += ['-c', source, '-o', objectfile] + extra_args @@ -2016,7 +2018,7 @@ int main(int argc, char **argv) { def build_static_lib(self, compiler, linker, source, objectfile, outfile, extra_args=None): if extra_args is None: extra_args = [] - if compiler.id == 'msvc': + if compiler.get_argument_syntax() == 'msvc': link_cmd = ['lib', '/NOLOGO', '/OUT:' + outfile, objectfile] else: link_cmd = ['ar', 'csr', outfile, objectfile] @@ -2049,9 +2051,10 @@ int main(int argc, char **argv) { def build_shared_lib(self, compiler, source, objectfile, outfile, impfile, extra_args=None): if extra_args is None: extra_args = [] - if compiler.id == 'msvc': - link_cmd = ['link', '/NOLOGO', '/DLL', '/DEBUG', - '/IMPLIB:' + impfile, '/OUT:' + outfile, objectfile] + if compiler.get_argument_syntax() == 'msvc': + link_cmd = compiler.get_linker_exelist() + [ + '/NOLOGO', '/DLL', '/DEBUG', '/IMPLIB:' + impfile, + '/OUT:' + outfile, objectfile] else: extra_args += ['-fPIC'] link_cmd = compiler.get_exelist() + ['-shared', '-o', outfile, objectfile] @@ -2069,7 +2072,7 @@ int main(int argc, char **argv) { source = os.path.join(tdir, 'alexandria.c') objectfile = os.path.join(tdir, 'alexandria.' + object_suffix) impfile = os.path.join(tdir, 'alexandria.lib') - if cc.id == 'msvc': + if cc.get_argument_syntax() == 'msvc': shlibfile = os.path.join(tdir, 'alexandria.' + shared_suffix) elif is_cygwin(): shlibfile = os.path.join(tdir, 'cygalexandria.' + shared_suffix) @@ -2107,7 +2110,7 @@ int main(int argc, char **argv) { objectfile = os.path.join(testdir, 'foo.' + objext) stlibfile = os.path.join(testdir, 'libfoo.a') impfile = os.path.join(testdir, 'foo.lib') - if cc.id == 'msvc': + if cc.get_argument_syntax() == 'msvc': shlibfile = os.path.join(testdir, 'foo.' + shext) elif is_cygwin(): shlibfile = os.path.join(testdir, 'cygfoo.' + shext) @@ -2449,7 +2452,7 @@ recommended as it is not supported on some platforms''') testdirlib = os.path.join(testdirbase, 'lib') extra_args = None env = get_fake_env(testdirlib, self.builddir, self.prefix) - if env.detect_c_compiler(False).get_id() != 'msvc': + if env.detect_c_compiler(False).get_id() not in ['msvc', 'clang-cl']: # static libraries are not linkable with -l with msvc because meson installs them # as .a files which unix_args_to_native will not know as it expects libraries to use # .lib as extension. For a DLL the import library is installed as .lib. Thus for msvc @@ -3058,7 +3061,7 @@ class WindowsTests(BasePlatformTests): testdir = os.path.join(self.platform_test_dir, '1 basic') env = get_fake_env(testdir, self.builddir, self.prefix) cc = env.detect_c_compiler(False) - if cc.id != 'msvc': + if cc.get_argument_syntax() != 'msvc': raise unittest.SkipTest('Not using MSVC') # To force people to update this test, and also test self.assertEqual(set(cc.ignore_libs), {'c', 'm', 'pthread', 'dl', 'rt'}) @@ -3070,7 +3073,7 @@ class WindowsTests(BasePlatformTests): # resource compiler depfile generation is not yet implemented for msvc env = get_fake_env(testdir, self.builddir, self.prefix) - depfile_works = env.detect_c_compiler(False).get_id() != 'msvc' + depfile_works = env.detect_c_compiler(False).get_id() not in ['msvc', 'clang-cl'] self.init(testdir) self.build() @@ -3097,9 +3100,14 @@ class WindowsTests(BasePlatformTests): self.utime(os.path.join(testdir, 'res', 'resource.h')) self.assertRebuiltTarget('prog_1') - @unittest.skipIf(shutil.which('cl') is None, 'Test only applies to VS') def test_msvc_cpp17(self): testdir = os.path.join(self.unit_test_dir, '45 vscpp17') + + env = get_fake_env(testdir, self.builddir, self.prefix) + cc = env.detect_c_compiler(False) + if cc.get_argument_syntax() != 'msvc': + raise unittest.SkipTest('Test only applies to MSVC-like compilers') + try: self.init(testdir) except subprocess.CalledProcessError: |