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_column_numbers = True
ignore_missing_imports = True
implicit_reexport = False
follow_imports = silent
warn_redundant_casts = True

@ -202,7 +202,7 @@ class TestSerialisation:
needs_exe_wrapper: bool
is_parallel: bool
cmd_args: T.List[str]
env: build.EnvironmentVariables
env: mesonlib.EnvironmentVariables
should_fail: bool
timeout: T.Optional[int]
workdir: T.Optional[str]
@ -512,7 +512,7 @@ class Backend:
extra_bdeps: T.Optional[T.List[build.BuildTarget]] = None,
capture: 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,
verbose: bool = False,
installdir_map: T.Optional[T.Dict[str, str]] = None) -> 'ExecutableSerialisation':
@ -585,7 +585,7 @@ class Backend:
capture: T.Optional[bool] = None,
feed: T.Optional[bool] = None,
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]:
'''
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]
return inputs, outputs, cmd
def get_run_target_env(self, target: build.RunTarget) -> build.EnvironmentVariables:
env = target.env if target.env else build.EnvironmentVariables()
def get_run_target_env(self, target: build.RunTarget) -> mesonlib.EnvironmentVariables:
env = target.env if target.env else mesonlib.EnvironmentVariables()
if target.default_env:
introspect_cmd = join_args(self.environment.get_build_command() + ['introspect'])
env.set('MESON_SOURCE_ROOT', [self.environment.get_source_dir()])
@ -1959,8 +1959,8 @@ class Backend:
return []
def get_devenv(self) -> build.EnvironmentVariables:
env = build.EnvironmentVariables()
def get_devenv(self) -> mesonlib.EnvironmentVariables:
env = mesonlib.EnvironmentVariables()
extra_paths = set()
library_paths = set()
build_machine = self.environment.machines[MachineChoice.BUILD]

@ -39,7 +39,7 @@ from .mesonlib import (
MesonBugException, EnvironmentVariables, pickle_load,
)
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
)
from .interpreterbase import FeatureNew, FeatureDeprecated
@ -47,12 +47,13 @@ from .interpreterbase import FeatureNew, FeatureDeprecated
if T.TYPE_CHECKING:
from typing_extensions import Literal
from ._typing import ImmutableListProtocol
from .backend.backends import Backend, ExecutableSerialisation
from .backend.backends import Backend
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 .linkers.linkers import StaticLinker
from .mesonlib import FileMode, FileOrString
from .mesonlib import ExecutableSerialisation, FileMode, FileOrString
from .modules import ModuleState
from .mparser import BaseNode
from .wrap import WrapMode
@ -434,7 +435,7 @@ class ExtractedObjects(HoldableObject):
sources.append(s)
# 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']]:
sources_ = self.get_sources(sources, generated_sources)
@ -1494,14 +1495,14 @@ You probably should put it in link_with instead.''')
if not pchlist:
return
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.')
elif len(pchlist) == 2:
if environment.is_header(pchlist[0]):
if not environment.is_source(pchlist[1]):
if is_header(pchlist[0]):
if not is_source(pchlist[1]):
raise InvalidArguments('PCH definition must contain one header and at most one source.')
elif environment.is_source(pchlist[0]):
if not environment.is_header(pchlist[1]):
elif is_source(pchlist[0]):
if not is_header(pchlist[1]):
raise InvalidArguments('PCH definition must contain one header and at most one source.')
pchlist = [pchlist[1], pchlist[0]]
else:

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

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

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

@ -24,7 +24,8 @@ from .factory import factory_methods
if T.TYPE_CHECKING:
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})

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

@ -27,7 +27,8 @@ from .pkgconfig import PkgConfigDependency
if T.TYPE_CHECKING:
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})

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

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

@ -23,7 +23,7 @@ from .. import compilers
from .. import envconfig
from ..wrap import wrap, WrapMode
from .. import mesonlib
from ..mesonlib import (MesonBugException, MesonException, HoldableObject,
from ..mesonlib import (EnvironmentVariables, ExecutableSerialisation, MesonBugException, MesonException, HoldableObject,
FileMode, MachineChoice, OptionKey, listify,
extract_as_list, has_path_sep, PerMachine)
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 ObjectHolder, ContextManagerObject
from ..modules import ExtensionModule, ModuleObject, MutableModuleObject, NewExtensionModule, NotFoundExtensionModule
from ..backend.backends import ExecutableSerialisation
from . import interpreterobjects as OBJ
from . import compiler as compilerOBJ
@ -458,7 +457,7 @@ class Interpreter(InterpreterBase, HoldableObject):
build.SymlinkData: OBJ.SymlinkDataHolder,
build.InstallDir: OBJ.InstallDirHolder,
build.IncludeDirs: OBJ.IncludeDirsHolder,
build.EnvironmentVariables: OBJ.EnvironmentVariablesHolder,
mesonlib.EnvironmentVariables: OBJ.EnvironmentVariablesHolder,
build.StructuredSources: OBJ.StructuredSourcesHolder,
compilers.RunResult: compilerOBJ.TryRunResultHolder,
dependencies.ExternalLibrary: OBJ.ExternalLibraryHolder,
@ -2166,10 +2165,10 @@ class Interpreter(InterpreterBase, HoldableObject):
kwargs: 'kwtypes.FuncTest') -> None:
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')
if envlist is None:
return build.EnvironmentVariables()
return EnvironmentVariables()
msg = ENV_KW.validator(envlist)
if msg:
raise InvalidArguments(f'"env": {msg}')
@ -2687,7 +2686,7 @@ class Interpreter(InterpreterBase, HoldableObject):
mlog.log('Configuring', mlog.bold(output), 'with command')
cmd, *args = _cmd
res = self.run_command_impl(node, (cmd, args),
{'capture': True, 'check': True, 'env': build.EnvironmentVariables()},
{'capture': True, 'check': True, 'env': EnvironmentVariables()},
True)
if kwargs['capture']:
dst_tmp = ofile_abs + '~'
@ -2967,7 +2966,7 @@ class Interpreter(InterpreterBase, HoldableObject):
@typed_pos_args('environment', optargs=[(str, list, dict)])
@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']]],
kwargs: 'TYPE_kwargs') -> build.EnvironmentVariables:
kwargs: 'TYPE_kwargs') -> EnvironmentVariables:
init = args[0]
if init is not None:
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)):
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 build.EnvironmentVariables()
return EnvironmentVariables()
@typed_pos_args('join_paths', varargs=str, min_varargs=1)
@noKwargs

@ -203,7 +203,7 @@ class RunProcess(MesonInterpreterObject):
def __init__(self,
cmd: ExternalProgram,
args: T.List[str],
env: build.EnvironmentVariables,
env: mesonlib.EnvironmentVariables,
source_dir: str,
build_dir: str,
subdir: str,
@ -224,7 +224,7 @@ class RunProcess(MesonInterpreterObject):
def run_command(self,
cmd: ExternalProgram,
args: T.List[str],
env: build.EnvironmentVariables,
env: mesonlib.EnvironmentVariables,
source_dir: str,
build_dir: str,
subdir: str,
@ -280,9 +280,9 @@ class RunProcess(MesonInterpreterObject):
def stderr_method(self, args: T.List[TYPE_var], kwargs: TYPE_kwargs) -> str:
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)
self.methods.update({'set': self.set_method,
'append': self.append_method,
@ -711,7 +711,7 @@ class Test(MesonInterpreterObject):
depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]],
is_parallel: bool,
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,
priority: int, verbose: bool):
super().__init__()

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

@ -21,14 +21,13 @@ from .primitives import MesonVersionString
from .type_checking import NATIVE_KW, NoneType
if T.TYPE_CHECKING:
from typing_extensions import Literal
from ..backend.backends import ExecutableSerialisation
from typing_extensions import Literal, TypedDict
from ..compilers import Compiler
from ..interpreterbase import TYPE_kwargs, TYPE_var
from ..mesonlib import ExecutableSerialisation
from .interpreter import Interpreter
from typing_extensions import TypedDict
class FuncOverrideDependency(TypedDict):
native: mesonlib.MachineChoice
@ -456,15 +455,15 @@ class MesonMain(MesonInterpreterObject):
@FeatureNew('add_devenv', '0.58.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))
def add_devenv_method(self, args: T.Tuple[T.Union[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, mesonlib.EnvironmentVariables]],
kwargs: 'AddDevenvKW') -> None:
env = args[0]
msg = ENV_KW.validator(env)
if msg:
raise build.InvalidArguments(f'"add_devenv": {msg}')
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)
@noPosargs

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

@ -36,7 +36,6 @@ from .exceptions import (
InterpreterException,
InvalidArguments,
InvalidCode,
MesonException,
SubdirDoneRequest,
)
@ -319,12 +318,12 @@ class InterpreterBase:
def evaluate_comparison(self, node: mparser.ComparisonNode) -> InterpreterObject:
val1 = self.evaluate_statement(node.left)
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):
return val1
val2 = self.evaluate_statement(node.right)
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):
return val2
@ -350,7 +349,7 @@ class InterpreterBase:
def evaluate_andstatement(self, cur: mparser.AndNode) -> InterpreterObject:
l = self.evaluate_statement(cur.left)
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):
return l
l_bool = l.operator_call(MesonOperator.BOOL, None)
@ -358,7 +357,7 @@ class InterpreterBase:
return self._holderify(l_bool)
r = self.evaluate_statement(cur.right)
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):
return r
return self._holderify(r.operator_call(MesonOperator.BOOL, None))
@ -366,7 +365,7 @@ class InterpreterBase:
def evaluate_orstatement(self, cur: mparser.OrNode) -> InterpreterObject:
l = self.evaluate_statement(cur.left)
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):
return l
l_bool = l.operator_call(MesonOperator.BOOL, None)
@ -374,7 +373,7 @@ class InterpreterBase:
return self._holderify(l_bool)
r = self.evaluate_statement(cur.right)
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):
return r
return self._holderify(r.operator_call(MesonOperator.BOOL, None))
@ -413,7 +412,7 @@ class InterpreterBase:
assert isinstance(node, mparser.TernaryNode)
result = self.evaluate_statement(node.condition)
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):
return result
result.current_node = node

@ -26,7 +26,7 @@ from . import environment
from . import mesonlib
from . import mintro
from . import mlog
from .ast import AstIDGenerator
from .ast import AstIDGenerator, IntrospectionInterpreter
from .mesonlib import MachineChoice, OptionKey
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
with mlog.no_logging():
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()
self.coredata = intr.coredata
self.default_values_only = True

@ -8,7 +8,7 @@ import itertools
from pathlib import Path
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)
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')
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_PROJECT_NAME', [b.project_name])

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

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

@ -30,7 +30,6 @@ if T.TYPE_CHECKING:
from ..interpreterbase import TYPE_var, TYPE_kwargs
from ..programs import OverrideProgram
from ..wrap import WrapMode
from ..build import Executable
from ..dependencies import Dependency
class ModuleState:
@ -87,16 +86,16 @@ class ModuleState:
def find_program(self, prog: T.Union[mesonlib.FileOrString, T.List[mesonlib.FileOrString]],
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,
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):
prog = [prog]
return self._interpreter.find_program_impl(prog, required=required, version_func=version_func,
wanted=wanted, silent=silent, for_machine=for_machine)
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
progobj = self._interpreter.program_from_overrides([name], [])
if progobj is not None:
@ -256,10 +255,10 @@ def is_module_library(fname: mesonlib.FileOrString) -> bool:
class ModuleReturnValue:
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
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):
pass

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

@ -272,7 +272,7 @@ class GnomeModule(ExtensionModule):
self.install_gtk_update_icon_cache = False
self.install_update_desktop_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.methods.update({
'post_install': self.post_install,
@ -328,7 +328,7 @@ class GnomeModule(ExtensionModule):
@noPosargs
@FeatureNew('gnome.post_install', '0.57.0')
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())
if kwargs['glib_compile_schemas'] and not self.install_glib_compile_schemas:
self.install_glib_compile_schemas = True
@ -769,7 +769,7 @@ class GnomeModule(ExtensionModule):
def _devenv_prepend(self, varname: str, value: str) -> None:
if self.devenv is None:
self.devenv = build.EnvironmentVariables()
self.devenv = mesonlib.EnvironmentVariables()
self.devenv.prepend(varname, [value])
def postconf_hook(self, b: build.Build) -> None:
@ -1522,7 +1522,7 @@ class GnomeModule(ExtensionModule):
check_args = (targetname + '-check', check_cmd)
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])
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']:
res.append(state.backend.get_executable_serialisation(command + t_args, tag='doc'))
return ModuleReturnValue(custom_target, res)

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

@ -381,7 +381,7 @@ class PkgConfigModule(NewExtensionModule):
# Track already generated pkg-config files This is stored as a class
# 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]] = {}
def __init__(self) -> None:

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

@ -44,9 +44,9 @@ import xml.etree.ElementTree as et
from . import build
from . import environment
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 .mesonlib import (MesonException, OrderedSet, RealPathAction,
from .mesonlib import (MesonException, OptionKey, OrderedSet, RealPathAction,
get_wine_shortpath, join_args, split_args, setup_vsenv)
from .mintro import get_infodir, load_info_file
from .programs import ExternalProgram

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

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

@ -8,7 +8,8 @@ import shutil
import tempfile
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__ = [

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

Loading…
Cancel
Save