1# SPDX-License-Identifier: Apache-2.0 2# Copyright © 2021 The Meson Developers 3# Copyright © 2021 Intel Corporation 4 5"""Keyword Argument type annotations.""" 6 7import typing as T 8 9from typing_extensions import TypedDict, Literal 10 11from .. import build 12from .. import coredata 13from ..mesonlib import MachineChoice, File, FileMode, FileOrString, OptionKey 14from ..programs import ExternalProgram 15 16 17class FuncAddProjectArgs(TypedDict): 18 19 """Keyword Arguments for the add_*_arguments family of arguments. 20 21 including `add_global_arguments`, `add_project_arguments`, and their 22 link variants 23 24 Because of the use of a convertor function, we get the native keyword as 25 a MachineChoice instance already. 26 """ 27 28 native: MachineChoice 29 language: T.List[str] 30 31 32class BaseTest(TypedDict): 33 34 """Shared base for the Rust module.""" 35 36 args: T.List[T.Union[str, File, build.Target]] 37 should_fail: bool 38 timeout: int 39 workdir: T.Optional[str] 40 depends: T.List[T.Union[build.CustomTarget, build.BuildTarget]] 41 priority: int 42 env: build.EnvironmentVariables 43 suite: T.List[str] 44 45 46class FuncBenchmark(BaseTest): 47 48 """Keyword Arguments shared between `test` and `benchmark`.""" 49 50 protocol: Literal['exitcode', 'tap', 'gtest', 'rust'] 51 52 53class FuncTest(FuncBenchmark): 54 55 """Keyword Arguments for `test` 56 57 `test` only adds the `is_prallel` argument over benchmark, so inherintance 58 is helpful here. 59 """ 60 61 is_parallel: bool 62 63 64class ExtractRequired(TypedDict): 65 66 """Keyword Arguments consumed by the `extract_required_kwargs` function. 67 68 Any function that uses the `required` keyword argument which accepts either 69 a boolean or a feature option should inherit it's arguments from this class. 70 """ 71 72 required: T.Union[bool, coredata.UserFeatureOption] 73 74 75class ExtractSearchDirs(TypedDict): 76 77 """Keyword arguments consumed by the `extract_search_dirs` function. 78 79 See the not in `ExtractRequired` 80 """ 81 82 dirs: T.List[str] 83 84 85class FuncGenerator(TypedDict): 86 87 """Keyword rguments for the generator function.""" 88 89 arguments: T.List[str] 90 output: T.List[str] 91 depfile: T.Optional[str] 92 capture: bool 93 depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]] 94 95 96class GeneratorProcess(TypedDict): 97 98 """Keyword Arguments for generator.process.""" 99 100 preserve_path_from: T.Optional[str] 101 extra_args: T.List[str] 102 103class DependencyMethodPartialDependency(TypedDict): 104 105 """ Keyword Arguments for the dep.partial_dependency methods """ 106 107 compile_args: bool 108 link_args: bool 109 links: bool 110 includes: bool 111 sources: bool 112 113class BuildTargeMethodExtractAllObjects(TypedDict): 114 recursive: bool 115 116class FuncInstallSubdir(TypedDict): 117 118 install_dir: str 119 strip_directory: bool 120 exclude_files: T.List[str] 121 exclude_directories: T.List[str] 122 install_mode: FileMode 123 124 125class FuncInstallData(TypedDict): 126 127 install_dir: str 128 sources: T.List[FileOrString] 129 rename: T.List[str] 130 install_mode: FileMode 131 132 133class FuncInstallHeaders(TypedDict): 134 135 install_dir: T.Optional[str] 136 install_mode: FileMode 137 subdir: T.Optional[str] 138 139 140class FuncInstallMan(TypedDict): 141 142 install_dir: T.Optional[str] 143 install_mode: FileMode 144 locale: T.Optional[str] 145 146 147class FuncImportModule(ExtractRequired): 148 149 disabler: bool 150 151 152class FuncIncludeDirectories(TypedDict): 153 154 is_system: bool 155 156class FuncAddLanguages(ExtractRequired): 157 158 native: T.Optional[bool] 159 160class RunTarget(TypedDict): 161 162 command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, ExternalProgram, File]] 163 depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]] 164 env: build.EnvironmentVariables 165 166 167class CustomTarget(TypedDict): 168 169 build_always: bool 170 build_always_stale: bool 171 build_by_default: bool 172 capture: bool 173 command: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, 174 build.CustomTargetIndex, ExternalProgram, File]] 175 consonle: bool 176 depend_files: T.List[FileOrString] 177 depends: T.List[T.Union[build.BuildTarget, build.CustomTarget]] 178 depfile: T.Optional[str] 179 env: build.EnvironmentVariables 180 feed: bool 181 input: T.List[T.Union[str, build.BuildTarget, build.CustomTarget, build.CustomTargetIndex, 182 build.ExtractedObjects, build.GeneratedList, ExternalProgram, File]] 183 install: bool 184 install_dir: T.List[T.Union[str, bool]] 185 install_mode: FileMode 186 install_tag: T.List[T.Union[str, bool]] 187 output: T.List[str] 188 override_options: T.Dict[OptionKey, str] 189