summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-10-02 09:45:52 -0700
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-10-14 19:11:53 +0300
commit15d3909695520850b6b587544a01971b6d34be43 (patch)
treea829e50f092d60ca48045f844fdb8e1f1c17cf24
parenta563ebd2da758001c89c8db3a0a26c16740cc279 (diff)
downloadmeson-15d3909695520850b6b587544a01971b6d34be43.tar.gz
Make use of build TypeAliases
There are a lot of spelled out unions for these types, lets reduce that number
-rw-r--r--mesonbuild/backend/backends.py32
-rw-r--r--mesonbuild/backend/vs2010backend.py6
-rw-r--r--mesonbuild/backend/xcodebackend.py8
-rw-r--r--mesonbuild/build.py22
-rw-r--r--mesonbuild/interpreter/compiler.py4
-rw-r--r--mesonbuild/interpreter/interpreter.py10
-rw-r--r--mesonbuild/interpreter/kwargs.py18
-rw-r--r--mesonbuild/interpreter/mesonmain.py2
-rw-r--r--mesonbuild/interpreter/type_checking.py12
-rw-r--r--mesonbuild/mintro.py2
-rw-r--r--mesonbuild/modules/_qt.py12
-rw-r--r--mesonbuild/modules/gnome.py18
-rw-r--r--mesonbuild/modules/i18n.py17
13 files changed, 78 insertions, 85 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index dabc4c10d..a5995e6b1 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -46,7 +46,7 @@ if T.TYPE_CHECKING:
from typing_extensions import TypedDict, NotRequired
- _ALL_SOURCES_TYPE = T.List[T.Union[File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
+ _ALL_SOURCES_TYPE = T.List[T.Union[File, build.GeneratedTypes]]
class TargetIntrospectionData(TypedDict):
@@ -295,7 +295,7 @@ class Backend:
def generate(self, capture: bool = False, vslite_ctx: T.Optional[T.Dict] = None) -> T.Optional[T.Dict]:
raise RuntimeError(f'generate is not implemented in {type(self).__name__}')
- def get_target_filename(self, t: T.Union[build.Target, build.CustomTargetIndex], *, warn_multi_output: bool = True) -> str:
+ def get_target_filename(self, t: build.AnyTargetType, *, warn_multi_output: bool = True) -> str:
if isinstance(t, build.CustomTarget):
if warn_multi_output and len(t.get_outputs()) != 1:
mlog.warning(f'custom_target {t.name!r} has more than one output! '
@@ -308,7 +308,7 @@ class Backend:
filename = t.get_filename()
return os.path.join(self.get_target_dir(t), filename)
- def get_target_filename_abs(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
+ def get_target_filename_abs(self, target: build.AnyTargetType) -> str:
return os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))
def get_target_debug_filename(self, target: build.BuildTarget) -> T.Optional[str]:
@@ -343,7 +343,7 @@ class Backend:
curdir = '.'
return compiler.get_include_args(curdir, False)
- def get_target_filename_for_linking(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> T.Optional[str]:
+ def get_target_filename_for_linking(self, target: build.AnyTargetType) -> T.Optional[str]:
# On some platforms (msvc for instance), the file that is used for
# dynamic linking is not the same as the dynamic library itself. This
# file is called an import library, and we want to link against that.
@@ -368,7 +368,7 @@ class Backend:
raise AssertionError(f'BUG: Tried to link to {target!r} which is not linkable')
@lru_cache(maxsize=None)
- def get_target_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
+ def get_target_dir(self, target: build.AnyTargetType) -> str:
if isinstance(target, build.RunTarget):
# this produces no output, only a dummy top-level name
dirname = ''
@@ -394,16 +394,16 @@ class Backend:
return os.path.join(self.build_to_src, target_dir)
return self.build_to_src
- def get_target_private_dir(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]) -> str:
+ def get_target_private_dir(self, target: build.BuildTargetTypes) -> str:
return os.path.join(self.get_target_filename(target, warn_multi_output=False) + '.p')
- def get_target_private_dir_abs(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]) -> str:
+ def get_target_private_dir_abs(self, target: build.BuildTargetTypes) -> str:
return os.path.join(self.environment.get_build_dir(), self.get_target_private_dir(target))
@lru_cache(maxsize=None)
def get_target_generated_dir(
- self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex],
- gensrc: T.Union[build.CustomTarget, build.CustomTargetIndex, build.GeneratedList],
+ self, target: build.BuildTargetTypes,
+ gensrc: build.GeneratedTypes,
src: str) -> str:
"""
Takes a BuildTarget, a generator source (CustomTarget or GeneratedList),
@@ -417,7 +417,7 @@ class Backend:
# target that the GeneratedList is used in
return os.path.join(self.get_target_private_dir(target), src)
- def get_unity_source_file(self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex],
+ def get_unity_source_file(self, target: build.BuildTargetTypes,
suffix: str, number: int) -> mesonlib.File:
# There is a potential conflict here, but it is unlikely that
# anyone both enables unity builds and has a file called foo-unity.cpp.
@@ -1117,8 +1117,8 @@ class Backend:
return results
def determine_windows_extra_paths(
- self, target: T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, programs.ExternalProgram, mesonlib.File, str],
- extra_bdeps: T.Sequence[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]) -> T.List[str]:
+ self, target: T.Union[build.BuildTargetTypes, programs.ExternalProgram, mesonlib.File, str],
+ extra_bdeps: T.Sequence[build.BuildTargetTypes]) -> T.List[str]:
"""On Windows there is no such thing as an rpath.
We must determine all locations of DLLs that this exe
@@ -1184,7 +1184,7 @@ class Backend:
exe_wrapper = self.environment.get_exe_wrapper()
machine = self.environment.machines[exe.for_machine]
if machine.is_windows() or machine.is_cygwin():
- extra_bdeps: T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]] = []
+ extra_bdeps: T.List[build.BuildTargetTypes] = []
if isinstance(exe, build.CustomTarget):
extra_bdeps = list(exe.get_transitive_build_target_deps())
extra_bdeps.extend(t.depends)
@@ -1252,7 +1252,7 @@ class Backend:
def write_test_serialisation(self, tests: T.List['Test'], datafile: T.BinaryIO) -> None:
pickle.dump(self.create_test_serialisation(tests), datafile)
- def construct_target_rel_paths(self, t: T.Union[build.Target, build.CustomTargetIndex], workdir: T.Optional[str]) -> T.List[str]:
+ def construct_target_rel_paths(self, t: build.AnyTargetType, workdir: T.Optional[str]) -> T.List[str]:
target_dir = self.get_target_dir(t)
# ensure that test executables can be run when passed as arguments
if isinstance(t, build.Executable) and workdir is None:
@@ -1452,7 +1452,7 @@ class Backend:
deps.append(os.path.join(self.build_to_src, target.subdir, i))
return deps
- def get_custom_target_output_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
+ def get_custom_target_output_dir(self, target: build.AnyTargetType) -> str:
# The XCode backend is special. A target foo/bar does
# not go to ${BUILDDIR}/foo/bar but instead to
# ${BUILDDIR}/${BUILDTYPE}/foo/bar.
@@ -2025,7 +2025,7 @@ class Backend:
compiler: 'Compiler',
sources: _ALL_SOURCES_TYPE,
output_templ: str,
- depends: T.Optional[T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]] = None,
+ depends: T.Optional[T.List[build.BuildTargetTypes]] = None,
) -> build.GeneratedList:
'''
Some backends don't support custom compilers. This is a convenience
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index fde3874b5..adcb2543e 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -153,7 +153,7 @@ class Vs2010Backend(backends.Backend):
def get_target_private_dir(self, target):
return os.path.join(self.get_target_dir(target), target.get_id())
- def generate_genlist_for_target(self, genlist: T.Union[build.GeneratedList, build.CustomTarget, build.CustomTargetIndex], target: build.BuildTarget, parent_node: ET.Element, generator_output_files: T.List[str], custom_target_include_dirs: T.List[str], custom_target_output_files: T.List[str]) -> None:
+ def generate_genlist_for_target(self, genlist: build.GeneratedTypes, target: build.BuildTarget, parent_node: ET.Element, generator_output_files: T.List[str], custom_target_include_dirs: T.List[str], custom_target_output_files: T.List[str]) -> None:
if isinstance(genlist, build.GeneratedList):
for x in genlist.depends:
self.generate_genlist_for_target(x, target, parent_node, [], [], [])
@@ -330,7 +330,7 @@ class Vs2010Backend(backends.Backend):
result[o.target.get_id()] = o.target
return result.items()
- def get_target_deps(self, t: T.Dict[T.Any, T.Union[build.Target, build.CustomTargetIndex]], recursive=False):
+ def get_target_deps(self, t: T.Dict[T.Any, build.AnyTargetType], recursive=False):
all_deps: T.Dict[str, build.Target] = {}
for target in t.values():
if isinstance(target, build.CustomTargetIndex):
@@ -1577,7 +1577,7 @@ class Vs2010Backend(backends.Backend):
# once a build/compile has generated these sources.
#
# This modifies the paths in 'gen_files' in place, as opposed to returning a new list of modified paths.
- def relocate_generated_file_paths_to_concrete_build_dir(self, gen_files: T.List[str], target: T.Union[build.Target, build.CustomTargetIndex]) -> None:
+ def relocate_generated_file_paths_to_concrete_build_dir(self, gen_files: T.List[str], target: build.AnyTargetType) -> None:
(_, build_dir_tail) = os.path.split(self.src_to_build)
meson_build_dir_for_buildtype = build_dir_tail[:-2] + coredata.get_genvs_default_buildtype_list()[0] # Get the first buildtype suffixed dir (i.e. '[builddir]_debug') from '[builddir]_vs'
# Relative path from this .vcxproj to the directory containing the set of '..._[debug/debugoptimized/release]' setup meson build dirs.
diff --git a/mesonbuild/backend/xcodebackend.py b/mesonbuild/backend/xcodebackend.py
index a0476ca85..ac2126025 100644
--- a/mesonbuild/backend/xcodebackend.py
+++ b/mesonbuild/backend/xcodebackend.py
@@ -280,12 +280,12 @@ class XCodeBackend(backends.Backend):
return str(uuid.uuid4()).upper().replace('-', '')[:24]
@functools.lru_cache(maxsize=None)
- def get_target_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
+ def get_target_dir(self, target: build.AnyTargetType) -> str:
dirname = os.path.join(target.get_subdir(), T.cast('str', self.environment.coredata.optstore.get_value_for(OptionKey('buildtype'))))
#os.makedirs(os.path.join(self.environment.get_build_dir(), dirname), exist_ok=True)
return dirname
- def get_custom_target_output_dir(self, target: T.Union[build.Target, build.CustomTargetIndex]) -> str:
+ def get_custom_target_output_dir(self, target: build.AnyTargetType) -> str:
dirname = target.get_subdir()
os.makedirs(os.path.join(self.environment.get_build_dir(), dirname), exist_ok=True)
return dirname
@@ -525,7 +525,7 @@ class XCodeBackend(backends.Backend):
generator_id += 1
def gen_single_target_map(self, genlist: build.GeneratedList, tname: str,
- t: T.Union[build.BuildTarget, build.CustomTarget], generator_id: int) -> None:
+ t: build.AnyTargetType, generator_id: int) -> None:
k = (tname, generator_id)
assert k not in self.shell_targets
self.shell_targets[k] = self.gen_id()
@@ -1439,7 +1439,7 @@ class XCodeBackend(backends.Backend):
self.generate_single_generator_phase(tname, t, genlist, generator_id, objects_dict)
generator_id += 1
- def generate_single_generator_phase(self, tname: str, t: T.Union[build.BuildTarget, build.CustomTarget],
+ def generate_single_generator_phase(self, tname: str, t: build.AnyTargetType,
genlist: build.GeneratedList, generator_id: int, objects_dict: PbxDict) -> None:
# TODO: this should be rewritten to use the meson wrapper, like the other generators do
# Currently it doesn't handle a host binary that requires an exe wrapper correctly.
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 185c1ad42..832e07711 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -494,7 +494,7 @@ class StructuredSources(HoldableObject):
represent the required filesystem layout.
"""
- sources: T.DefaultDict[str, T.List[T.Union[File, CustomTarget, CustomTargetIndex, GeneratedList]]] = field(
+ sources: T.DefaultDict[str, T.List[T.Union[File, GeneratedTypes]]] = field(
default_factory=lambda: defaultdict(list))
def __add__(self, other: StructuredSources) -> StructuredSources:
@@ -506,14 +506,14 @@ class StructuredSources(HoldableObject):
def __bool__(self) -> bool:
return bool(self.sources)
- def first_file(self) -> T.Union[File, CustomTarget, CustomTargetIndex, GeneratedList]:
+ def first_file(self) -> T.Union[File, GeneratedTypes]:
"""Get the first source in the root
:return: The first source in the root
"""
return self.sources[''][0]
- def as_list(self) -> T.List[T.Union[File, CustomTarget, CustomTargetIndex, GeneratedList]]:
+ def as_list(self) -> T.List[T.Union[File, GeneratedTypes]]:
return list(itertools.chain.from_iterable(self.sources.values()))
def needs_copy(self) -> bool:
@@ -724,7 +724,7 @@ class BuildTarget(Target):
self.link_targets: T.List[LibTypes] = []
self.link_whole_targets: T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex]] = []
self.depend_files: T.List[File] = []
- self.link_depends: T.List[T.Union[File, CustomTarget, CustomTargetIndex, BuildTarget]] = []
+ self.link_depends: T.List[T.Union[File, BuildTargetTypes]] = []
self.added_deps = set()
self.name_prefix_set = False
self.name_suffix_set = False
@@ -1028,7 +1028,7 @@ class BuildTarget(Target):
langs = ', '.join(self.compilers.keys())
raise InvalidArguments(f'Cannot mix those languages into a target: {langs}')
- def process_link_depends(self, sources: T.Iterable[T.Union[str, File, CustomTarget, CustomTargetIndex, BuildTarget]]) -> None:
+ def process_link_depends(self, sources: T.Iterable[T.Union[str, File, BuildTargetTypes]]) -> None:
"""Process the link_depends keyword argument.
This is designed to handle strings, Files, and the output of Custom
@@ -1989,12 +1989,12 @@ class Generator(HoldableObject):
*,
depfile: T.Optional[str] = None,
capture: bool = False,
- depends: T.Optional[T.List[T.Union[BuildTarget, 'CustomTarget', 'CustomTargetIndex']]] = None,
+ depends: T.Optional[T.List[BuildTargetTypes]] = None,
name: str = 'Generator'):
self.exe = exe
self.depfile = depfile
self.capture = capture
- self.depends: T.List[T.Union[BuildTarget, 'CustomTarget', 'CustomTargetIndex']] = depends or []
+ self.depends: T.List[BuildTargetTypes] = depends or []
self.arglist = arguments
self.outputs = output
self.name = name
@@ -2024,7 +2024,7 @@ class Generator(HoldableObject):
basename = os.path.splitext(plainname)[0]
return [x.replace('@BASENAME@', basename).replace('@PLAINNAME@', plainname) for x in self.arglist]
- def process_files(self, files: T.Iterable[T.Union[str, File, 'CustomTarget', 'CustomTargetIndex', 'GeneratedList']],
+ def process_files(self, files: T.Iterable[T.Union[str, File, GeneratedTypes]],
state: T.Union['Interpreter', 'ModuleState'],
preserve_path_from: T.Optional[str] = None,
extra_args: T.Optional[T.List[str]] = None,
@@ -3078,7 +3078,7 @@ class CompileTarget(BuildTarget):
compile_args: T.List[str],
include_directories: T.List[IncludeDirs],
dependencies: T.List[dependencies.Dependency],
- depends: T.List[T.Union[BuildTarget, CustomTarget, CustomTargetIndex]]):
+ depends: T.List[BuildTargetTypes]):
compilers = {compiler.get_language(): compiler}
kwargs = {
'build_by_default': False,
@@ -3123,7 +3123,7 @@ class RunTarget(Target, CommandBase):
def __init__(self, name: str,
command: T.Sequence[T.Union[str, File, BuildTargetTypes, programs.ExternalProgram]],
- dependencies: T.Sequence[T.Union[Target, CustomTargetIndex]],
+ dependencies: T.Sequence[AnyTargetType],
subdir: str,
subproject: str,
environment: environment.Environment,
@@ -3142,7 +3142,7 @@ class RunTarget(Target, CommandBase):
repr_str = "<{0} {1}: {2}>"
return repr_str.format(self.__class__.__name__, self.get_id(), self.command[0])
- def get_dependencies(self) -> T.List[T.Union[BuildTarget, CustomTarget, CustomTargetIndex]]:
+ def get_dependencies(self) -> T.List[BuildTargetTypes]:
return self.dependencies
def get_generated_sources(self) -> T.List[GeneratedTypes]:
diff --git a/mesonbuild/interpreter/compiler.py b/mesonbuild/interpreter/compiler.py
index 57e949961..99204be10 100644
--- a/mesonbuild/interpreter/compiler.py
+++ b/mesonbuild/interpreter/compiler.py
@@ -96,7 +96,7 @@ if T.TYPE_CHECKING:
compile_args: T.List[str]
include_directories: T.List[build.IncludeDirs]
dependencies: T.List[dependencies.Dependency]
- depends: T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]
+ depends: T.List[build.BuildTargetTypes]
class _TestMode(enum.Enum):
@@ -148,7 +148,7 @@ _DEPENDENCIES_KW: KwargInfo[T.List['dependencies.Dependency']] = KwargInfo(
listify=True,
default=[],
)
-_DEPENDS_KW: KwargInfo[T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]] = KwargInfo(
+_DEPENDS_KW: KwargInfo[T.List[build.BuildTargetTypes]] = KwargInfo(
'depends',
ContainerTypeInfo(list, (build.BuildTarget, build.CustomTarget, build.CustomTargetIndex)),
listify=True,
diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py
index 73be40eec..b28cc8a76 100644
--- a/mesonbuild/interpreter/interpreter.py
+++ b/mesonbuild/interpreter/interpreter.py
@@ -121,13 +121,11 @@ if T.TYPE_CHECKING:
from .type_checking import SourcesVarargsType
# Input source types passed to Targets
- SourceInputs = T.Union[mesonlib.File, build.GeneratedList, build.BuildTarget, build.BothLibraries,
- build.CustomTargetIndex, build.CustomTarget, build.GeneratedList,
- build.ExtractedObjects, str]
+ SourceInputs = T.Union[mesonlib.FileOrString, build.GeneratedTypes, build.BuildTarget,
+ build.BothLibraries, build.ExtractedObjects]
# Input source types passed to the build.Target classes
- SourceOutputs = T.Union[mesonlib.File, build.GeneratedList,
- build.BuildTarget, build.CustomTargetIndex, build.CustomTarget,
- build.ExtractedObjects, build.GeneratedList, build.StructuredSources]
+ SourceOutputs = T.Union[mesonlib.File, build.GeneratedTypes, build.BuildTarget,
+ build.ExtractedObjects, build.StructuredSources]
BuildTargetSource = T.Union[mesonlib.FileOrString, build.GeneratedTypes, build.StructuredSources]
diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py
index f05dd4e12..43e3cb30b 100644
--- a/mesonbuild/interpreter/kwargs.py
+++ b/mesonbuild/interpreter/kwargs.py
@@ -182,16 +182,15 @@ class CustomTarget(TypedDict):
build_always_stale: T.Optional[bool]
build_by_default: T.Optional[bool]
capture: bool
- command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
- build.CustomTargetIndex, ExternalProgram, File]]
+ command: T.List[T.Union[str, build.BuildTargetTypes, ExternalProgram, File]]
console: bool
depend_files: T.List[FileOrString]
depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]]
depfile: T.Optional[str]
env: EnvironmentVariables
feed: bool
- input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
- build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]]
+ input: T.List[T.Union[str, build.BuildTarget, build.GeneratedTypes,
+ build.ExtractedObjects, ExternalProgram, File]]
install: bool
install_dir: T.List[T.Union[str, T.Literal[False]]]
install_mode: FileMode
@@ -282,11 +281,10 @@ class ConfigurationDataSet(TypedDict):
class VcsTag(TypedDict):
- command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
- build.CustomTargetIndex, ExternalProgram, File]]
+ command: T.List[T.Union[str, build.GeneratedTypes, ExternalProgram, File]]
fallback: T.Optional[str]
- input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
- build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]]
+ input: T.List[T.Union[str, build.BuildTarget, build.GeneratedTypes,
+ build.ExtractedObjects, ExternalProgram, File]]
output: T.List[str]
replace_string: str
install: bool
@@ -343,7 +341,7 @@ class _BaseBuildTarget(TypedDict):
install_mode: FileMode
install_rpath: str
implicit_include_directories: bool
- link_depends: T.List[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex, build.BuildTarget]]
+ link_depends: T.List[T.Union[str, File, build.GeneratedTypes]]
link_language: T.Optional[str]
name_prefix: T.Optional[str]
name_suffix: T.Optional[str]
@@ -469,7 +467,7 @@ class Jar(_BaseBuildTarget):
main_class: str
java_resources: T.Optional[build.StructuredSources]
- sources: T.Union[str, File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList, build.ExtractedObjects, build.BuildTarget]
+ sources: T.Union[str, File, build.GeneratedTypes, build.ExtractedObjects, build.BuildTarget]
java_args: T.List[str]
diff --git a/mesonbuild/interpreter/mesonmain.py b/mesonbuild/interpreter/mesonmain.py
index 602575c57..d22d36bf0 100644
--- a/mesonbuild/interpreter/mesonmain.py
+++ b/mesonbuild/interpreter/mesonmain.py
@@ -129,7 +129,7 @@ class MesonMain(MesonInterpreterObject):
def add_install_script_method(
self,
args: T.Tuple[T.Union[str, mesonlib.File, build.Executable, ExternalProgram],
- T.List[T.Union[str, mesonlib.File, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, ExternalProgram]]],
+ T.List[T.Union[str, mesonlib.File, build.BuildTargetTypes, ExternalProgram]]],
kwargs: 'AddInstallScriptKW') -> None:
script_args = self._process_script_args('add_install_script', args[1])
script = self._find_source_script('add_install_script', args[0], script_args)
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index a551d0f7c..567cd1e59 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -24,14 +24,14 @@ NoneType: T.Type[None] = type(None)
if T.TYPE_CHECKING:
from typing_extensions import Literal
- from ..build import ObjectTypes
+ from ..build import ObjectTypes, GeneratedTypes, BuildTargetTypes
from ..interpreterbase import TYPE_var
from ..options import ElementaryOptionValues
from ..mesonlib import EnvInitValueType
_FullEnvInitValueType = T.Union[EnvironmentVariables, T.List[str], T.List[T.List[str]], EnvInitValueType, str, None]
PkgConfigDefineType = T.Optional[T.Tuple[T.Tuple[str, str], ...]]
- SourcesVarargsType = T.List[T.Union[str, File, CustomTarget, CustomTargetIndex, GeneratedList, StructuredSources, ExtractedObjects, BuildTarget]]
+ SourcesVarargsType = T.List[T.Union[str, File, GeneratedTypes, StructuredSources, ExtractedObjects, BuildTarget]]
def in_set_validator(choices: T.Set[str]) -> T.Callable[[str], T.Optional[str]]:
@@ -269,7 +269,7 @@ DEPFILE_KW: KwargInfo[T.Optional[str]] = KwargInfo(
validator=lambda x: 'Depfile must be a plain filename with a subdirectory' if has_path_sep(x) else None
)
-DEPENDS_KW: KwargInfo[T.List[T.Union[BuildTarget, CustomTarget, CustomTargetIndex]]] = KwargInfo(
+DEPENDS_KW: KwargInfo[T.List[BuildTargetTypes]] = KwargInfo(
'depends',
ContainerTypeInfo(list, (BuildTarget, CustomTarget, CustomTargetIndex)),
listify=True,
@@ -284,7 +284,7 @@ DEPEND_FILES_KW: KwargInfo[T.List[T.Union[str, File]]] = KwargInfo(
default=[],
)
-COMMAND_KW: KwargInfo[T.List[T.Union[str, BuildTarget, CustomTarget, CustomTargetIndex, ExternalProgram, File]]] = KwargInfo(
+COMMAND_KW: KwargInfo[T.List[T.Union[str, BuildTargetTypes, ExternalProgram, File]]] = KwargInfo(
'command',
ContainerTypeInfo(list, (str, BuildTarget, CustomTarget, CustomTargetIndex, ExternalProgram, File), allow_empty=False),
required=True,
@@ -349,7 +349,7 @@ OUTPUT_KW: KwargInfo[str] = KwargInfo(
validator=lambda x: _output_validator([x])
)
-CT_INPUT_KW: KwargInfo[T.List[T.Union[str, File, ExternalProgram, BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects, GeneratedList]]] = KwargInfo(
+CT_INPUT_KW: KwargInfo[T.List[T.Union[str, File, ExternalProgram, BuildTarget, GeneratedTypes, ExtractedObjects]]] = KwargInfo(
'input',
ContainerTypeInfo(list, (str, File, ExternalProgram, BuildTarget, CustomTarget, CustomTargetIndex, ExtractedObjects, GeneratedList)),
listify=True,
@@ -461,7 +461,7 @@ LINK_WHOLE_KW: KwargInfo[T.List[T.Union[BothLibraries, StaticLibrary, CustomTarg
validator=link_whole_validator,
)
-DEPENDENCY_SOURCES_KW: KwargInfo[T.List[T.Union[str, File, CustomTarget, CustomTargetIndex, GeneratedList]]] = KwargInfo(
+DEPENDENCY_SOURCES_KW: KwargInfo[T.List[T.Union[str, File, GeneratedTypes]]] = KwargInfo(
'sources',
ContainerTypeInfo(list, (str, File, CustomTarget, CustomTargetIndex, GeneratedList)),
listify=True,
diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py
index b4505fdb9..aeda4837e 100644
--- a/mesonbuild/mintro.py
+++ b/mesonbuild/mintro.py
@@ -378,7 +378,7 @@ def list_deps_from_source(intr: IntrospectionInterpreter) -> T.List[T.Dict[str,
def list_deps(coredata: cdata.CoreData, backend: backends.Backend) -> T.List[T.Dict[str, T.Union[str, T.List[str]]]]:
result: T.Dict[str, T.Dict[str, T.Union[str, T.List[str]]]] = {}
- def _src_to_str(src_file: T.Union[mesonlib.FileOrString, build.CustomTarget, build.StructuredSources, build.CustomTargetIndex, build.GeneratedList]) -> T.List[str]:
+ def _src_to_str(src_file: T.Union[mesonlib.FileOrString, build.GeneratedTypes, build.StructuredSources]) -> T.List[str]:
if isinstance(src_file, str):
return [src_file]
if isinstance(src_file, mesonlib.File):
diff --git a/mesonbuild/modules/_qt.py b/mesonbuild/modules/_qt.py
index 7d52842f9..675c174a7 100644
--- a/mesonbuild/modules/_qt.py
+++ b/mesonbuild/modules/_qt.py
@@ -39,7 +39,7 @@ if T.TYPE_CHECKING:
"""Keyword arguments for the Resource Compiler method."""
name: T.Optional[str]
- sources: T.Sequence[T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
+ sources: T.Sequence[T.Union[FileOrString, build.GeneratedTypes]]
extra_args: T.List[str]
method: str
@@ -47,7 +47,7 @@ if T.TYPE_CHECKING:
"""Keyword arguments for the Ui Compiler method."""
- sources: T.Sequence[T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
+ sources: T.Sequence[T.Union[FileOrString, build.GeneratedTypes]]
extra_args: T.List[str]
method: str
preserve_paths: bool
@@ -56,8 +56,8 @@ if T.TYPE_CHECKING:
"""Keyword arguments for the Moc Compiler method."""
- sources: T.Sequence[T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
- headers: T.Sequence[T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
+ sources: T.Sequence[T.Union[FileOrString, build.GeneratedTypes]]
+ headers: T.Sequence[T.Union[FileOrString, build.GeneratedTypes]]
extra_args: T.List[str]
method: str
include_directories: T.List[T.Union[str, build.IncludeDirs]]
@@ -94,7 +94,7 @@ if T.TYPE_CHECKING:
method: str
qresource: T.Optional[str]
rcc_extra_arguments: T.List[str]
- ts_files: T.List[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]]
+ ts_files: T.List[T.Union[str, File, build.GeneratedTypes]]
class GenQrcKwArgs(TypedDict):
@@ -325,7 +325,7 @@ class QtBaseModule(ExtensionModule):
raise MesonException(f'Unable to parse resource file {abspath}')
def _parse_qrc_deps(self, state: ModuleState,
- rcc_file_: T.Union[FileOrString, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList]) -> T.List[File]:
+ rcc_file_: T.Union[FileOrString, build.GeneratedTypes]) -> T.List[File]:
result: T.List[File] = []
inputs: T.Sequence['FileOrString'] = []
if isinstance(rcc_file_, (str, File)):
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index 6a7685390..9e525601e 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -648,7 +648,7 @@ class GnomeModule(ExtensionModule):
return link_command, new_depends
def _get_dependencies_flags_raw(
- self, deps: T.Sequence[T.Union['Dependency', build.BuildTarget, CustomTarget, CustomTargetIndex]],
+ self, deps: T.Sequence[T.Union['Dependency', build.BuildTargetTypes]],
state: 'ModuleState',
depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString', build.StructuredSources]],
include_rpath: bool,
@@ -741,7 +741,7 @@ class GnomeModule(ExtensionModule):
return cflags, internal_ldflags, external_ldflags, gi_includes, depends
def _get_dependencies_flags(
- self, deps: T.Sequence[T.Union['Dependency', build.BuildTarget, CustomTarget, CustomTargetIndex]],
+ self, deps: T.Sequence[T.Union['Dependency', build.BuildTargetTypes]],
state: 'ModuleState',
depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString', build.StructuredSources]],
include_rpath: bool = False,
@@ -895,8 +895,8 @@ class GnomeModule(ExtensionModule):
@staticmethod
def _get_gir_targets_deps(girtargets: T.Sequence[build.BuildTarget]
- ) -> T.List[T.Union[build.BuildTarget, CustomTarget, CustomTargetIndex, Dependency]]:
- ret: T.List[T.Union[build.BuildTarget, CustomTarget, CustomTargetIndex, Dependency]] = []
+ ) -> T.List[T.Union[build.BuildTargetTypes, Dependency]]:
+ ret: T.List[T.Union[build.BuildTargetTypes, Dependency]] = []
for girtarget in girtargets:
ret += girtarget.get_all_link_deps()
ret += girtarget.get_external_deps()
@@ -972,7 +972,7 @@ class GnomeModule(ExtensionModule):
state: 'ModuleState',
girfile: str,
scan_command: T.Sequence[T.Union['FileOrString', Executable, ExternalProgram, OverrideProgram]],
- generated_files: T.Sequence[T.Union[str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList]],
+ generated_files: T.Sequence[T.Union[str, mesonlib.File, build.GeneratedTypes]],
depends: T.Sequence[T.Union['FileOrString', build.BuildTarget, 'build.GeneratedTypes', build.StructuredSources]],
env_flags: T.Sequence[str],
kwargs: T.Dict[str, T.Any]) -> GirTarget:
@@ -1021,7 +1021,7 @@ class GnomeModule(ExtensionModule):
@staticmethod
def _make_typelib_target(state: 'ModuleState', typelib_output: str,
typelib_cmd: T.Sequence[T.Union[str, Executable, ExternalProgram, CustomTarget]],
- generated_files: T.Sequence[T.Union[str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList]],
+ generated_files: T.Sequence[T.Union[str, mesonlib.File, build.GeneratedTypes]],
kwargs: T.Dict[str, T.Any]) -> TypelibTarget:
install = kwargs['install_typelib']
if install is None:
@@ -1051,7 +1051,7 @@ class GnomeModule(ExtensionModule):
@staticmethod
def _gather_typelib_includes_and_update_depends(
state: 'ModuleState',
- deps: T.Sequence[T.Union[Dependency, build.BuildTarget, CustomTarget, CustomTargetIndex]],
+ deps: T.Sequence[T.Union[Dependency, build.BuildTargetTypes]],
depends: T.Sequence[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString', build.StructuredSources]]
) -> T.Tuple[T.List[str], T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString', build.StructuredSources]]]:
# Need to recursively add deps on GirTarget sources from our
@@ -2041,13 +2041,13 @@ class GnomeModule(ExtensionModule):
def _make_mkenum_impl(
self,
state: 'ModuleState',
- sources: T.Sequence[T.Union[str, mesonlib.File, CustomTarget, CustomTargetIndex, GeneratedList]],
+ sources: T.Sequence[T.Union[str, mesonlib.File, build.GeneratedTypes]],
output: str,
cmd: T.List[str],
*,
install: bool = False,
install_dir: T.Optional[T.Sequence[T.Union[str, bool]]] = None,
- depends: T.Optional[T.Sequence[T.Union[CustomTarget, CustomTargetIndex, BuildTarget]]] = None
+ depends: T.Optional[T.Sequence[build.BuildTargetTypes]] = None
) -> build.CustomTarget:
real_cmd: T.List[T.Union[str, 'ToolType']] = [self._find_tool(state, 'glib-mkenums')]
real_cmd.extend(cmd)
diff --git a/mesonbuild/modules/i18n.py b/mesonbuild/modules/i18n.py
index 8b8306584..2d8d04d3e 100644
--- a/mesonbuild/modules/i18n.py
+++ b/mesonbuild/modules/i18n.py
@@ -56,16 +56,15 @@ if T.TYPE_CHECKING:
class ItsJoinFile(TypedDict):
input: T.List[T.Union[
- str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
- build.ExtractedObjects, build.GeneratedList, ExternalProgram,
- mesonlib.File]]
+ str, build.BuildTarget, build.GeneratedTypes,
+ build.ExtractedObjects, ExternalProgram, mesonlib.File]]
output: str
build_by_default: bool
install: bool
install_dir: T.Optional[str]
install_tag: T.Optional[str]
its_files: T.List[str]
- mo_targets: T.List[T.Union[build.BuildTarget, build.CustomTarget, build.CustomTargetIndex]]
+ mo_targets: T.List[build.BuildTargetTypes]
class XgettextProgramT(TypedDict):
@@ -75,7 +74,7 @@ if T.TYPE_CHECKING:
install_dir: T.Optional[str]
install_tag: T.Optional[str]
- SourcesType = T.Union[str, mesonlib.File, build.BuildTarget, build.BothLibraries, build.CustomTarget, build.CustomTargetIndex]
+ SourcesType = T.Union[str, mesonlib.File, build.BuildTargetTypes, build.BothLibraries]
_ARGS: KwargInfo[T.List[str]] = KwargInfo(
@@ -239,7 +238,7 @@ class XgettextProgram:
return mesonlib.File.from_built_file(self.interpreter.subdir, rsp_file.name)
@staticmethod
- def _get_source_id(sources: T.Iterable[T.Union[SourcesType, build.CustomTargetIndex]]) -> T.Iterable[str]:
+ def _get_source_id(sources: T.Iterable[SourcesType]) -> T.Iterable[str]:
for source in sources:
if isinstance(source, build.Target):
yield source.get_id()
@@ -309,8 +308,7 @@ class I18nModule(ExtensionModule):
ddirs = self._get_data_dirs(state, kwargs['data_dirs'])
datadirs = '--datadirs=' + ':'.join(ddirs) if ddirs else None
- command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
- build.CustomTargetIndex, 'ExternalProgram', mesonlib.File]] = []
+ command: T.List[T.Union[str, build.BuildTargetTypes, ExternalProgram, mesonlib.File]] = []
command.extend(state.environment.get_build_command())
command.extend([
'--internal', 'msgfmthelper',
@@ -489,8 +487,7 @@ class I18nModule(ExtensionModule):
for target in mo_targets:
mo_fnames.append(path.join(target.get_subdir(), target.get_outputs()[0]))
- command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
- build.CustomTargetIndex, 'ExternalProgram', mesonlib.File]] = []
+ command: T.List[T.Union[str, build.BuildTargetTypes, ExternalProgram, mesonlib.File]] = []
command.extend(state.environment.get_build_command())
itstool_cmd = self.tools['itstool'].get_command()