diff options
author | John Ericson <git@JohnEricson.me> | 2019-02-25 02:45:20 -0500 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2019-05-02 10:58:23 -0700 |
commit | 4c2617a9c6fd02e3f8831b7de8755380ac4bcb16 (patch) | |
tree | 0214fa8f65cd2b9ef66c88c588401907e868ed9f /mesonbuild/environment.py | |
parent | a15a8b7e246be448e79ba20742e713e39807bd00 (diff) | |
download | meson-4c2617a9c6fd02e3f8831b7de8755380ac4bcb16.zip meson-4c2617a9c6fd02e3f8831b7de8755380ac4bcb16.tar.gz meson-4c2617a9c6fd02e3f8831b7de8755380ac4bcb16.tar.bz2 |
Add some type annotations and fix lints
Some things, like `method[...](...)` or `x: ... = ...` python 3.5
doesn't support, so I made a comment instead with the intention that it
can someday be made into a real annotation.
Diffstat (limited to 'mesonbuild/environment.py')
-rw-r--r-- | mesonbuild/environment.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index bf2cce9..462672e 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os, platform, re, sys, shlex, shutil, subprocess +import os, platform, re, sys, shlex, shutil, subprocess, typing from . import coredata from .linkers import ArLinker, ArmarLinker, VisualStudioLinker, DLinker, CcrxLinker @@ -28,6 +28,7 @@ from .envconfig import ( ) from . import compilers from .compilers import ( + Compiler, CompilerType, is_assembly, is_header, @@ -83,6 +84,8 @@ from .compilers import ( build_filename = 'meson.build' +CompilersDict = typing.Dict[str, Compiler] + def detect_gcovr(min_version='3.3', new_rootdir_version='4.2', log=False): gcovr_exe = 'gcovr' try: @@ -150,7 +153,7 @@ def detect_native_windows_arch(): raise EnvironmentException('Unable to detect native OS architecture') return arch -def detect_windows_arch(compilers): +def detect_windows_arch(compilers: CompilersDict) -> str: """ Detecting the 'native' architecture of Windows is not a trivial task. We cannot trust that the architecture that Python is built for is the 'native' @@ -190,7 +193,7 @@ def detect_windows_arch(compilers): return 'x86' return os_arch -def any_compiler_has_define(compilers, define): +def any_compiler_has_define(compilers: CompilersDict, define): for c in compilers.values(): try: if c.has_builtin_define(define): @@ -200,7 +203,7 @@ def any_compiler_has_define(compilers, define): pass return False -def detect_cpu_family(compilers): +def detect_cpu_family(compilers: CompilersDict) -> str: """ Python is inconsistent in its platform module. It returns different values for the same cpu. @@ -262,7 +265,7 @@ def detect_cpu_family(compilers): return trial -def detect_cpu(compilers): +def detect_cpu(compilers: CompilersDict): if mesonlib.is_windows(): trial = detect_windows_arch(compilers) else: @@ -295,7 +298,7 @@ def detect_msys2_arch(): return os.environ['MSYSTEM_CARCH'] return None -def detect_machine_info(compilers = None) -> MachineInfo: +def detect_machine_info(compilers: typing.Optional[CompilersDict] = None) -> MachineInfo: """Detect the machine we're running on If compilers are not provided, we cannot know as much. None out those |