diff options
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 4 | ||||
-rw-r--r-- | mesonbuild/compilers/swift.py | 67 | ||||
-rwxr-xr-x | run_mypy.py | 1 |
3 files changed, 40 insertions, 32 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index a086d37..e7165d2 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1689,7 +1689,7 @@ int dummy; else: expdir = basedir srctreedir = os.path.normpath(os.path.join(self.environment.get_build_dir(), self.build_to_src, expdir)) - sargs = swiftc.get_include_args(srctreedir) + sargs = swiftc.get_include_args(srctreedir, False) compile_args += sargs link_args = swiftc.get_output_args(os.path.join(self.environment.get_build_dir(), self.get_target_filename(target))) link_args += self.build.get_project_link_args(swiftc, target.subproject, target.for_machine) @@ -1700,7 +1700,7 @@ int dummy; abs_module_dirs = self.determine_swift_dep_dirs(target) module_includes = [] for x in abs_module_dirs: - module_includes += swiftc.get_include_args(x) + module_includes += swiftc.get_include_args(x, False) link_deps = self.get_swift_link_deps(target) abs_link_deps = [os.path.join(self.environment.get_build_dir(), x) for x in link_deps] for d in target.link_targets: diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index 55f2761..8682e54 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -21,76 +21,83 @@ from .compilers import Compiler, swift_buildtype_args, clike_debug_args if T.TYPE_CHECKING: from ..envconfig import MachineInfo - -swift_optimization_args = {'0': [], - 'g': [], - '1': ['-O'], - '2': ['-O'], - '3': ['-O'], - 's': ['-O'], - } + from ..environment import Environment + from ..linkers import DynamicLinker + +swift_optimization_args = { + '0': [], + 'g': [], + '1': ['-O'], + '2': ['-O'], + '3': ['-O'], + 's': ['-O'], +} # type: T.Dict[str, T.List[str]] class SwiftCompiler(Compiler): LINKER_PREFIX = ['-Xlinker'] language = 'swift' - def __init__(self, exelist, version, for_machine: MachineChoice, - is_cross: bool, info: 'MachineInfo', **kwargs): - super().__init__(exelist, version, for_machine, info, is_cross=is_cross, **kwargs) + def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, + is_cross: bool, info: 'MachineInfo', full_version: T.Optional[str] = None, + linker: T.Optional['DynamicLinker'] = None): + super().__init__(exelist, version, for_machine, info, + is_cross=is_cross, full_version=full_version, + linker=linker) self.version = version self.id = 'llvm' - def needs_static_linker(self): + def needs_static_linker(self) -> bool: return True - def get_werror_args(self): + def get_werror_args(self) -> T.List[str]: return ['--fatal-warnings'] - def get_dependency_gen_args(self, outtarget, outfile): + def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]: return ['-emit-dependencies'] - def depfile_for_object(self, objfile): + def depfile_for_object(self, objfile: str) -> str: return os.path.splitext(objfile)[0] + '.' + self.get_depfile_suffix() - def get_depfile_suffix(self): + def get_depfile_suffix(self) -> str: return 'd' - def get_output_args(self, target): + def get_output_args(self, target: str) -> T.List[str]: return ['-o', target] - def get_header_import_args(self, headername): + def get_header_import_args(self, headername: str) -> T.List[str]: return ['-import-objc-header', headername] - def get_warn_args(self, level): + def get_warn_args(self, level: str) -> T.List[str]: return [] - def get_buildtype_args(self, buildtype): + def get_buildtype_args(self, buildtype: str) -> T.List[str]: return swift_buildtype_args[buildtype] - def get_std_exe_link_args(self): + def get_std_exe_link_args(self) -> T.List[str]: return ['-emit-executable'] - def get_module_args(self, modname): + def get_module_args(self, modname: str) -> T.List[str]: return ['-module-name', modname] - def get_mod_gen_args(self): + def get_mod_gen_args(self) -> T.List[str]: return ['-emit-module'] - def get_include_args(self, dirname): - return ['-I' + dirname] + def get_include_args(self, path: str, is_system: bool) -> T.List[str]: + return ['-I' + path] - def get_compile_only_args(self): + def get_compile_only_args(self) -> T.List[str]: return ['-c'] - def compute_parameters_with_absolute_paths(self, parameter_list, build_dir): + def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], + build_dir: str) -> T.List[str]: for idx, i in enumerate(parameter_list): if i[:2] == '-I' or i[:2] == '-L': parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:])) return parameter_list - def sanity_check(self, work_dir, environment): + def sanity_check(self, work_dir: str, environment: 'Environment') -> None: src = 'swifttest.swift' source_name = os.path.join(work_dir, src) output_name = os.path.join(work_dir, 'swifttest') @@ -113,8 +120,8 @@ class SwiftCompiler(Compiler): if subprocess.call(output_name) != 0: raise EnvironmentException('Executables created by Swift compiler %s are not runnable.' % self.name_string()) - def get_debug_args(self, is_debug): + def get_debug_args(self, is_debug: bool) -> T.List[str]: return clike_debug_args[is_debug] - def get_optimization_args(self, optimization_level): + def get_optimization_args(self, optimization_level: str) -> T.List[str]: return swift_optimization_args[optimization_level] diff --git a/run_mypy.py b/run_mypy.py index 791deea..a5d7470 100755 --- a/run_mypy.py +++ b/run_mypy.py @@ -23,6 +23,7 @@ modules = [ 'mesonbuild/compilers/cuda.py', 'mesonbuild/compilers/objc.py', 'mesonbuild/compilers/objcpp.py', + 'mesonbuild/compilers/swift.py', 'mesonbuild/compilers/vala.py', # 'mesonbuild/coredata.py', 'mesonbuild/dependencies/boost.py', |