aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/backend/ninjabackend.py28
-rw-r--r--mesonbuild/cmake/toolchain.py3
-rw-r--r--mesonbuild/environment.py4
-rw-r--r--unittests/windowstests.py7
4 files changed, 18 insertions, 24 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 45c0e9d..89f3763 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -36,13 +36,8 @@ from .. import build
from .. import mlog
from .. import compilers
from ..arglist import CompilerArgs
-from ..compilers import (
- Compiler, CCompiler,
- FortranCompiler,
- mixins,
- PGICCompiler,
- VisualStudioLikeCompiler,
-)
+from ..compilers import Compiler
+from ..compilers.c import CCompiler
from ..linkers import ArLinker, AppleArLinker, RSPFileSyntax
from ..mesonlib import (
File, LibType, MachineChoice, MesonException, OrderedSet, PerMachine,
@@ -60,6 +55,7 @@ if T.TYPE_CHECKING:
from ..interpreter import Interpreter
from ..linkers import DynamicLinker, StaticLinker
from ..compilers.cs import CsCompiler
+ from ..compilers.fortran import FortranCompiler
RUST_EDITIONS = Literal['2015', '2018', '2021']
@@ -516,12 +512,12 @@ class NinjaBackend(backends.Backend):
# Have to detect the dependency format
# IFort on windows is MSVC like, but doesn't have /showincludes
- if isinstance(compiler, FortranCompiler):
+ if compiler.language == 'fortran':
continue
- if isinstance(compiler, PGICCompiler) and mesonlib.is_windows():
+ if compiler.id == 'pgi' and mesonlib.is_windows():
# for the purpose of this function, PGI doesn't act enough like MSVC
return open(tempfilename, 'a', encoding='utf-8')
- if isinstance(compiler, VisualStudioLikeCompiler):
+ if compiler.get_argument_syntax() == 'msvc':
break
else:
# None of our compilers are MSVC, we're done.
@@ -2325,7 +2321,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
command = compiler.get_exelist()
args = ['$ARGS'] + depargs + NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none) + compiler.get_compile_only_args() + ['$in']
description = f'Compiling {compiler.get_display_language()} object $out'
- if isinstance(compiler, VisualStudioLikeCompiler):
+ if compiler.get_argument_syntax() == 'msvc':
deps = 'msvc'
depfile = None
else:
@@ -2341,13 +2337,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
rule = self.compiler_to_pch_rule_name(compiler)
depargs = compiler.get_dependency_gen_args('$out', '$DEPFILE')
- if isinstance(compiler, VisualStudioLikeCompiler):
+ if compiler.get_argument_syntax() == 'msvc':
output = []
else:
output = NinjaCommandArg.list(compiler.get_output_args('$out'), Quoting.none)
command = compiler.get_exelist() + ['$ARGS'] + depargs + output + compiler.get_compile_only_args() + ['$in']
description = 'Precompiling header $in'
- if isinstance(compiler, VisualStudioLikeCompiler):
+ if compiler.get_argument_syntax() == 'msvc':
deps = 'msvc'
depfile = None
else:
@@ -2931,8 +2927,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
msg = f'Precompiled header of {target.get_basename()!r} must not be in the same ' \
'directory as source, please put it in a subdirectory.'
raise InvalidArguments(msg)
- compiler = target.compilers[lang]
- if isinstance(compiler, VisualStudioLikeCompiler):
+ compiler: Compiler = target.compilers[lang]
+ if compiler.get_argument_syntax() == 'msvc':
(commands, dep, dst, objs, src) = self.generate_msvc_pch_command(target, compiler, pch)
extradep = os.path.join(self.build_to_src, target.get_source_subdir(), pch[0])
elif compiler.id == 'intel':
@@ -3026,7 +3022,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
def get_link_whole_args(self, linker, target):
use_custom = False
- if isinstance(linker, mixins.visualstudio.MSVCCompiler):
+ if linker.id == 'msvc':
# Expand our object lists manually if we are on pre-Visual Studio 2015 Update 2
# (incidentally, the "linker" here actually refers to cl.exe)
if mesonlib.version_compare(linker.version, '<19.00.23918'):
diff --git a/mesonbuild/cmake/toolchain.py b/mesonbuild/cmake/toolchain.py
index c854828..477629e 100644
--- a/mesonbuild/cmake/toolchain.py
+++ b/mesonbuild/cmake/toolchain.py
@@ -16,7 +16,6 @@ from __future__ import annotations
from pathlib import Path
from .traceparser import CMakeTraceParser
from ..envconfig import CMakeSkipCompilerTest
-from ..compilers import VisualStudioLikeCompiler
from .common import language_map, cmake_get_generator_args
from .. import mlog
@@ -204,7 +203,7 @@ class CMakeToolchain:
@staticmethod
def is_cmdline_option(compiler: 'Compiler', arg: str) -> bool:
- if isinstance(compiler, VisualStudioLikeCompiler):
+ if compiler.get_argument_syntax() == 'msvc':
return arg.startswith('/')
else:
return arg.startswith('-')
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index 6ac7604..394b080 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -845,10 +845,10 @@ class Environment:
def get_compiler_system_dirs(self, for_machine: MachineChoice):
for comp in self.coredata.compilers[for_machine].values():
- if isinstance(comp, compilers.ClangCompiler):
+ if comp.id == 'clang':
index = 1
break
- elif isinstance(comp, compilers.GnuCompiler):
+ elif comp.id == 'gcc':
index = 2
break
else:
diff --git a/unittests/windowstests.py b/unittests/windowstests.py
index 7339ca8..c81d924 100644
--- a/unittests/windowstests.py
+++ b/unittests/windowstests.py
@@ -32,7 +32,6 @@ from mesonbuild.mesonlib import (
)
from mesonbuild.compilers import (
detect_c_compiler, detect_d_compiler, compiler_from_language,
- GnuLikeCompiler
)
from mesonbuild.programs import ExternalProgram
import mesonbuild.dependencies.base
@@ -222,21 +221,21 @@ class WindowsTests(BasePlatformTests):
def test_link_environment_variable_lld_link(self):
env = get_fake_env()
comp = detect_c_compiler(env, MachineChoice.HOST)
- if isinstance(comp, GnuLikeCompiler):
+ if comp.get_argument_syntax() == 'gcc':
raise SkipTest('GCC cannot be used with link compatible linkers.')
self._check_ld('lld-link', 'c', 'lld-link')
def test_link_environment_variable_link(self):
env = get_fake_env()
comp = detect_c_compiler(env, MachineChoice.HOST)
- if isinstance(comp, GnuLikeCompiler):
+ if comp.get_argument_syntax() == 'gcc':
raise SkipTest('GCC cannot be used with link compatible linkers.')
self._check_ld('link', 'c', 'link')
def test_link_environment_variable_optlink(self):
env = get_fake_env()
comp = detect_c_compiler(env, MachineChoice.HOST)
- if isinstance(comp, GnuLikeCompiler):
+ if comp.get_argument_syntax() == 'gcc':
raise SkipTest('GCC cannot be used with link compatible linkers.')
self._check_ld('optlink', 'c', 'optlink')