1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
|
# SPDX-License-Identifier: Apache-2.0
# Copyright © 2021 The Meson Developers
# Copyright © 2021 Intel Corporation
from __future__ import annotations
"""Keyword Argument type annotations."""
import typing as T
from typing_extensions import TypedDict, Literal, Protocol, NotRequired
from .. import build
from .. import options
from ..compilers import Compiler
from ..dependencies.base import Dependency
from ..mesonlib import EnvironmentVariables, MachineChoice, File, FileMode, FileOrString, OptionKey
from ..modules.cmake import CMakeSubprojectOptions
from ..programs import ExternalProgram
from .type_checking import PkgConfigDefineType, SourcesVarargsType
class FuncAddProjectArgs(TypedDict):
"""Keyword Arguments for the add_*_arguments family of arguments.
including `add_global_arguments`, `add_project_arguments`, and their
link variants
Because of the use of a convertor function, we get the native keyword as
a MachineChoice instance already.
"""
native: MachineChoice
language: T.List[str]
class BaseTest(TypedDict):
"""Shared base for the Rust module."""
args: T.List[T.Union[str, File, build.Target]]
should_fail: bool
timeout: int
workdir: T.Optional[str]
depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]]
priority: int
env: EnvironmentVariables
suite: T.List[str]
class FuncBenchmark(BaseTest):
"""Keyword Arguments shared between `test` and `benchmark`."""
protocol: Literal['exitcode', 'tap', 'gtest', 'rust']
class FuncTest(FuncBenchmark):
"""Keyword Arguments for `test`
`test` only adds the `is_parallel` argument over benchmark, so inheritance
is helpful here.
"""
is_parallel: bool
class ExtractRequired(TypedDict):
"""Keyword Arguments consumed by the `extract_required_kwargs` function.
Any function that uses the `required` keyword argument which accepts either
a boolean or a feature option should inherit it's arguments from this class.
"""
required: T.Union[bool, options.UserFeatureOption]
class ExtractSearchDirs(TypedDict):
"""Keyword arguments consumed by the `extract_search_dirs` function.
See the not in `ExtractRequired`
"""
dirs: T.List[str]
class FuncGenerator(TypedDict):
"""Keyword rguments for the generator function."""
arguments: T.List[str]
output: T.List[str]
depfile: T.Optional[str]
capture: bool
depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]]
class GeneratorProcess(TypedDict):
"""Keyword Arguments for generator.process."""
preserve_path_from: T.Optional[str]
extra_args: T.List[str]
env: EnvironmentVariables
class DependencyMethodPartialDependency(TypedDict):
""" Keyword Arguments for the dep.partial_dependency methods """
compile_args: bool
link_args: bool
links: bool
includes: bool
sources: bool
class BuildTargeMethodExtractAllObjects(TypedDict):
recursive: bool
class FuncInstallSubdir(TypedDict):
install_dir: str
strip_directory: bool
exclude_files: T.List[str]
exclude_directories: T.List[str]
install_mode: FileMode
follow_symlinks: T.Optional[bool]
class FuncInstallData(TypedDict):
install_dir: str
sources: T.List[FileOrString]
rename: T.List[str]
install_mode: FileMode
follow_symlinks: T.Optional[bool]
class FuncInstallHeaders(TypedDict):
install_dir: T.Optional[str]
install_mode: FileMode
subdir: T.Optional[str]
follow_symlinks: T.Optional[bool]
class FuncInstallMan(TypedDict):
install_dir: T.Optional[str]
install_mode: FileMode
locale: T.Optional[str]
class FuncImportModule(ExtractRequired):
disabler: bool
class FuncIncludeDirectories(TypedDict):
is_system: bool
class FuncAddLanguages(ExtractRequired):
native: T.Optional[bool]
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: EnvironmentVariables
class CustomTarget(TypedDict):
build_always: bool
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]]
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]]
install: bool
install_dir: T.List[T.Union[str, T.Literal[False]]]
install_mode: FileMode
install_tag: T.List[T.Optional[str]]
output: T.List[str]
class AddTestSetup(TypedDict):
exe_wrapper: T.List[T.Union[str, ExternalProgram]]
gdb: bool
timeout_multiplier: int
is_default: bool
exclude_suites: T.List[str]
env: EnvironmentVariables
class Project(TypedDict):
version: T.Optional[FileOrString]
meson_version: T.Optional[str]
default_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
license: T.List[str]
subproject_dir: str
class _FoundProto(Protocol):
"""Protocol for subdir arguments.
This allows us to define any object that has a found(self) -> bool method
"""
def found(self) -> bool: ...
class Subdir(TypedDict):
if_found: T.List[_FoundProto]
class Summary(TypedDict):
section: str
bool_yn: bool
list_sep: T.Optional[str]
class FindProgram(ExtractRequired, ExtractSearchDirs):
default_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
native: MachineChoice
version: T.List[str]
class RunCommand(TypedDict):
check: bool
capture: T.Optional[bool]
env: EnvironmentVariables
class FeatureOptionRequire(TypedDict):
error_message: T.Optional[str]
class DependencyPkgConfigVar(TypedDict):
default: T.Optional[str]
define_variable: PkgConfigDefineType
class DependencyGetVariable(TypedDict):
cmake: T.Optional[str]
pkgconfig: T.Optional[str]
configtool: T.Optional[str]
internal: T.Optional[str]
default_value: T.Optional[str]
pkgconfig_define: PkgConfigDefineType
class ConfigurationDataSet(TypedDict):
description: T.Optional[str]
class VcsTag(TypedDict):
command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget,
build.CustomTargetIndex, ExternalProgram, File]]
fallback: T.Optional[str]
input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex,
build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]]
output: T.List[str]
replace_string: str
class ConfigureFile(TypedDict):
output: str
capture: bool
format: T.Literal['meson', 'cmake', 'cmake@']
output_format: T.Literal['c', 'json', 'nasm']
depfile: T.Optional[str]
install: T.Optional[bool]
install_dir: T.Union[str, T.Literal[False]]
install_mode: FileMode
install_tag: T.Optional[str]
encoding: str
command: T.Optional[T.List[T.Union[build.Executable, ExternalProgram, Compiler, File, str]]]
input: T.List[FileOrString]
configuration: T.Optional[T.Union[T.Dict[str, T.Union[str, int, bool]], build.ConfigurationData]]
macro_name: T.Optional[str]
class Subproject(ExtractRequired):
default_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
version: T.List[str]
class DoSubproject(ExtractRequired):
default_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
version: T.List[str]
cmake_options: T.List[str]
options: T.Optional[CMakeSubprojectOptions]
class _BaseBuildTarget(TypedDict):
"""Arguments used by all BuildTarget like functions.
This really exists because Jar is so different than all of the other
BuildTarget functions.
"""
build_by_default: bool
build_rpath: str
extra_files: T.List[FileOrString]
gnu_symbol_visibility: str
install: bool
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_language: T.Optional[str]
name_prefix: T.Optional[str]
name_suffix: T.Optional[str]
native: MachineChoice
objects: T.List[build.ObjectTypes]
override_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
depend_files: NotRequired[T.List[File]]
resources: T.List[str]
class _BuildTarget(_BaseBuildTarget):
"""Arguments shared by non-JAR functions"""
d_debug: T.List[T.Union[str, int]]
d_import_dirs: T.List[T.Union[str, build.IncludeDirs]]
d_module_versions: T.List[T.Union[str, int]]
d_unittest: bool
rust_dependency_map: T.Dict[str, str]
sources: SourcesVarargsType
c_args: T.List[str]
cpp_args: T.List[str]
cuda_args: T.List[str]
fortran_args: T.List[str]
d_args: T.List[str]
objc_args: T.List[str]
objcpp_args: T.List[str]
rust_args: T.List[str]
vala_args: T.List[T.Union[str, File]] # Yes, Vala is really special
cs_args: T.List[str]
swift_args: T.List[str]
cython_args: T.List[str]
nasm_args: T.List[str]
masm_args: T.List[str]
class _LibraryMixin(TypedDict):
rust_abi: T.Optional[Literal['c', 'rust']]
class Executable(_BuildTarget):
export_dynamic: T.Optional[bool]
gui_app: T.Optional[bool]
implib: T.Optional[T.Union[str, bool]]
pie: T.Optional[bool]
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex]]
win_subsystem: T.Optional[str]
class _StaticLibMixin(TypedDict):
prelink: bool
pic: T.Optional[bool]
class StaticLibrary(_BuildTarget, _StaticLibMixin, _LibraryMixin):
pass
class _SharedLibMixin(TypedDict):
darwin_versions: T.Optional[T.Tuple[str, str]]
soversion: T.Optional[str]
version: T.Optional[str]
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex]]
class SharedLibrary(_BuildTarget, _SharedLibMixin, _LibraryMixin):
pass
class SharedModule(_BuildTarget, _LibraryMixin):
vs_module_defs: T.Optional[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex]]
class Library(_BuildTarget, _SharedLibMixin, _StaticLibMixin, _LibraryMixin):
"""For library, both_library, and as a base for build_target"""
c_static_args: NotRequired[T.List[str]]
c_shared_args: NotRequired[T.List[str]]
cpp_static_args: NotRequired[T.List[str]]
cpp_shared_args: NotRequired[T.List[str]]
cuda_static_args: NotRequired[T.List[str]]
cuda_shared_args: NotRequired[T.List[str]]
fortran_static_args: NotRequired[T.List[str]]
fortran_shared_args: NotRequired[T.List[str]]
d_static_args: NotRequired[T.List[str]]
d_shared_args: NotRequired[T.List[str]]
objc_static_args: NotRequired[T.List[str]]
objc_shared_args: NotRequired[T.List[str]]
objcpp_static_args: NotRequired[T.List[str]]
objcpp_shared_args: NotRequired[T.List[str]]
rust_static_args: NotRequired[T.List[str]]
rust_shared_args: NotRequired[T.List[str]]
vala_static_args: NotRequired[T.List[T.Union[str, File]]] # Yes, Vala is really special
vala_shared_args: NotRequired[T.List[T.Union[str, File]]] # Yes, Vala is really special
cs_static_args: NotRequired[T.List[str]]
cs_shared_args: NotRequired[T.List[str]]
swift_static_args: NotRequired[T.List[str]]
swift_shared_args: NotRequired[T.List[str]]
cython_static_args: NotRequired[T.List[str]]
cython_shared_args: NotRequired[T.List[str]]
nasm_static_args: NotRequired[T.List[str]]
nasm_shared_args: NotRequired[T.List[str]]
masm_static_args: NotRequired[T.List[str]]
masm_shared_args: NotRequired[T.List[str]]
class BuildTarget(Library):
target_type: Literal['executable', 'shared_library', 'static_library',
'shared_module', 'both_libraries', 'library', 'jar']
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]
java_args: T.List[str]
class FuncDeclareDependency(TypedDict):
compile_args: T.List[str]
d_import_dirs: T.List[T.Union[build.IncludeDirs, str]]
d_module_versions: T.List[T.Union[str, int]]
dependencies: T.List[Dependency]
extra_files: T.List[FileOrString]
include_directories: T.List[T.Union[build.IncludeDirs, str]]
link_args: T.List[str]
link_whole: T.List[T.Union[build.StaticLibrary, build.CustomTarget, build.CustomTargetIndex]]
link_with: T.List[build.LibTypes]
objects: T.List[build.ExtractedObjects]
sources: T.List[T.Union[FileOrString, build.GeneratedTypes]]
variables: T.Dict[str, str]
version: T.Optional[str]
|