Skip to content

Commit da8f36f

Browse files
committed
dependencies: Remove log_tried method
It's now only used to populate the DependencyCandidate, so we can remove it and just calculate the same information from the `type_name` parameter. This reduces code and the number of method calls.
1 parent dfb3e2a commit da8f36f

File tree

7 files changed

+13
-40
lines changed

7 files changed

+13
-40
lines changed

mesonbuild/dependencies/base.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,6 @@ def log_details(self) -> str:
464464
def log_info(self) -> str:
465465
return ''
466466

467-
@staticmethod
468-
def log_tried() -> str:
469-
return ''
470-
471467
# Check if dependency version meets the requirements
472468
def _check_version(self) -> None:
473469
if not self.is_found:
@@ -673,21 +669,13 @@ class SystemDependency(ExternalDependency):
673669

674670
type_name = DependencyTypeName('system')
675671

676-
@staticmethod
677-
def log_tried() -> str:
678-
return 'system'
679-
680672

681673
class BuiltinDependency(ExternalDependency):
682674

683675
"""Dependency base for Builtin type dependencies."""
684676

685677
type_name = DependencyTypeName('builtin')
686678

687-
@staticmethod
688-
def log_tried() -> str:
689-
return 'builtin'
690-
691679

692680
@dataclasses.dataclass
693681
class DependencyCandidate(T.Generic[DepType]):
@@ -711,4 +699,12 @@ def from_dependency(cls, name: str, dep: T.Type[DepType],
711699
args: T.Optional[T.Tuple[Environment, DependencyObjectKWs]] = None,
712700
modules: T.Optional[T.List[str]] = None,
713701
) -> DependencyCandidate[DepType]:
714-
return cls(dep, name, dep.log_tried(), modules, arguments=args)
702+
tried = str(dep.type_name)
703+
704+
# fixup the cases where type_name and log tried don't match
705+
if tried in {'extraframeworks', 'appleframeworks'}:
706+
tried = 'framework'
707+
elif tried == 'pkgconfig':
708+
tried = 'pkg-config'
709+
710+
return cls(dep, name, tried, modules, arguments=args)

mesonbuild/dependencies/cmake.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,6 @@ def _call_cmake(self,
609609
build_dir = self._setup_cmake_dir(cmake_file)
610610
return self.cmakebin.call(args, build_dir, env=env)
611611

612-
@staticmethod
613-
def log_tried() -> str:
614-
return 'cmake'
615-
616612
def log_details(self) -> str:
617613
modules = [self._original_module_name(x) for x in self.found_modules]
618614
modules = sorted(set(modules))

mesonbuild/dependencies/configtool.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,6 @@ def get_config_value(self, args: T.List[str], stage: str) -> T.List[str]:
150150
def get_variable_args(self, variable_name: str) -> T.List[str]:
151151
return [f'--{variable_name}']
152152

153-
@staticmethod
154-
def log_tried() -> str:
155-
return 'config-tool'
156-
157153
def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[str] = None,
158154
configtool: T.Optional[str] = None, internal: T.Optional[str] = None,
159155
system: T.Optional[str] = None, default_value: T.Optional[str] = None,

mesonbuild/dependencies/framework.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,3 @@ def _get_framework_include_path(self, path: Path) -> T.Optional[str]:
112112

113113
def log_info(self) -> str:
114114
return self.framework_path or ''
115-
116-
@staticmethod
117-
def log_tried() -> str:
118-
return 'framework'

mesonbuild/dependencies/pkgconfig.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,10 +586,6 @@ def extract_libtool_shlib(self, la_file: str) -> T.Optional[str]:
586586
# a path rather than the raw dlname
587587
return os.path.basename(dlname)
588588

589-
@staticmethod
590-
def log_tried() -> str:
591-
return 'pkgconfig'
592-
593589
def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[str] = None,
594590
configtool: T.Optional[str] = None, internal: T.Optional[str] = None,
595591
system: T.Optional[str] = None, default_value: T.Optional[str] = None,

mesonbuild/dependencies/platform.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,4 @@ def __init__(self, name: str, env: 'Environment', kwargs: DependencyObjectKWs) -
4747
def log_info(self) -> str:
4848
return ', '.join(self.frameworks)
4949

50-
@staticmethod
51-
def log_tried() -> str:
52-
return 'framework'
53-
5450
packages['appleframeworks'] = AppleFrameworks

mesonbuild/dependencies/python.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,6 @@ def __init__(self, name: str, environment: 'Environment',
559559
if not self.clib_compiler.has_header('Python.h', '', environment, extra_args=self.compile_args)[0]:
560560
self.is_found = False
561561

562-
@staticmethod
563-
def log_tried() -> str:
564-
return 'sysconfig'
565-
566562
def python_factory(env: Environment, kwargs: DependencyObjectKWs,
567563
installation: T.Optional['BasicPythonExternalProgram'] = None) -> T.List['DependencyGenerator']:
568564
# We can't use the factory_methods decorator here, as we need to pass the
@@ -579,15 +575,16 @@ def python_factory(env: Environment, kwargs: DependencyObjectKWs,
579575
if from_installation:
580576
candidates.append(DependencyCandidate(
581577
functools.partial(PythonPkgConfigDependency, installation=installation),
582-
'python', PythonPkgConfigDependency.log_tried(), arguments=(env, kwargs)))
578+
'python', PythonPkgConfigDependency.type_name, arguments=(env, kwargs)))
583579
else:
584580
candidates.append(DependencyCandidate.from_dependency(
585581
'python3', PkgConfigDependency, (env, kwargs)))
586582

587583
if DependencyMethods.SYSTEM in methods:
584+
# This is a unique log-tried.
588585
candidates.append(DependencyCandidate(
589586
functools.partial(PythonSystemDependency, installation=installation),
590-
'python', PythonSystemDependency.log_tried(), arguments=(env, kwargs)))
587+
'python', 'sysconfig', arguments=(env, kwargs)))
591588

592589
if DependencyMethods.EXTRAFRAMEWORK in methods:
593590
nkwargs = kwargs.copy()
@@ -597,7 +594,7 @@ def python_factory(env: Environment, kwargs: DependencyObjectKWs,
597594
nkwargs['paths'] = ['/Library/Frameworks']
598595
candidates.append(DependencyCandidate(
599596
functools.partial(PythonFrameworkDependency, installation=installation),
600-
'python', PythonFrameworkDependency.log_tried(), arguments=(env, nkwargs)))
597+
'python', PythonPkgConfigDependency.type_name, arguments=(env, nkwargs)))
601598

602599
return candidates
603600

0 commit comments

Comments
 (0)