diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-08-21 13:12:30 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-10-07 12:08:20 -0700 |
commit | 0c22798b1ad4678abb205280060175678a790c4a (patch) | |
tree | e58a51d87bffe1ecd6437f85adc0adefbed469d6 /run_unittests.py | |
parent | ff4a17dbef08a1d8afd075f57dbab0f5c76951ab (diff) | |
download | meson-0c22798b1ad4678abb205280060175678a790c4a.zip meson-0c22798b1ad4678abb205280060175678a790c4a.tar.gz meson-0c22798b1ad4678abb205280060175678a790c4a.tar.bz2 |
compilers: replace CompilerType with MachineInfo
Now that the linkers are split out of the compilers this enum is
only used to know what platform we're compiling for. Which is
what the MachineInfo class is for
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/run_unittests.py b/run_unittests.py index bfd7a54..896dce5 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -359,7 +359,7 @@ class InternalTests(unittest.TestCase): def test_compiler_args_class(self): cargsfunc = mesonbuild.compilers.CompilerArgs - cc = mesonbuild.compilers.CCompiler([], 'fake', False, MachineChoice.HOST) + cc = mesonbuild.compilers.CCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock()) # Test that bad initialization fails self.assertRaises(TypeError, cargsfunc, []) self.assertRaises(TypeError, cargsfunc, [], []) @@ -446,7 +446,7 @@ class InternalTests(unittest.TestCase): cargsfunc = mesonbuild.compilers.CompilerArgs ## Test --start/end-group linker = mesonbuild.linkers.GnuDynamicLinker([], MachineChoice.HOST, 'fake', '-Wl,') - gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', mesonbuild.compilers.CompilerType.GCC_STANDARD, False, MachineChoice.HOST, linker=linker) + gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock(), linker=linker) ## Ensure that the fake compiler is never called by overriding the relevant function gcc.get_default_include_dirs = lambda: ['/usr/include', '/usr/share/include', '/usr/local/include'] ## Test that 'direct' append and extend works @@ -475,7 +475,7 @@ class InternalTests(unittest.TestCase): cargsfunc = mesonbuild.compilers.CompilerArgs ## Test --start/end-group linker = mesonbuild.linkers.GnuDynamicLinker([], MachineChoice.HOST, 'fake', '-Wl,') - gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', mesonbuild.compilers.CompilerType.GCC_STANDARD, False, MachineChoice.HOST, linker=linker) + gcc = mesonbuild.compilers.GnuCCompiler([], 'fake', False, MachineChoice.HOST, mock.Mock(), linker=linker) ## Ensure that the fake compiler is never called by overriding the relevant function gcc.get_default_include_dirs = lambda: ['/usr/include', '/usr/share/include', '/usr/local/include'] ## Test that 'direct' append and extend works @@ -2274,35 +2274,35 @@ class AllPlatformTests(BasePlatformTests): if isinstance(cc, gnu): self.assertIsInstance(linker, ar) if is_osx(): - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.GCC_OSX) - elif is_windows(): - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.GCC_MINGW) - elif is_cygwin(): - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.GCC_CYGWIN) + self.assertIsInstance(cc.linker, mesonbuild.linkers.AppleDynamicLinker) else: - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.GCC_STANDARD) + self.assertIsInstance(cc.linker, mesonbuild.linkers.GnuLikeDynamicLinkerMixin) + if isinstance(cc, clangcl): + self.assertIsInstance(linker, lib) + self.assertIsInstance(cc.linker, mesonbuild.linkers.ClangClDynamicLinker) if isinstance(cc, clang): self.assertIsInstance(linker, ar) if is_osx(): - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.CLANG_OSX) + self.assertIsInstance(cc.linker, mesonbuild.linkers.AppleDynamicLinker) elif is_windows(): - # Not implemented yet - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.CLANG_MINGW) + # This is clang, not clang-cl + self.assertIsInstance(cc.linker, mesonbuild.linkers.MSVCDynamicLinker) else: - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.CLANG_STANDARD) + self.assertIsInstance(cc.linker, mesonbuild.linkers.GnuLikeDynamicLinkerMixin) if isinstance(cc, intel): self.assertIsInstance(linker, ar) if is_osx(): - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.ICC_OSX) + self.assertIsInstance(cc.linker, mesonbuild.linkers.XildAppleDynamicLinker) elif is_windows(): - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.ICC_WIN) + self.assertIsInstance(cc.linker, mesonbuild.linkers.XilinkDynamicLinker) else: - self.assertEqual(cc.compiler_type, mesonbuild.compilers.CompilerType.ICC_STANDARD) + self.assertIsInstance(cc.linker, mesonbuild.linkers.XildLinuxDynamicLinker) if isinstance(cc, msvc): self.assertTrue(is_windows()) self.assertIsInstance(linker, lib) self.assertEqual(cc.id, 'msvc') self.assertTrue(hasattr(cc, 'is_64')) + self.assertIsInstance(cc.linker, mesonbuild.linkers.MSVCDynamicLinker) # If we're on Windows CI, we know what the compiler will be if 'arch' in os.environ: if os.environ['arch'] == 'x64': @@ -2717,8 +2717,7 @@ int main(int argc, char **argv) { '/NOLOGO', '/DLL', '/DEBUG', '/IMPLIB:' + impfile, '/OUT:' + outfile, objectfile] else: - if not (compiler.compiler_type.is_windows_compiler or - compiler.compiler_type.is_osx_compiler): + if not (compiler.info.is_windows() or compiler.info.is_cygwin() or compiler.info.is_darwin()): extra_args += ['-fPIC'] link_cmd = compiler.get_exelist() + ['-shared', '-o', outfile, objectfile] if not mesonbuild.mesonlib.is_osx(): @@ -6898,7 +6897,8 @@ def _clang_at_least(compiler, minver: str, apple_minver: str) -> bool: at_least: bool Clang is at least the specified version """ - if compiler.compiler_type == mesonbuild.compilers.CompilerType.CLANG_OSX: + if isinstance(compiler, (mesonbuild.compilers.AppleClangCCompiler, + mesonbuild.compilers.AppleClangCPPCompiler)): return version_compare(compiler.version, apple_minver) return version_compare(compiler.version, minver) |