14
14
15
15
import os , subprocess , shlex
16
16
from pathlib import Path
17
+ import typing as T
17
18
18
19
from . import ExtensionModule , ModuleReturnValue
19
20
from .. import mlog , build
20
21
from ..mesonlib import (MesonException , Popen_safe , MachineChoice ,
21
22
get_variable_regex , do_replacement )
22
23
from ..interpreterbase import InterpreterObject , InterpreterException , FeatureNew
23
24
from ..interpreterbase import stringArgs , permittedKwargs
24
- from ..interpreter import DependencyHolder , InstallDir
25
+ from ..interpreter import Interpreter , DependencyHolder , InstallDir
25
26
from ..compilers .compilers import cflags_mapping , cexe_mapping
26
27
from ..dependencies .base import InternalDependency , PkgConfigDependency
28
+ from ..environment import Environment
27
29
28
30
class ExternalProject (InterpreterObject ):
29
- def __init__ (self , interpreter , subdir , project_version , subproject , environment , build_machine , host_machine ,
30
- configure_command , configure_options , cross_configure_options , env , verbose ):
31
+ def __init__ (self ,
32
+ interpreter : Interpreter ,
33
+ subdir : str ,
34
+ project_version : T .Dict [str , str ],
35
+ subproject : str ,
36
+ environment : Environment ,
37
+ build_machine : str ,
38
+ host_machine : str ,
39
+ configure_command : T .List [str ],
40
+ configure_options : T .List [str ],
41
+ cross_configure_options : T .List [str ],
42
+ env : build .EnvironmentVariables ,
43
+ verbose : bool ):
31
44
InterpreterObject .__init__ (self )
32
45
self .methods .update ({'dependency' : self .dependency_method ,
33
46
})
@@ -116,10 +129,10 @@ def _configure(self):
116
129
self .build_dir .mkdir (parents = True , exist_ok = True )
117
130
self ._run ('configure' , configure_cmd )
118
131
119
- def _quote_and_join (self , array ) :
132
+ def _quote_and_join (self , array : T . List [ str ]) -> str :
120
133
return ' ' .join ([shlex .quote (i ) for i in array ])
121
134
122
- def _validate_configure_options (self , required_keys ):
135
+ def _validate_configure_options (self , required_keys : T . List [ str ] ):
123
136
# Ensure the user at least try to pass basic info to the build system,
124
137
# like the prefix, libdir, etc.
125
138
for key in required_keys :
@@ -131,7 +144,7 @@ def _validate_configure_options(self, required_keys):
131
144
m = 'At least one configure option must contain "{}" key'
132
145
raise InterpreterException (m .format (key_format ))
133
146
134
- def _format_options (self , options , variables ) :
147
+ def _format_options (self , options : T . List [ str ] , variables : T . Dict [ str , str ]) -> T . List [ str ] :
135
148
out = []
136
149
missing = set ()
137
150
regex = get_variable_regex ('meson' )
@@ -146,7 +159,7 @@ def _format_options(self, options, variables):
146
159
"Variables {} in configure options are missing." .format (var_list ))
147
160
return out
148
161
149
- def _run (self , step , command ):
162
+ def _run (self , step : str , command : T . List [ str ] ):
150
163
mlog .log ('External project {}:' .format (self .name ), mlog .bold (step ))
151
164
output = None if self .verbose else subprocess .DEVNULL
152
165
p , o , e = Popen_safe (command , cwd = str (self .build_dir ), env = self .run_env ,
0 commit comments