aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-02-16 19:25:07 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2020-02-17 22:48:19 +0530
commitfeb82e0f0f365d66199d697f1d99e109e2c6a700 (patch)
tree8fbc1e21421c5035f6f8c146e6517c0595b2fd51
parent901bbc36d902c8146482295827e5464070bbf898 (diff)
downloadmeson-feb82e0f0f365d66199d697f1d99e109e2c6a700.zip
meson-feb82e0f0f365d66199d697f1d99e109e2c6a700.tar.gz
meson-feb82e0f0f365d66199d697f1d99e109e2c6a700.tar.bz2
symbolextractor: Add typing hints
-rw-r--r--mesonbuild/scripts/symbolextractor.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/mesonbuild/scripts/symbolextractor.py b/mesonbuild/scripts/symbolextractor.py
index b168acc..f94595f 100644
--- a/mesonbuild/scripts/symbolextractor.py
+++ b/mesonbuild/scripts/symbolextractor.py
@@ -20,6 +20,7 @@
# This file is basically a reimplementation of
# http://cgit.freedesktop.org/libreoffice/core/commit/?id=3213cd54b76bc80a6f0516aac75a48ff3b2ad67c
+import typing as T
import os, sys
from .. import mesonlib
from .. import mlog
@@ -35,12 +36,12 @@ parser.add_argument('args', nargs='+')
TOOL_WARNING_FILE = None
RELINKING_WARNING = 'Relinking will always happen on source changes.'
-def dummy_syms(outfilename):
+def dummy_syms(outfilename: str):
"""Just touch it so relinking happens always."""
with open(outfilename, 'w'):
pass
-def write_if_changed(text, outfilename):
+def write_if_changed(text: str, outfilename: str):
try:
with open(outfilename, 'r') as f:
oldtext = f.read()
@@ -51,7 +52,7 @@ def write_if_changed(text, outfilename):
with open(outfilename, 'w') as f:
f.write(text)
-def print_tool_warning(tool, msg, stderr=None):
+def print_tool_warning(tool: list, msg: str, stderr: str = None):
global TOOL_WARNING_FILE
if os.path.exists(TOOL_WARNING_FILE):
return
@@ -65,7 +66,7 @@ def print_tool_warning(tool, msg, stderr=None):
with open(TOOL_WARNING_FILE, 'w'):
pass
-def call_tool(name, args):
+def call_tool(name: str, args: T.List[str]) -> str:
evar = name.upper()
if evar in os.environ:
import shlex
@@ -107,7 +108,7 @@ def linux_syms(libfilename: str, outfilename: str):
result += [' '.join(entry)]
write_if_changed('\n'.join(result) + '\n', outfilename)
-def osx_syms(libfilename, outfilename):
+def osx_syms(libfilename: str, outfilename: str):
# Get the name of the library
output = call_tool('otool', ['-l', libfilename])
if not output:
@@ -128,7 +129,7 @@ def osx_syms(libfilename, outfilename):
result += [' '.join(x.split()[0:2]) for x in output.split('\n')]
write_if_changed('\n'.join(result) + '\n', outfilename)
-def gen_symbols(libfilename, outfilename, cross_host):
+def gen_symbols(libfilename: str, outfilename: str, cross_host: str):
if cross_host is not None:
# In case of cross builds just always relink. In theory we could
# determine the correct toolset, but we would need to use the correct