fix implicit_reexport issues and enforce them going forward

This detects cases where module A imports a function from B, and C
imports that same function from A instead of B. It's not part of the API
contract of A, and causes innocent refactoring to break things.
pull/11938/head
Eli Schwartz 2 years ago
parent cfc3960956
commit 7afc69254d
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 1
      .mypy.ini
  2. 14
      mesonbuild/backend/backends.py
  3. 21
      mesonbuild/build.py
  4. 3
      mesonbuild/compilers/mixins/clike.py
  5. 5
      mesonbuild/compilers/vala.py
  6. 3
      mesonbuild/dependencies/boost.py
  7. 3
      mesonbuild/dependencies/coarrays.py
  8. 8
      mesonbuild/dependencies/misc.py
  9. 3
      mesonbuild/dependencies/mpi.py
  10. 4
      mesonbuild/dependencies/pkgconfig.py
  11. 3
      mesonbuild/dependencies/scalapack.py
  12. 15
      mesonbuild/interpreter/interpreter.py
  13. 10
      mesonbuild/interpreter/interpreterobjects.py
  14. 12
      mesonbuild/interpreter/kwargs.py
  15. 13
      mesonbuild/interpreter/mesonmain.py
  16. 3
      mesonbuild/interpreterbase/decorators.py
  17. 15
      mesonbuild/interpreterbase/interpreterbase.py
  18. 4
      mesonbuild/mconf.py
  19. 4
      mesonbuild/mdevenv.py
  20. 8
      mesonbuild/minstall.py
  21. 2
      mesonbuild/mintro.py
  22. 11
      mesonbuild/modules/__init__.py
  23. 5
      mesonbuild/modules/external_project.py
  24. 8
      mesonbuild/modules/gnome.py
  25. 2
      mesonbuild/modules/hotdoc.py
  26. 2
      mesonbuild/modules/pkgconfig.py
  27. 2
      mesonbuild/modules/python.py
  28. 4
      mesonbuild/mtest.py
  29. 3
      mesonbuild/programs.py
  30. 2
      mesonbuild/utils/posix.py
  31. 3
      mesonbuild/utils/vsenv.py
  32. 2
      mesonbuild/utils/win32.py

@ -3,6 +3,7 @@ strict_optional = False
show_error_context = False show_error_context = False
show_column_numbers = True show_column_numbers = True
ignore_missing_imports = True ignore_missing_imports = True
implicit_reexport = False
follow_imports = silent follow_imports = silent
warn_redundant_casts = True warn_redundant_casts = True

@ -202,7 +202,7 @@ class TestSerialisation:
needs_exe_wrapper: bool needs_exe_wrapper: bool
is_parallel: bool is_parallel: bool
cmd_args: T.List[str] cmd_args: T.List[str]
env: build.EnvironmentVariables env: mesonlib.EnvironmentVariables
should_fail: bool should_fail: bool
timeout: T.Optional[int] timeout: T.Optional[int]
workdir: T.Optional[str] workdir: T.Optional[str]
@ -512,7 +512,7 @@ class Backend:
extra_bdeps: T.Optional[T.List[build.BuildTarget]] = None, extra_bdeps: T.Optional[T.List[build.BuildTarget]] = None,
capture: T.Optional[bool] = None, capture: T.Optional[bool] = None,
feed: T.Optional[bool] = None, feed: T.Optional[bool] = None,
env: T.Optional[build.EnvironmentVariables] = None, env: T.Optional[mesonlib.EnvironmentVariables] = None,
tag: T.Optional[str] = None, tag: T.Optional[str] = None,
verbose: bool = False, verbose: bool = False,
installdir_map: T.Optional[T.Dict[str, str]] = None) -> 'ExecutableSerialisation': installdir_map: T.Optional[T.Dict[str, str]] = None) -> 'ExecutableSerialisation':
@ -585,7 +585,7 @@ class Backend:
capture: T.Optional[bool] = None, capture: T.Optional[bool] = None,
feed: T.Optional[bool] = None, feed: T.Optional[bool] = None,
force_serialize: bool = False, force_serialize: bool = False,
env: T.Optional[build.EnvironmentVariables] = None, env: T.Optional[mesonlib.EnvironmentVariables] = None,
verbose: bool = False) -> T.Tuple[T.Sequence[T.Union[str, File, build.Target, programs.ExternalProgram]], str]: verbose: bool = False) -> T.Tuple[T.Sequence[T.Union[str, File, build.Target, programs.ExternalProgram]], str]:
''' '''
Serialize an executable for running with a generator or a custom target Serialize an executable for running with a generator or a custom target
@ -1588,8 +1588,8 @@ class Backend:
cmd = [i.replace('\\', '/') for i in cmd] cmd = [i.replace('\\', '/') for i in cmd]
return inputs, outputs, cmd return inputs, outputs, cmd
def get_run_target_env(self, target: build.RunTarget) -> build.EnvironmentVariables: def get_run_target_env(self, target: build.RunTarget) -> mesonlib.EnvironmentVariables:
env = target.env if target.env else build.EnvironmentVariables() env = target.env if target.env else mesonlib.EnvironmentVariables()
if target.default_env: if target.default_env:
introspect_cmd = join_args(self.environment.get_build_command() + ['introspect']) introspect_cmd = join_args(self.environment.get_build_command() + ['introspect'])
env.set('MESON_SOURCE_ROOT', [self.environment.get_source_dir()]) env.set('MESON_SOURCE_ROOT', [self.environment.get_source_dir()])
@ -1959,8 +1959,8 @@ class Backend:
return [] return []
def get_devenv(self) -> build.EnvironmentVariables: def get_devenv(self) -> mesonlib.EnvironmentVariables:
env = build.EnvironmentVariables() env = mesonlib.EnvironmentVariables()
extra_paths = set() extra_paths = set()
library_paths = set() library_paths = set()
build_machine = self.environment.machines[MachineChoice.BUILD] build_machine = self.environment.machines[MachineChoice.BUILD]

@ -39,7 +39,7 @@ from .mesonlib import (
MesonBugException, EnvironmentVariables, pickle_load, MesonBugException, EnvironmentVariables, pickle_load,
) )
from .compilers import ( from .compilers import (
is_object, clink_langs, sort_clink, all_languages, is_header, is_object, is_source, clink_langs, sort_clink, all_languages,
is_known_suffix, detect_static_linker is_known_suffix, detect_static_linker
) )
from .interpreterbase import FeatureNew, FeatureDeprecated from .interpreterbase import FeatureNew, FeatureDeprecated
@ -47,12 +47,13 @@ from .interpreterbase import FeatureNew, FeatureDeprecated
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from typing_extensions import Literal from typing_extensions import Literal
from ._typing import ImmutableListProtocol from ._typing import ImmutableListProtocol
from .backend.backends import Backend, ExecutableSerialisation from .backend.backends import Backend
from .compilers import Compiler from .compilers import Compiler
from .interpreter.interpreter import Test, SourceOutputs, Interpreter from .interpreter.interpreter import SourceOutputs, Interpreter
from .interpreter.interpreterobjects import Test
from .interpreterbase import SubProject from .interpreterbase import SubProject
from .linkers.linkers import StaticLinker from .linkers.linkers import StaticLinker
from .mesonlib import FileMode, FileOrString from .mesonlib import ExecutableSerialisation, FileMode, FileOrString
from .modules import ModuleState from .modules import ModuleState
from .mparser import BaseNode from .mparser import BaseNode
from .wrap import WrapMode from .wrap import WrapMode
@ -434,7 +435,7 @@ class ExtractedObjects(HoldableObject):
sources.append(s) sources.append(s)
# Filter out headers and all non-source files # Filter out headers and all non-source files
return [s for s in sources if environment.is_source(s)] return [s for s in sources if is_source(s)]
def classify_all_sources(self, sources: T.List[FileOrString], generated_sources: T.Sequence['GeneratedTypes']) -> T.Dict['Compiler', T.List['FileOrString']]: def classify_all_sources(self, sources: T.List[FileOrString], generated_sources: T.Sequence['GeneratedTypes']) -> T.Dict['Compiler', T.List['FileOrString']]:
sources_ = self.get_sources(sources, generated_sources) sources_ = self.get_sources(sources, generated_sources)
@ -1494,14 +1495,14 @@ You probably should put it in link_with instead.''')
if not pchlist: if not pchlist:
return return
elif len(pchlist) == 1: elif len(pchlist) == 1:
if not environment.is_header(pchlist[0]): if not is_header(pchlist[0]):
raise InvalidArguments(f'PCH argument {pchlist[0]} is not a header.') raise InvalidArguments(f'PCH argument {pchlist[0]} is not a header.')
elif len(pchlist) == 2: elif len(pchlist) == 2:
if environment.is_header(pchlist[0]): if is_header(pchlist[0]):
if not environment.is_source(pchlist[1]): if not is_source(pchlist[1]):
raise InvalidArguments('PCH definition must contain one header and at most one source.') raise InvalidArguments('PCH definition must contain one header and at most one source.')
elif environment.is_source(pchlist[0]): elif is_source(pchlist[0]):
if not environment.is_header(pchlist[1]): if not is_header(pchlist[1]):
raise InvalidArguments('PCH definition must contain one header and at most one source.') raise InvalidArguments('PCH definition must contain one header and at most one source.')
pchlist = [pchlist[1], pchlist[0]] pchlist = [pchlist[1], pchlist[0]]
else: else:

@ -36,8 +36,7 @@ from ... import arglist
from ... import mesonlib from ... import mesonlib
from ... import mlog from ... import mlog
from ...linkers.linkers import GnuLikeDynamicLinkerMixin, SolarisDynamicLinker, CompCertDynamicLinker from ...linkers.linkers import GnuLikeDynamicLinkerMixin, SolarisDynamicLinker, CompCertDynamicLinker
from ...mesonlib import LibType from ...mesonlib import LibType, OptionKey
from ...coredata import OptionKey
from .. import compilers from .. import compilers
from ..compilers import CompileCheckMode from ..compilers import CompileCheckMode
from .visualstudio import VisualStudioLikeCompiler from .visualstudio import VisualStudioLikeCompiler

@ -17,9 +17,8 @@ import os.path
import typing as T import typing as T
from .. import mlog from .. import mlog
from ..mesonlib import EnvironmentException, version_compare, OptionKey from ..mesonlib import EnvironmentException, version_compare, LibType, OptionKey
from .compilers import CompileCheckMode, Compiler
from .compilers import CompileCheckMode, Compiler, LibType
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ..envconfig import MachineInfo from ..envconfig import MachineInfo

@ -28,7 +28,8 @@ from .pkgconfig import PkgConfigDependency
from .misc import threads_factory from .misc import threads_factory
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ..environment import Environment, Properties from ..envconfig import Properties
from ..environment import Environment
# On windows 3 directory layouts are supported: # On windows 3 directory layouts are supported:
# * The default layout (versioned) installed: # * The default layout (versioned) installed:

@ -24,7 +24,8 @@ from .factory import factory_methods
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from . factory import DependencyGenerator from . factory import DependencyGenerator
from ..environment import Environment, MachineChoice from ..environment import Environment
from ..mesonlib import MachineChoice
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE, DependencyMethods.SYSTEM}) @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE, DependencyMethods.SYSTEM})

@ -30,13 +30,13 @@ from .factory import DependencyFactory, factory_methods
from .pkgconfig import PkgConfigDependency from .pkgconfig import PkgConfigDependency
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ..environment import Environment, MachineChoice from ..environment import Environment
from .factory import DependencyGenerator from .factory import DependencyGenerator
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE}) @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CMAKE})
def netcdf_factory(env: 'Environment', def netcdf_factory(env: 'Environment',
for_machine: 'MachineChoice', for_machine: 'mesonlib.MachineChoice',
kwargs: T.Dict[str, T.Any], kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']: methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
language = kwargs.get('language', 'c') language = kwargs.get('language', 'c')
@ -475,7 +475,7 @@ class OpensslSystemDependency(SystemDependency):
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM}) @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM})
def curses_factory(env: 'Environment', def curses_factory(env: 'Environment',
for_machine: 'MachineChoice', for_machine: 'mesonlib.MachineChoice',
kwargs: T.Dict[str, T.Any], kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']: methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
candidates: T.List['DependencyGenerator'] = [] candidates: T.List['DependencyGenerator'] = []
@ -501,7 +501,7 @@ packages['curses'] = curses_factory
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM}) @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.SYSTEM})
def shaderc_factory(env: 'Environment', def shaderc_factory(env: 'Environment',
for_machine: 'MachineChoice', for_machine: 'mesonlib.MachineChoice',
kwargs: T.Dict[str, T.Any], kwargs: T.Dict[str, T.Any],
methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']: methods: T.List[DependencyMethods]) -> T.List['DependencyGenerator']:
"""Custom DependencyFactory for ShaderC. """Custom DependencyFactory for ShaderC.

@ -27,7 +27,8 @@ from .pkgconfig import PkgConfigDependency
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from .factory import DependencyGenerator from .factory import DependencyGenerator
from ..environment import Environment, MachineChoice from ..environment import Environment
from ..mesonlib import MachineChoice
@factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM}) @factory_methods({DependencyMethods.PKGCONFIG, DependencyMethods.CONFIG_TOOL, DependencyMethods.SYSTEM})

@ -16,7 +16,7 @@ from __future__ import annotations
from pathlib import Path from pathlib import Path
from .base import ExternalDependency, DependencyException, sort_libpaths, DependencyTypeName from .base import ExternalDependency, DependencyException, sort_libpaths, DependencyTypeName
from ..mesonlib import OptionKey, OrderedSet, PerMachine, Popen_safe, Popen_safe_logged from ..mesonlib import EnvironmentVariables, OptionKey, OrderedSet, PerMachine, Popen_safe, Popen_safe_logged
from ..programs import find_external_program, ExternalProgram from ..programs import find_external_program, ExternalProgram
from .. import mlog from .. import mlog
from pathlib import PurePath from pathlib import PurePath
@ -30,7 +30,6 @@ if T.TYPE_CHECKING:
from ..mesonlib import MachineChoice from ..mesonlib import MachineChoice
from ..utils.core import EnvironOrDict from ..utils.core import EnvironOrDict
from .._typing import ImmutableListProtocol from .._typing import ImmutableListProtocol
from ..build import EnvironmentVariables
class PkgConfigDependency(ExternalDependency): class PkgConfigDependency(ExternalDependency):
# The class's copy of the pkg-config path. Avoids having to search for it # The class's copy of the pkg-config path. Avoids having to search for it
@ -128,7 +127,6 @@ class PkgConfigDependency(ExternalDependency):
@staticmethod @staticmethod
def get_env(environment: 'Environment', for_machine: MachineChoice, def get_env(environment: 'Environment', for_machine: MachineChoice,
uninstalled: bool = False) -> 'EnvironmentVariables': uninstalled: bool = False) -> 'EnvironmentVariables':
from ..build import EnvironmentVariables
env = EnvironmentVariables() env = EnvironmentVariables()
key = OptionKey('pkg_config_path', machine=for_machine) key = OptionKey('pkg_config_path', machine=for_machine)
extra_paths: T.List[str] = environment.coredata.options[key].value[:] extra_paths: T.List[str] = environment.coredata.options[key].value[:]

@ -27,7 +27,8 @@ from .pkgconfig import PkgConfigDependency
from .factory import factory_methods from .factory import factory_methods
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from ..environment import Environment, MachineChoice from ..environment import Environment
from ..mesonlib import MachineChoice
from .factory import DependencyGenerator from .factory import DependencyGenerator

@ -23,7 +23,7 @@ from .. import compilers
from .. import envconfig from .. import envconfig
from ..wrap import wrap, WrapMode from ..wrap import wrap, WrapMode
from .. import mesonlib from .. import mesonlib
from ..mesonlib import (MesonBugException, MesonException, HoldableObject, from ..mesonlib import (EnvironmentVariables, ExecutableSerialisation, MesonBugException, MesonException, HoldableObject,
FileMode, MachineChoice, OptionKey, listify, FileMode, MachineChoice, OptionKey, listify,
extract_as_list, has_path_sep, PerMachine) extract_as_list, has_path_sep, PerMachine)
from ..programs import ExternalProgram, NonExistingExternalProgram from ..programs import ExternalProgram, NonExistingExternalProgram
@ -36,7 +36,6 @@ from ..interpreterbase import Disabler, disablerIfNotFound
from ..interpreterbase import FeatureNew, FeatureDeprecated, FeatureBroken, FeatureNewKwargs, FeatureDeprecatedKwargs from ..interpreterbase import FeatureNew, FeatureDeprecated, FeatureBroken, FeatureNewKwargs, FeatureDeprecatedKwargs
from ..interpreterbase import ObjectHolder, ContextManagerObject from ..interpreterbase import ObjectHolder, ContextManagerObject
from ..modules import ExtensionModule, ModuleObject, MutableModuleObject, NewExtensionModule, NotFoundExtensionModule from ..modules import ExtensionModule, ModuleObject, MutableModuleObject, NewExtensionModule, NotFoundExtensionModule
from ..backend.backends import ExecutableSerialisation
from . import interpreterobjects as OBJ from . import interpreterobjects as OBJ
from . import compiler as compilerOBJ from . import compiler as compilerOBJ
@ -458,7 +457,7 @@ class Interpreter(InterpreterBase, HoldableObject):
build.SymlinkData: OBJ.SymlinkDataHolder, build.SymlinkData: OBJ.SymlinkDataHolder,
build.InstallDir: OBJ.InstallDirHolder, build.InstallDir: OBJ.InstallDirHolder,
build.IncludeDirs: OBJ.IncludeDirsHolder, build.IncludeDirs: OBJ.IncludeDirsHolder,
build.EnvironmentVariables: OBJ.EnvironmentVariablesHolder, mesonlib.EnvironmentVariables: OBJ.EnvironmentVariablesHolder,
build.StructuredSources: OBJ.StructuredSourcesHolder, build.StructuredSources: OBJ.StructuredSourcesHolder,
compilers.RunResult: compilerOBJ.TryRunResultHolder, compilers.RunResult: compilerOBJ.TryRunResultHolder,
dependencies.ExternalLibrary: OBJ.ExternalLibraryHolder, dependencies.ExternalLibrary: OBJ.ExternalLibraryHolder,
@ -2166,10 +2165,10 @@ class Interpreter(InterpreterBase, HoldableObject):
kwargs: 'kwtypes.FuncTest') -> None: kwargs: 'kwtypes.FuncTest') -> None:
self.add_test(node, args, kwargs, True) self.add_test(node, args, kwargs, True)
def unpack_env_kwarg(self, kwargs: T.Union[build.EnvironmentVariables, T.Dict[str, 'TYPE_var'], T.List['TYPE_var'], str]) -> build.EnvironmentVariables: def unpack_env_kwarg(self, kwargs: T.Union[EnvironmentVariables, T.Dict[str, 'TYPE_var'], T.List['TYPE_var'], str]) -> EnvironmentVariables:
envlist = kwargs.get('env') envlist = kwargs.get('env')
if envlist is None: if envlist is None:
return build.EnvironmentVariables() return EnvironmentVariables()
msg = ENV_KW.validator(envlist) msg = ENV_KW.validator(envlist)
if msg: if msg:
raise InvalidArguments(f'"env": {msg}') raise InvalidArguments(f'"env": {msg}')
@ -2687,7 +2686,7 @@ class Interpreter(InterpreterBase, HoldableObject):
mlog.log('Configuring', mlog.bold(output), 'with command') mlog.log('Configuring', mlog.bold(output), 'with command')
cmd, *args = _cmd cmd, *args = _cmd
res = self.run_command_impl(node, (cmd, args), res = self.run_command_impl(node, (cmd, args),
{'capture': True, 'check': True, 'env': build.EnvironmentVariables()}, {'capture': True, 'check': True, 'env': EnvironmentVariables()},
True) True)
if kwargs['capture']: if kwargs['capture']:
dst_tmp = ofile_abs + '~' dst_tmp = ofile_abs + '~'
@ -2967,7 +2966,7 @@ class Interpreter(InterpreterBase, HoldableObject):
@typed_pos_args('environment', optargs=[(str, list, dict)]) @typed_pos_args('environment', optargs=[(str, list, dict)])
@typed_kwargs('environment', ENV_METHOD_KW, ENV_SEPARATOR_KW.evolve(since='0.62.0')) @typed_kwargs('environment', ENV_METHOD_KW, ENV_SEPARATOR_KW.evolve(since='0.62.0'))
def func_environment(self, node: mparser.FunctionNode, args: T.Tuple[T.Union[None, str, T.List['TYPE_var'], T.Dict[str, 'TYPE_var']]], def func_environment(self, node: mparser.FunctionNode, args: T.Tuple[T.Union[None, str, T.List['TYPE_var'], T.Dict[str, 'TYPE_var']]],
kwargs: 'TYPE_kwargs') -> build.EnvironmentVariables: kwargs: 'TYPE_kwargs') -> EnvironmentVariables:
init = args[0] init = args[0]
if init is not None: if init is not None:
FeatureNew.single_use('environment positional arguments', '0.52.0', self.subproject, location=node) FeatureNew.single_use('environment positional arguments', '0.52.0', self.subproject, location=node)
@ -2977,7 +2976,7 @@ class Interpreter(InterpreterBase, HoldableObject):
if isinstance(init, dict) and any(i for i in init.values() if isinstance(i, list)): if isinstance(init, dict) and any(i for i in init.values() if isinstance(i, list)):
FeatureNew.single_use('List of string in dictionary value', '0.62.0', self.subproject, location=node) FeatureNew.single_use('List of string in dictionary value', '0.62.0', self.subproject, location=node)
return env_convertor_with_method(init, kwargs['method'], kwargs['separator']) return env_convertor_with_method(init, kwargs['method'], kwargs['separator'])
return build.EnvironmentVariables() return EnvironmentVariables()
@typed_pos_args('join_paths', varargs=str, min_varargs=1) @typed_pos_args('join_paths', varargs=str, min_varargs=1)
@noKwargs @noKwargs

@ -203,7 +203,7 @@ class RunProcess(MesonInterpreterObject):
def __init__(self, def __init__(self,
cmd: ExternalProgram, cmd: ExternalProgram,
args: T.List[str], args: T.List[str],
env: build.EnvironmentVariables, env: mesonlib.EnvironmentVariables,
source_dir: str, source_dir: str,
build_dir: str, build_dir: str,
subdir: str, subdir: str,
@ -224,7 +224,7 @@ class RunProcess(MesonInterpreterObject):
def run_command(self, def run_command(self,
cmd: ExternalProgram, cmd: ExternalProgram,
args: T.List[str], args: T.List[str],
env: build.EnvironmentVariables, env: mesonlib.EnvironmentVariables,
source_dir: str, source_dir: str,
build_dir: str, build_dir: str,
subdir: str, subdir: str,
@ -280,9 +280,9 @@ class RunProcess(MesonInterpreterObject):
def stderr_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str: def stderr_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
return self.stderr return self.stderr
class EnvironmentVariablesHolder(ObjectHolder[build.EnvironmentVariables], MutableInterpreterObject): class EnvironmentVariablesHolder(ObjectHolder[mesonlib.EnvironmentVariables], MutableInterpreterObject):
def __init__(self, obj: build.EnvironmentVariables, interpreter: 'Interpreter'): def __init__(self, obj: mesonlib.EnvironmentVariables, interpreter: 'Interpreter'):
super().__init__(obj, interpreter) super().__init__(obj, interpreter)
self.methods.update({'set': self.set_method, self.methods.update({'set': self.set_method,
'append': self.append_method, 'append': self.append_method,
@ -711,7 +711,7 @@ class Test(MesonInterpreterObject):
depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]], depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]],
is_parallel: bool, is_parallel: bool,
cmd_args: T.List[T.Union[str, mesonlib.File, build.Target]], cmd_args: T.List[T.Union[str, mesonlib.File, build.Target]],
env: build.EnvironmentVariables, env: mesonlib.EnvironmentVariables,
should_fail: bool, timeout: int, workdir: T.Optional[str], protocol: str, should_fail: bool, timeout: int, workdir: T.Optional[str], protocol: str,
priority: int, verbose: bool): priority: int, verbose: bool):
super().__init__() super().__init__()

@ -12,7 +12,7 @@ from typing_extensions import TypedDict, Literal, Protocol
from .. import build from .. import build
from .. import coredata from .. import coredata
from ..compilers import Compiler from ..compilers import Compiler
from ..mesonlib import MachineChoice, File, FileMode, FileOrString, OptionKey from ..mesonlib import EnvironmentVariables, MachineChoice, File, FileMode, FileOrString, OptionKey
from ..modules.cmake import CMakeSubprojectOptions from ..modules.cmake import CMakeSubprojectOptions
from ..programs import ExternalProgram from ..programs import ExternalProgram
@ -42,7 +42,7 @@ class BaseTest(TypedDict):
workdir: T.Optional[str] workdir: T.Optional[str]
depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]] depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]]
priority: int priority: int
env: build.EnvironmentVariables env: EnvironmentVariables
suite: T.List[str] suite: T.List[str]
@ -164,7 +164,7 @@ class RunTarget(TypedDict):
command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, ExternalProgram, File]] command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, ExternalProgram, File]]
depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]] depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]]
env: build.EnvironmentVariables env: EnvironmentVariables
class CustomTarget(TypedDict): class CustomTarget(TypedDict):
@ -179,7 +179,7 @@ class CustomTarget(TypedDict):
depend_files: T.List[FileOrString] depend_files: T.List[FileOrString]
depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]] depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]]
depfile: T.Optional[str] depfile: T.Optional[str]
env: build.EnvironmentVariables env: EnvironmentVariables
feed: bool feed: bool
input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]] build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]]
@ -196,7 +196,7 @@ class AddTestSetup(TypedDict):
timeout_multiplier: int timeout_multiplier: int
is_default: bool is_default: bool
exclude_suites: T.List[str] exclude_suites: T.List[str]
env: build.EnvironmentVariables env: EnvironmentVariables
class Project(TypedDict): class Project(TypedDict):
@ -240,7 +240,7 @@ class RunCommand(TypedDict):
check: bool check: bool
capture: T.Optional[bool] capture: T.Optional[bool]
env: build.EnvironmentVariables env: EnvironmentVariables
class FeatureOptionRequire(TypedDict): class FeatureOptionRequire(TypedDict):

@ -21,14 +21,13 @@ from .primitives import MesonVersionString
from .type_checking import NATIVE_KW, NoneType from .type_checking import NATIVE_KW, NoneType
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from typing_extensions import Literal from typing_extensions import Literal, TypedDict
from ..backend.backends import ExecutableSerialisation
from ..compilers import Compiler from ..compilers import Compiler
from ..interpreterbase import TYPE_kwargs, TYPE_var from ..interpreterbase import TYPE_kwargs, TYPE_var
from ..mesonlib import ExecutableSerialisation
from .interpreter import Interpreter from .interpreter import Interpreter
from typing_extensions import TypedDict
class FuncOverrideDependency(TypedDict): class FuncOverrideDependency(TypedDict):
native: mesonlib.MachineChoice native: mesonlib.MachineChoice
@ -456,15 +455,15 @@ class MesonMain(MesonInterpreterObject):
@FeatureNew('add_devenv', '0.58.0') @FeatureNew('add_devenv', '0.58.0')
@typed_kwargs('environment', ENV_METHOD_KW, ENV_SEPARATOR_KW.evolve(since='0.62.0')) @typed_kwargs('environment', ENV_METHOD_KW, ENV_SEPARATOR_KW.evolve(since='0.62.0'))
@typed_pos_args('add_devenv', (str, list, dict, build.EnvironmentVariables)) @typed_pos_args('add_devenv', (str, list, dict, mesonlib.EnvironmentVariables))
def add_devenv_method(self, args: T.Tuple[T.Union[str, list, dict, build.EnvironmentVariables]], def add_devenv_method(self, args: T.Tuple[T.Union[str, list, dict, mesonlib.EnvironmentVariables]],
kwargs: 'AddDevenvKW') -> None: kwargs: 'AddDevenvKW') -> None:
env = args[0] env = args[0]
msg = ENV_KW.validator(env) msg = ENV_KW.validator(env)
if msg: if msg:
raise build.InvalidArguments(f'"add_devenv": {msg}') raise build.InvalidArguments(f'"add_devenv": {msg}')
converted = env_convertor_with_method(env, kwargs['method'], kwargs['separator']) converted = env_convertor_with_method(env, kwargs['method'], kwargs['separator'])
assert isinstance(converted, build.EnvironmentVariables) assert isinstance(converted, mesonlib.EnvironmentVariables)
self.build.devenv.append(converted) self.build.devenv.append(converted)
@noPosargs @noPosargs

@ -29,8 +29,7 @@ if T.TYPE_CHECKING:
from typing_extensions import Protocol from typing_extensions import Protocol
from .. import mparser from .. import mparser
from .baseobjects import InterpreterObject, TV_func, TYPE_var, TYPE_kwargs from .baseobjects import InterpreterObject, SubProject, TV_func, TYPE_var, TYPE_kwargs
from .interpreterbase import SubProject
from .operator import MesonOperator from .operator import MesonOperator
_TV_IntegerObject = T.TypeVar('_TV_IntegerObject', bound=InterpreterObject, contravariant=True) _TV_IntegerObject = T.TypeVar('_TV_IntegerObject', bound=InterpreterObject, contravariant=True)

@ -36,7 +36,6 @@ from .exceptions import (
InterpreterException, InterpreterException,
InvalidArguments, InvalidArguments,
InvalidCode, InvalidCode,
MesonException,
SubdirDoneRequest, SubdirDoneRequest,
) )
@ -319,12 +318,12 @@ class InterpreterBase:
def evaluate_comparison(self, node: mparser.ComparisonNode) -> InterpreterObject: def evaluate_comparison(self, node: mparser.ComparisonNode) -> InterpreterObject:
val1 = self.evaluate_statement(node.left) val1 = self.evaluate_statement(node.left)
if val1 is None: if val1 is None:
raise MesonException('Cannot compare a void statement on the left-hand side') raise mesonlib.MesonException('Cannot compare a void statement on the left-hand side')
if isinstance(val1, Disabler): if isinstance(val1, Disabler):
return val1 return val1
val2 = self.evaluate_statement(node.right) val2 = self.evaluate_statement(node.right)
if val2 is None: if val2 is None:
raise MesonException('Cannot compare a void statement on the right-hand side') raise mesonlib.MesonException('Cannot compare a void statement on the right-hand side')
if isinstance(val2, Disabler): if isinstance(val2, Disabler):
return val2 return val2
@ -350,7 +349,7 @@ class InterpreterBase:
def evaluate_andstatement(self, cur: mparser.AndNode) -> InterpreterObject: def evaluate_andstatement(self, cur: mparser.AndNode) -> InterpreterObject:
l = self.evaluate_statement(cur.left) l = self.evaluate_statement(cur.left)
if l is None: if l is None:
raise MesonException('Cannot compare a void statement on the left-hand side') raise mesonlib.MesonException('Cannot compare a void statement on the left-hand side')
if isinstance(l, Disabler): if isinstance(l, Disabler):
return l return l
l_bool = l.operator_call(MesonOperator.BOOL, None) l_bool = l.operator_call(MesonOperator.BOOL, None)
@ -358,7 +357,7 @@ class InterpreterBase:
return self._holderify(l_bool) return self._holderify(l_bool)
r = self.evaluate_statement(cur.right) r = self.evaluate_statement(cur.right)
if r is None: if r is None:
raise MesonException('Cannot compare a void statement on the right-hand side') raise mesonlib.MesonException('Cannot compare a void statement on the right-hand side')
if isinstance(r, Disabler): if isinstance(r, Disabler):
return r return r
return self._holderify(r.operator_call(MesonOperator.BOOL, None)) return self._holderify(r.operator_call(MesonOperator.BOOL, None))
@ -366,7 +365,7 @@ class InterpreterBase:
def evaluate_orstatement(self, cur: mparser.OrNode) -> InterpreterObject: def evaluate_orstatement(self, cur: mparser.OrNode) -> InterpreterObject:
l = self.evaluate_statement(cur.left) l = self.evaluate_statement(cur.left)
if l is None: if l is None:
raise MesonException('Cannot compare a void statement on the left-hand side') raise mesonlib.MesonException('Cannot compare a void statement on the left-hand side')
if isinstance(l, Disabler): if isinstance(l, Disabler):
return l return l
l_bool = l.operator_call(MesonOperator.BOOL, None) l_bool = l.operator_call(MesonOperator.BOOL, None)
@ -374,7 +373,7 @@ class InterpreterBase:
return self._holderify(l_bool) return self._holderify(l_bool)
r = self.evaluate_statement(cur.right) r = self.evaluate_statement(cur.right)
if r is None: if r is None:
raise MesonException('Cannot compare a void statement on the right-hand side') raise mesonlib.MesonException('Cannot compare a void statement on the right-hand side')
if isinstance(r, Disabler): if isinstance(r, Disabler):
return r return r
return self._holderify(r.operator_call(MesonOperator.BOOL, None)) return self._holderify(r.operator_call(MesonOperator.BOOL, None))
@ -413,7 +412,7 @@ class InterpreterBase:
assert isinstance(node, mparser.TernaryNode) assert isinstance(node, mparser.TernaryNode)
result = self.evaluate_statement(node.condition) result = self.evaluate_statement(node.condition)
if result is None: if result is None:
raise MesonException('Cannot use a void statement as condition for ternary operator.') raise mesonlib.MesonException('Cannot use a void statement as condition for ternary operator.')
if isinstance(result, Disabler): if isinstance(result, Disabler):
return result return result
result.current_node = node result.current_node = node

@ -26,7 +26,7 @@ from . import environment
from . import mesonlib from . import mesonlib
from . import mintro from . import mintro
from . import mlog from . import mlog
from .ast import AstIDGenerator from .ast import AstIDGenerator, IntrospectionInterpreter
from .mesonlib import MachineChoice, OptionKey from .mesonlib import MachineChoice, OptionKey
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
@ -81,7 +81,7 @@ class Conf:
# Make sure that log entries in other parts of meson don't interfere with the JSON output # Make sure that log entries in other parts of meson don't interfere with the JSON output
with mlog.no_logging(): with mlog.no_logging():
self.source_dir = os.path.abspath(os.path.realpath(self.build_dir)) self.source_dir = os.path.abspath(os.path.realpath(self.build_dir))
intr = mintro.IntrospectionInterpreter(self.source_dir, '', 'ninja', visitors = [AstIDGenerator()]) intr = IntrospectionInterpreter(self.source_dir, '', 'ninja', visitors = [AstIDGenerator()])
intr.analyze() intr.analyze()
self.coredata = intr.coredata self.coredata = intr.coredata
self.default_values_only = True self.default_values_only = True

@ -8,7 +8,7 @@ import itertools
from pathlib import Path from pathlib import Path
from . import build, minstall from . import build, minstall
from .mesonlib import (MesonException, is_windows, setup_vsenv, OptionKey, from .mesonlib import (EnvironmentVariables, MesonException, is_windows, setup_vsenv, OptionKey,
get_wine_shortpath, MachineChoice) get_wine_shortpath, MachineChoice)
from . import mlog from . import mlog
@ -55,7 +55,7 @@ def reduce_winepath(env: T.Dict[str, str]) -> None:
mlog.log('Meson detected wine and has set WINEPATH accordingly') mlog.log('Meson detected wine and has set WINEPATH accordingly')
def get_env(b: build.Build, dump_fmt: T.Optional[str]) -> T.Tuple[T.Dict[str, str], T.Set[str]]: def get_env(b: build.Build, dump_fmt: T.Optional[str]) -> T.Tuple[T.Dict[str, str], T.Set[str]]:
extra_env = build.EnvironmentVariables() extra_env = EnvironmentVariables()
extra_env.set('MESON_DEVENV', ['1']) extra_env.set('MESON_DEVENV', ['1'])
extra_env.set('MESON_PROJECT_NAME', [b.project_name]) extra_env.set('MESON_PROJECT_NAME', [b.project_name])

@ -25,7 +25,7 @@ import sys
import typing as T import typing as T
import re import re
from . import build, coredata, environment from . import build, environment
from .backend.backends import InstallData from .backend.backends import InstallData
from .mesonlib import (MesonException, Popen_safe, RealPathAction, is_windows, from .mesonlib import (MesonException, Popen_safe, RealPathAction, is_windows,
is_aix, setup_vsenv, pickle_load, is_osx, OptionKey) is_aix, setup_vsenv, pickle_load, is_osx, OptionKey)
@ -40,10 +40,10 @@ except ImportError:
if T.TYPE_CHECKING: if T.TYPE_CHECKING:
from .backend.backends import ( from .backend.backends import (
ExecutableSerialisation, InstallDataBase, InstallEmptyDir, InstallDataBase, InstallEmptyDir,
InstallSymlinkData, TargetInstallData InstallSymlinkData, TargetInstallData
) )
from .mesonlib import FileMode, EnvironOrDict from .mesonlib import FileMode, EnvironOrDict, ExecutableSerialisation
try: try:
from typing import Protocol from typing import Protocol
@ -847,7 +847,7 @@ def run(opts: 'ArgumentType') -> int:
b = build.load(opts.wd) b = build.load(opts.wd)
need_vsenv = T.cast('bool', b.environment.coredata.get_option(OptionKey('vsenv'))) need_vsenv = T.cast('bool', b.environment.coredata.get_option(OptionKey('vsenv')))
setup_vsenv(need_vsenv) setup_vsenv(need_vsenv)
backend = T.cast('str', b.environment.coredata.get_option(coredata.OptionKey('backend'))) backend = T.cast('str', b.environment.coredata.get_option(OptionKey('backend')))
if not rebuild_all(opts.wd, backend): if not rebuild_all(opts.wd, backend):
sys.exit(-1) sys.exit(-1)
os.chdir(opts.wd) os.chdir(opts.wd)

@ -444,7 +444,7 @@ def get_test_list(testdata: T.List[backends.TestSerialisation]) -> T.List[T.Dict
else: else:
fname = t.fname fname = t.fname
to['cmd'] = fname + t.cmd_args to['cmd'] = fname + t.cmd_args
if isinstance(t.env, build.EnvironmentVariables): if isinstance(t.env, mesonlib.EnvironmentVariables):
to['env'] = t.env.get_env({}) to['env'] = t.env.get_env({})
else: else:
to['env'] = t.env to['env'] = t.env

@ -30,7 +30,6 @@ if T.TYPE_CHECKING:
from ..interpreterbase import TYPE_var, TYPE_kwargs from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..programs import OverrideProgram from ..programs import OverrideProgram
from ..wrap import WrapMode from ..wrap import WrapMode
from ..build import Executable
from ..dependencies import Dependency from ..dependencies import Dependency
class ModuleState: class ModuleState:
@ -87,16 +86,16 @@ class ModuleState:
def find_program(self, prog: T.Union[mesonlib.FileOrString, T.List[mesonlib.FileOrString]], def find_program(self, prog: T.Union[mesonlib.FileOrString, T.List[mesonlib.FileOrString]],
required: bool = True, required: bool = True,
version_func: T.Optional[T.Callable[[T.Union[ExternalProgram, Executable, OverrideProgram]], str]] = None, version_func: T.Optional[T.Callable[[T.Union[ExternalProgram, build.Executable, OverrideProgram]], str]] = None,
wanted: T.Optional[str] = None, silent: bool = False, wanted: T.Optional[str] = None, silent: bool = False,
for_machine: MachineChoice = MachineChoice.HOST) -> T.Union[ExternalProgram, Executable, OverrideProgram]: for_machine: MachineChoice = MachineChoice.HOST) -> T.Union[ExternalProgram, build.Executable, OverrideProgram]:
if not isinstance(prog, list): if not isinstance(prog, list):
prog = [prog] prog = [prog]
return self._interpreter.find_program_impl(prog, required=required, version_func=version_func, return self._interpreter.find_program_impl(prog, required=required, version_func=version_func,
wanted=wanted, silent=silent, for_machine=for_machine) wanted=wanted, silent=silent, for_machine=for_machine)
def find_tool(self, name: str, depname: str, varname: str, required: bool = True, def find_tool(self, name: str, depname: str, varname: str, required: bool = True,
wanted: T.Optional[str] = None) -> T.Union['Executable', ExternalProgram, 'OverrideProgram']: wanted: T.Optional[str] = None) -> T.Union['build.Executable', ExternalProgram, 'OverrideProgram']:
# Look in overrides in case it's built as subproject # Look in overrides in case it's built as subproject
progobj = self._interpreter.program_from_overrides([name], []) progobj = self._interpreter.program_from_overrides([name], [])
if progobj is not None: if progobj is not None:
@ -256,10 +255,10 @@ def is_module_library(fname: mesonlib.FileOrString) -> bool:
class ModuleReturnValue: class ModuleReturnValue:
def __init__(self, return_value: T.Optional['TYPE_var'], def __init__(self, return_value: T.Optional['TYPE_var'],
new_objects: T.Sequence[T.Union['TYPE_var', 'build.ExecutableSerialisation']]) -> None: new_objects: T.Sequence[T.Union['TYPE_var', 'mesonlib.ExecutableSerialisation']]) -> None:
self.return_value = return_value self.return_value = return_value
assert isinstance(new_objects, list) assert isinstance(new_objects, list)
self.new_objects: T.List[T.Union['TYPE_var', 'build.ExecutableSerialisation']] = new_objects self.new_objects: T.List[T.Union['TYPE_var', 'mesonlib.ExecutableSerialisation']] = new_objects
class GResourceTarget(build.CustomTarget): class GResourceTarget(build.CustomTarget):
pass pass

@ -39,6 +39,7 @@ if T.TYPE_CHECKING:
from ..build import BuildTarget, CustomTarget from ..build import BuildTarget, CustomTarget
from ..interpreter import Interpreter from ..interpreter import Interpreter
from ..interpreterbase import TYPE_var from ..interpreterbase import TYPE_var
from ..mesonlib import EnvironmentVariables
class Dependency(TypedDict): class Dependency(TypedDict):
@ -49,7 +50,7 @@ if T.TYPE_CHECKING:
configure_options: T.List[str] configure_options: T.List[str]
cross_configure_options: T.List[str] cross_configure_options: T.List[str]
verbose: bool verbose: bool
env: build.EnvironmentVariables env: EnvironmentVariables
depends: T.List[T.Union[BuildTarget, CustomTarget]] depends: T.List[T.Union[BuildTarget, CustomTarget]]
@ -62,7 +63,7 @@ class ExternalProject(NewExtensionModule):
configure_command: str, configure_command: str,
configure_options: T.List[str], configure_options: T.List[str],
cross_configure_options: T.List[str], cross_configure_options: T.List[str],
env: build.EnvironmentVariables, env: EnvironmentVariables,
verbose: bool, verbose: bool,
extra_depends: T.List[T.Union['BuildTarget', 'CustomTarget']]): extra_depends: T.List[T.Union['BuildTarget', 'CustomTarget']]):
super().__init__() super().__init__()

@ -272,7 +272,7 @@ class GnomeModule(ExtensionModule):
self.install_gtk_update_icon_cache = False self.install_gtk_update_icon_cache = False
self.install_update_desktop_database = False self.install_update_desktop_database = False
self.install_update_mime_database = False self.install_update_mime_database = False
self.devenv: T.Optional[build.EnvironmentVariables] = None self.devenv: T.Optional[mesonlib.EnvironmentVariables] = None
self.native_glib_version: T.Optional[str] = None self.native_glib_version: T.Optional[str] = None
self.methods.update({ self.methods.update({
'post_install': self.post_install, 'post_install': self.post_install,
@ -328,7 +328,7 @@ class GnomeModule(ExtensionModule):
@noPosargs @noPosargs
@FeatureNew('gnome.post_install', '0.57.0') @FeatureNew('gnome.post_install', '0.57.0')
def post_install(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: 'PostInstall') -> ModuleReturnValue: def post_install(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: 'PostInstall') -> ModuleReturnValue:
rv: T.List['build.ExecutableSerialisation'] = [] rv: T.List['mesonlib.ExecutableSerialisation'] = []
datadir_abs = os.path.join(state.environment.get_prefix(), state.environment.get_datadir()) datadir_abs = os.path.join(state.environment.get_prefix(), state.environment.get_datadir())
if kwargs['glib_compile_schemas'] and not self.install_glib_compile_schemas: if kwargs['glib_compile_schemas'] and not self.install_glib_compile_schemas:
self.install_glib_compile_schemas = True self.install_glib_compile_schemas = True
@ -769,7 +769,7 @@ class GnomeModule(ExtensionModule):
def _devenv_prepend(self, varname: str, value: str) -> None: def _devenv_prepend(self, varname: str, value: str) -> None:
if self.devenv is None: if self.devenv is None:
self.devenv = build.EnvironmentVariables() self.devenv = mesonlib.EnvironmentVariables()
self.devenv.prepend(varname, [value]) self.devenv.prepend(varname, [value])
def postconf_hook(self, b: build.Build) -> None: def postconf_hook(self, b: build.Build) -> None:
@ -1522,7 +1522,7 @@ class GnomeModule(ExtensionModule):
check_args = (targetname + '-check', check_cmd) check_args = (targetname + '-check', check_cmd)
check_workdir = os.path.join(state.environment.get_build_dir(), state.subdir) check_workdir = os.path.join(state.environment.get_build_dir(), state.subdir)
state.test(check_args, env=check_env, workdir=check_workdir, depends=[custom_target]) state.test(check_args, env=check_env, workdir=check_workdir, depends=[custom_target])
res: T.List[T.Union[build.Target, build.ExecutableSerialisation]] = [custom_target, alias_target] res: T.List[T.Union[build.Target, mesonlib.ExecutableSerialisation]] = [custom_target, alias_target]
if kwargs['install']: if kwargs['install']:
res.append(state.backend.get_executable_serialisation(command + t_args, tag='doc')) res.append(state.backend.get_executable_serialisation(command + t_args, tag='doc'))
return ModuleReturnValue(custom_target, res) return ModuleReturnValue(custom_target, res)

@ -20,7 +20,7 @@ import subprocess
from mesonbuild import mesonlib from mesonbuild import mesonlib
from mesonbuild import mlog, build from mesonbuild import mlog, build
from mesonbuild.coredata import MesonException from mesonbuild.mesonlib import MesonException
from . import ModuleReturnValue, ModuleInfo from . import ModuleReturnValue, ModuleInfo
from . import ExtensionModule from . import ExtensionModule
from ..dependencies import Dependency, InternalDependency from ..dependencies import Dependency, InternalDependency

@ -381,7 +381,7 @@ class PkgConfigModule(NewExtensionModule):
# Track already generated pkg-config files This is stored as a class # Track already generated pkg-config files This is stored as a class
# variable so that multiple `import()`s share metadata # variable so that multiple `import()`s share metadata
devenv: T.Optional[build.EnvironmentVariables] = None devenv: T.Optional[mesonlib.EnvironmentVariables] = None
_metadata: T.ClassVar[T.Dict[str, MetaData]] = {} _metadata: T.ClassVar[T.Dict[str, MetaData]] = {}
def __init__(self) -> None: def __init__(self) -> None:

@ -43,7 +43,7 @@ if T.TYPE_CHECKING:
from ..dependencies import Dependency from ..dependencies import Dependency
from ..interpreter import Interpreter from ..interpreter import Interpreter
from ..interpreter.kwargs import ExtractRequired from ..interpreter.kwargs import ExtractRequired
from ..interpreterbase.interpreterbase import TYPE_var, TYPE_kwargs from ..interpreterbase.baseobjects import TYPE_var, TYPE_kwargs
class PyInstallKw(TypedDict): class PyInstallKw(TypedDict):

@ -44,9 +44,9 @@ import xml.etree.ElementTree as et
from . import build from . import build
from . import environment from . import environment
from . import mlog from . import mlog
from .coredata import MesonVersionMismatchException, OptionKey, major_versions_differ from .coredata import MesonVersionMismatchException, major_versions_differ
from .coredata import version as coredata_version from .coredata import version as coredata_version
from .mesonlib import (MesonException, OrderedSet, RealPathAction, from .mesonlib import (MesonException, OptionKey, OrderedSet, RealPathAction,
get_wine_shortpath, join_args, split_args, setup_vsenv) get_wine_shortpath, join_args, split_args, setup_vsenv)
from .mintro import get_infodir, load_info_file from .mintro import get_infodir, load_info_file
from .programs import ExternalProgram from .programs import ExternalProgram

@ -103,13 +103,12 @@ class ExternalProgram(mesonlib.HoldableObject):
def get_version(self, interpreter: T.Optional['Interpreter'] = None) -> str: def get_version(self, interpreter: T.Optional['Interpreter'] = None) -> str:
if not self.cached_version: if not self.cached_version:
from . import build
raw_cmd = self.get_command() + ['--version'] raw_cmd = self.get_command() + ['--version']
if interpreter: if interpreter:
res = interpreter.run_command_impl(interpreter.current_node, (self, ['--version']), res = interpreter.run_command_impl(interpreter.current_node, (self, ['--version']),
{'capture': True, {'capture': True,
'check': True, 'check': True,
'env': build.EnvironmentVariables()}, 'env': mesonlib.EnvironmentVariables()},
True) True)
o, e = res.stdout, res.stderr o, e = res.stdout, res.stderr
else: else:

@ -20,7 +20,7 @@ from __future__ import annotations
import fcntl import fcntl
import typing as T import typing as T
from .universal import MesonException from .core import MesonException
from .platform import BuildDirLock as BuildDirLockBase from .platform import BuildDirLock as BuildDirLockBase
__all__ = ['BuildDirLock'] __all__ = ['BuildDirLock']

@ -8,7 +8,8 @@ import shutil
import tempfile import tempfile
from .. import mlog from .. import mlog
from .universal import MesonException, is_windows, windows_detect_native_arch from .core import MesonException
from .universal import is_windows, windows_detect_native_arch
__all__ = [ __all__ = [

@ -20,7 +20,7 @@ from __future__ import annotations
import msvcrt import msvcrt
import typing as T import typing as T
from .universal import MesonException from .core import MesonException
from .platform import BuildDirLock as BuildDirLockBase from .platform import BuildDirLock as BuildDirLockBase
__all__ = ['BuildDirLock'] __all__ = ['BuildDirLock']

Loading…
Cancel
Save