aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-08-29 16:49:41 -0400
committerXavier Claessens <xclaesse@gmail.com>2020-09-13 13:54:47 -0400
commit6ec0b535ba75955d2c82fcf6baff895782a96bb0 (patch)
treea0c18a34d455c2e977992e710c87020ed17f718b
parent9d338200dacdf24c50259c309380200f8a53d5b5 (diff)
downloadmeson-6ec0b535ba75955d2c82fcf6baff895782a96bb0.zip
meson-6ec0b535ba75955d2c82fcf6baff895782a96bb0.tar.gz
meson-6ec0b535ba75955d2c82fcf6baff895782a96bb0.tar.bz2
external-project: Add typing annotation
-rw-r--r--mesonbuild/modules/unstable_external_project.py27
-rw-r--r--mesonbuild/scripts/externalproject.py9
2 files changed, 25 insertions, 11 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,
diff --git a/mesonbuild/scripts/externalproject.py b/mesonbuild/scripts/externalproject.py
index 6c3a89c..6ed6264 100644
--- a/mesonbuild/scripts/externalproject.py
+++ b/mesonbuild/scripts/externalproject.py
@@ -17,11 +17,12 @@ import argparse
import multiprocessing
import subprocess
from pathlib import Path
+import typing as T
from ..mesonlib import Popen_safe
class ExternalProject:
- def __init__(self, options):
+ def __init__(self, options: argparse.Namespace):
self.name = options.name
self.src_dir = options.srcdir
self.build_dir = options.builddir
@@ -46,13 +47,13 @@ class ExternalProject:
with open(self.stampfile, 'w') as f:
pass
- def gnu_make(self):
+ def gnu_make(self) -> bool:
p, o, e = Popen_safe([self.make, '--version'])
if p.returncode == 0 and 'GNU Make' in o:
return True
return False
- def build(self):
+ def build(self) -> int:
make_cmd = [self.make]
if not self.verbose:
make_cmd.append('--quiet')
@@ -73,7 +74,7 @@ class ExternalProject:
return 0
- def _run(self, command):
+ def _run(self, command: T.List[str]) -> int:
output = None if self.verbose else subprocess.DEVNULL
p, o, e = Popen_safe(command, stderr=subprocess.STDOUT, stdout=output,
cwd=self.build_dir)