aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-01-12 11:20:13 -0800
committerDylan Baker <dylan@pnwbakers.com>2021-01-13 13:32:48 -0800
commit59328aba2929b969a7e7ce1390d891dafe391a7f (patch)
treee4386d9ca8757d1901dedf885df0fa6787595443
parent022632c91b255739c5100601a02b197cb29cd23e (diff)
downloadmeson-59328aba2929b969a7e7ce1390d891dafe391a7f.zip
meson-59328aba2929b969a7e7ce1390d891dafe391a7f.tar.gz
meson-59328aba2929b969a7e7ce1390d891dafe391a7f.tar.bz2
build: Add some type annotations
-rw-r--r--mesonbuild/build.py30
-rw-r--r--mesonbuild/minstall.py2
2 files changed, 20 insertions, 12 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 736d42c..23d2ff7 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -404,6 +404,9 @@ class EnvironmentVariables:
return env
class Target:
+
+ # TODO: should Target be an abc.ABCMeta?
+
def __init__(self, name: str, subdir: str, subproject: str, build_by_default: bool, for_machine: MachineChoice):
if has_path_sep(name):
# Fix failing test 53 when this becomes an error.
@@ -443,7 +446,10 @@ a hard error in the future.'''.format(name))
return NotImplemented
return self.get_id() >= other.get_id()
- def get_install_dir(self, environment):
+ def get_default_install_dir(self, env: environment.Environment) -> str:
+ raise NotImplementedError
+
+ def get_install_dir(self, environment: environment.Environment) -> T.Tuple[T.Any, bool]:
# Find the installation directory.
default_install_dir = self.get_default_install_dir(environment)
outdirs = self.get_custom_install_dir()
@@ -554,7 +560,7 @@ class BuildTarget(Target):
self.external_deps = []
self.include_dirs = []
self.link_language = kwargs.get('link_language')
- self.link_targets = []
+ self.link_targets: T.List[BuildTarget] = []
self.link_whole_targets = []
self.link_depends = []
self.added_deps = set()
@@ -572,7 +578,7 @@ class BuildTarget(Target):
self.pic = False
self.pie = False
# Track build_rpath entries so we can remove them at install time
- self.rpath_dirs_to_remove = set()
+ self.rpath_dirs_to_remove: T.Set[bytes] = set()
# Sources can be:
# 1. Pre-existing source files in the source tree
# 2. Pre-existing sources generated by configure_file in the build tree
@@ -884,7 +890,7 @@ class BuildTarget(Target):
result.update(i.get_link_dep_subdirs())
return result
- def get_default_install_dir(self, environment):
+ def get_default_install_dir(self, environment: environment.Environment) -> str:
return environment.get_libdir()
def get_custom_install_dir(self):
@@ -995,7 +1001,7 @@ This will become a hard error in a future Meson release.''')
if not(os.path.isfile(trial)):
raise InvalidArguments('Tried to add non-existing extra file {}.'.format(i))
self.extra_files = extra_files
- self.install_rpath = kwargs.get('install_rpath', '')
+ self.install_rpath: str = kwargs.get('install_rpath', '')
if not isinstance(self.install_rpath, str):
raise InvalidArguments('Install_rpath is not a string.')
self.build_rpath = kwargs.get('build_rpath', '')
@@ -1299,7 +1305,7 @@ You probably should put it in link_with instead.''')
else:
self.extra_args[language] = args
- def get_aliases(self):
+ def get_aliases(self) -> T.Dict[str, str]:
return {}
def get_langs_used_by_deps(self) -> T.List[str]:
@@ -1673,7 +1679,7 @@ class Executable(BuildTarget):
# Only linkwithable if using export_dynamic
self.is_linkwithable = self.export_dynamic
- def get_default_install_dir(self, environment):
+ def get_default_install_dir(self, environment: environment.Environment) -> str:
return environment.get_bindir()
def description(self):
@@ -1802,8 +1808,8 @@ class SharedLibrary(BuildTarget):
self.basic_filename_tpl = '{0.prefix}{0.name}.{0.suffix}'
self.determine_filenames(environment)
- def get_link_deps_mapping(self, prefix, environment):
- result = {}
+ def get_link_deps_mapping(self, prefix, environment) -> T.Dict[str, str]:
+ result: T.Dict[str, str] = {}
mappings = self.get_transitive_link_deps_mapping(prefix, environment)
old = get_target_macos_dylib_install_name(self)
if old not in mappings:
@@ -2053,7 +2059,7 @@ class SharedLibrary(BuildTarget):
def get_all_link_deps(self):
return [self] + self.get_transitive_link_deps()
- def get_aliases(self):
+ def get_aliases(self) -> T.Dict[str, str]:
"""
If the versioned library name is libfoo.so.0.100.0, aliases are:
* libfoo.so.0 (soversion) -> libfoo.so.0.100.0
@@ -2061,11 +2067,11 @@ class SharedLibrary(BuildTarget):
Same for dylib:
* libfoo.dylib (unversioned; for linking) -> libfoo.0.dylib
"""
- aliases = {}
+ aliases: T.Dict[str, str] = {}
# Aliases are only useful with .so and .dylib libraries. Also if
# there's no self.soversion (no versioning), we don't need aliases.
if self.suffix not in ('so', 'dylib') or not self.soversion:
- return {}
+ return aliases
# With .so libraries, the minor and micro versions are also in the
# filename. If ltversion != soversion we create an soversion alias:
# libfoo.so.0 -> libfoo.so.0.100.0
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index 4d40752..0adcda2 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -538,6 +538,7 @@ class Installer:
else:
raise
+
def rebuild_all(wd: str) -> bool:
if not (Path(wd) / 'build.ninja').is_file():
print('Only ninja backend is supported to rebuild the project before installation.')
@@ -555,6 +556,7 @@ def rebuild_all(wd: str) -> bool:
return True
+
def run(opts):
datafilename = 'meson-private/install.dat'
private_dir = os.path.dirname(datafilename)