Skip to content

Commit

Permalink
dependencies: Make MissingCompiler an implementation detail
Browse files Browse the repository at this point in the history
Since type checkers now view MisingCompiler as a Compiler, and it
provides a method to determine that it is missing (language ==
'missing'), we don't need to expose it anywhere, it's just an
implementation detail of the dependencies.base module.
  • Loading branch information
dcbaker committed Dec 6, 2023
1 parent 014d3fe commit be4a5cc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions mesonbuild/cmake/tracetargets.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from .traceparser import CMakeTraceParser
from ..environment import Environment
from ..compilers import Compiler
from ..dependencies import MissingCompiler

class ResolvedTarget:
def __init__(self) -> None:
Expand All @@ -26,7 +25,7 @@ def resolve_cmake_trace_targets(target_name: str,
trace: 'CMakeTraceParser',
env: 'Environment',
*,
clib_compiler: T.Union['MissingCompiler', 'Compiler'] = None,
clib_compiler: T.Optional[Compiler] = None,
not_found_warning: T.Callable[[str], None] = lambda x: None) -> ResolvedTarget:
res = ResolvedTarget()
targets = [target_name]
Expand Down
3 changes: 1 addition & 2 deletions mesonbuild/dependencies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .base import Dependency, InternalDependency, ExternalDependency, NotFoundDependency, MissingCompiler
from .base import Dependency, InternalDependency, ExternalDependency, NotFoundDependency
from .base import (
ExternalLibrary, DependencyException, DependencyMethods,
BuiltinDependency, SystemDependency, get_leaf_external_dependencies)
Expand All @@ -28,7 +28,6 @@
'ExternalLibrary',
'DependencyException',
'DependencyMethods',
'MissingCompiler',

'find_external_dependency',
'get_dep_identifier',
Expand Down
4 changes: 2 additions & 2 deletions mesonbuild/dependencies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def __init__(self, type_name: DependencyTypeName, environment: 'Environment', kw
# Is this dependency to be run on the build platform?
self.clib_compiler = detect_compiler(self.name, environment, self.for_machine, self.language)

def get_compiler(self) -> T.Union['MissingCompiler', 'Compiler']:
def get_compiler(self) -> Compiler:
return self.clib_compiler

def get_partial_dependency(self, *, compile_args: bool = False,
Expand Down Expand Up @@ -582,7 +582,7 @@ def process_method_kw(possible: T.Iterable[DependencyMethods], kwargs: Dependenc
return methods

def detect_compiler(name: str, env: 'Environment', for_machine: MachineChoice,
language: T.Optional[str]) -> T.Union['MissingCompiler', 'Compiler']:
language: T.Optional[str]) -> Compiler:
"""Given a language and environment find the compiler used."""
compilers = env.coredata.compilers[for_machine]

Expand Down
3 changes: 1 addition & 2 deletions mesonbuild/dependencies/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from ..compilers import Compiler
from ..envconfig import MachineInfo
from ..environment import Environment
from ..dependencies import MissingCompiler
from ..interpreter.kwargs import Dependency as DependencyKw


Expand Down Expand Up @@ -132,7 +131,7 @@ class _QtBase:
"""Mixin class for shared components between PkgConfig and Qmake."""

link_args: T.List[str]
clib_compiler: T.Union['MissingCompiler', 'Compiler']
clib_compiler: Compiler
env: 'Environment'
libexecdir: T.Optional[str] = None

Expand Down

0 comments on commit be4a5cc

Please sign in to comment.