diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-08-29 16:49:41 -0400 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-09-13 13:54:47 -0400 |
commit | 6ec0b535ba75955d2c82fcf6baff895782a96bb0 (patch) | |
tree | a0c18a34d455c2e977992e710c87020ed17f718b /mesonbuild/modules | |
parent | 9d338200dacdf24c50259c309380200f8a53d5b5 (diff) | |
download | meson-6ec0b535ba75955d2c82fcf6baff895782a96bb0.zip meson-6ec0b535ba75955d2c82fcf6baff895782a96bb0.tar.gz meson-6ec0b535ba75955d2c82fcf6baff895782a96bb0.tar.bz2 |
external-project: Add typing annotation
Diffstat (limited to 'mesonbuild/modules')
-rw-r--r-- | mesonbuild/modules/unstable_external_project.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/mesonbuild/modules/unstable_external_project.py b/mesonbuild/modules/unstable_external_project.py index ff4685d..7bb761f 100644 --- a/mesonbuild/modules/unstable_external_project.py +++ b/mesonbuild/modules/unstable_external_project.py @@ -14,6 +14,7 @@ import os, subprocess, shlex from pathlib import Path +import typing as T from . import ExtensionModule, ModuleReturnValue from .. import mlog, build @@ -21,13 +22,25 @@ from ..mesonlib import (MesonException, Popen_safe, MachineChoice, get_variable_regex, do_replacement) from ..interpreterbase import InterpreterObject, InterpreterException, FeatureNew from ..interpreterbase import stringArgs, permittedKwargs -from ..interpreter import DependencyHolder, InstallDir +from ..interpreter import Interpreter, DependencyHolder, InstallDir from ..compilers.compilers import cflags_mapping, cexe_mapping from ..dependencies.base import InternalDependency, PkgConfigDependency +from ..environment import Environment class ExternalProject(InterpreterObject): - def __init__(self, interpreter, subdir, project_version, subproject, environment, build_machine, host_machine, - configure_command, configure_options, cross_configure_options, env, verbose): + def __init__(self, + interpreter: Interpreter, + subdir: str, + project_version: T.Dict[str, str], + subproject: str, + environment: Environment, + build_machine: str, + host_machine: str, + configure_command: T.List[str], + configure_options: T.List[str], + cross_configure_options: T.List[str], + env: build.EnvironmentVariables, + verbose: bool): InterpreterObject.__init__(self) self.methods.update({'dependency': self.dependency_method, }) @@ -116,10 +129,10 @@ class ExternalProject(InterpreterObject): self.build_dir.mkdir(parents=True, exist_ok=True) self._run('configure', configure_cmd) - def _quote_and_join(self, array): + def _quote_and_join(self, array: T.List[str]) -> str: return ' '.join([shlex.quote(i) for i in array]) - def _validate_configure_options(self, required_keys): + def _validate_configure_options(self, required_keys: T.List[str]): # Ensure the user at least try to pass basic info to the build system, # like the prefix, libdir, etc. for key in required_keys: @@ -131,7 +144,7 @@ class ExternalProject(InterpreterObject): m = 'At least one configure option must contain "{}" key' raise InterpreterException(m.format(key_format)) - def _format_options(self, options, variables): + def _format_options(self, options: T.List[str], variables: T.Dict[str, str]) -> T.List[str]: out = [] missing = set() regex = get_variable_regex('meson') @@ -146,7 +159,7 @@ class ExternalProject(InterpreterObject): "Variables {} in configure options are missing.".format(var_list)) return out - def _run(self, step, command): + def _run(self, step: str, command: T.List[str]): mlog.log('External project {}:'.format(self.name), mlog.bold(step)) output = None if self.verbose else subprocess.DEVNULL p, o, e = Popen_safe(command, cwd=str(self.build_dir), env=self.run_env, |