From ab21dc0384e1d03806b561b47942fb28da052efe Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 14:47:30 -0500 Subject: Remove type comments from compilers.py --- mesonbuild/compilers/compilers.py | 112 ++++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 53 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index dda0f38..286406d 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -92,12 +92,12 @@ clib_langs = ('objcpp', 'cpp', 'objc', 'c', 'nasm', 'fortran') clink_langs = ('d', 'cuda') + clib_langs SUFFIX_TO_LANG = dict(itertools.chain(*( - [(suffix, lang) for suffix in v] for lang, v in lang_suffixes.items()))) # type: T.Dict[str, str] + [(suffix, lang) for suffix in v] for lang, v in lang_suffixes.items()))) # Languages that should use LDFLAGS arguments when linking. -LANGUAGES_USING_LDFLAGS = {'objcpp', 'cpp', 'objc', 'c', 'fortran', 'd', 'cuda'} # type: T.Set[str] +LANGUAGES_USING_LDFLAGS = {'objcpp', 'cpp', 'objc', 'c', 'fortran', 'd', 'cuda'} # Languages that should use CPPFLAGS arguments when linking. -LANGUAGES_USING_CPPFLAGS = {'c', 'cpp', 'objc', 'objcpp'} # type: T.Set[str] +LANGUAGES_USING_CPPFLAGS = {'c', 'cpp', 'objc', 'objcpp'} soregex = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$') # Environment variables that each lang uses. @@ -190,99 +190,105 @@ class CompileCheckMode(enum.Enum): LINK = 'link' -cuda_buildtype_args = {'plain': [], +cuda_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': ['-g', '-G'], 'debugoptimized': ['-g', '-lineinfo'], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] -java_buildtype_args = {'plain': [], + } +java_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': ['-g'], 'debugoptimized': ['-g'], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } -rust_buildtype_args = {'plain': [], +rust_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } -d_gdc_buildtype_args = {'plain': [], +d_gdc_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': [], 'debugoptimized': ['-finline-functions'], 'release': ['-finline-functions'], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } -d_ldc_buildtype_args = {'plain': [], +d_ldc_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': [], 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'], 'release': ['-enable-inlining', '-Hkeep-all-bodies'], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } -d_dmd_buildtype_args = {'plain': [], +d_dmd_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': [], 'debugoptimized': ['-inline'], 'release': ['-inline'], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } -mono_buildtype_args = {'plain': [], +mono_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': [], 'debugoptimized': ['-optimize+'], 'release': ['-optimize+'], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } -swift_buildtype_args = {'plain': [], +swift_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], 'debug': [], 'debugoptimized': [], 'release': [], 'minsize': [], 'custom': [], - } # type: T.Dict[str, T.List[str]] + } gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32', - '-lole32', '-loleaut32', '-luuid', '-lcomdlg32', '-ladvapi32'] # type: T.List[str] + '-lole32', '-loleaut32', '-luuid', '-lcomdlg32', '-ladvapi32'] msvc_winlibs = ['kernel32.lib', 'user32.lib', 'gdi32.lib', 'winspool.lib', 'shell32.lib', 'ole32.lib', 'oleaut32.lib', - 'uuid.lib', 'comdlg32.lib', 'advapi32.lib'] # type: T.List[str] - -clike_optimization_args = {'plain': [], - '0': [], - 'g': [], - '1': ['-O1'], - '2': ['-O2'], - '3': ['-O3'], - 's': ['-Os'], - } # type: T.Dict[str, T.List[str]] - -cuda_optimization_args = {'plain': [], - '0': [], - 'g': ['-O0'], - '1': ['-O1'], - '2': ['-O2'], - '3': ['-O3'], - 's': ['-O3'] - } # type: T.Dict[str, T.List[str]] - -cuda_debug_args = {False: [], - True: ['-g']} # type: T.Dict[bool, T.List[str]] - -clike_debug_args = {False: [], - True: ['-g']} # type: T.Dict[bool, T.List[str]] + 'uuid.lib', 'comdlg32.lib', 'advapi32.lib'] + +clike_optimization_args: T.Dict[str, T.List[str]] = { + 'plain': [], + '0': [], + 'g': [], + '1': ['-O1'], + '2': ['-O2'], + '3': ['-O3'], + 's': ['-Os'], +} + +cuda_optimization_args: T.Dict[str, T.List[str]] = { + 'plain': [], + '0': [], + 'g': ['-O0'], + '1': ['-O1'], + '2': ['-O2'], + '3': ['-O3'], + 's': ['-O3'] +} + +cuda_debug_args: T.Dict[bool, T.List[str]] = { + False: [], + True: ['-g'] +} + +clike_debug_args: T.Dict[bool, T.List[str]] = { + False: [], + True: ['-g'] +} base_options: 'KeyedOptionDictType' = { OptionKey('b_pch'): coredata.UserBooleanOption('Use precompiled headers', True), @@ -350,7 +356,7 @@ def are_asserts_disabled(options: KeyedOptionDictType) -> bool: def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') -> T.List[str]: - args = [] # type T.List[str] + args: T.List[str] = [] try: if options[OptionKey('b_lto')].value: args.extend(compiler.get_lto_compile_args( @@ -399,7 +405,7 @@ def get_base_compile_args(options: 'KeyedOptionDictType', compiler: 'Compiler') def get_base_link_args(options: 'KeyedOptionDictType', linker: 'Compiler', is_shared_module: bool, build_dir: str) -> T.List[str]: - args = [] # type: T.List[str] + args: T.List[str] = [] try: if options[OptionKey('b_lto')].value: thinlto_cache_dir = None @@ -499,12 +505,12 @@ class CompileResult(HoldableObject): class Compiler(HoldableObject, metaclass=abc.ABCMeta): # Libraries to ignore in find_library() since they are provided by the # compiler or the C library. Currently only used for MSVC. - ignore_libs = [] # type: T.List[str] + ignore_libs: T.List[str] = [] # Libraries that are internal compiler implementations, and must not be # manually searched. - internal_libs = [] # type: T.List[str] + internal_libs: T.List[str] = [] - LINKER_PREFIX = None # type: T.Union[None, str, T.List[str]] + LINKER_PREFIX: T.Union[None, str, T.List[str]] = None INVOKES_LINKER = True language: str @@ -799,7 +805,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def get_compiler_args_for_mode(self, mode: CompileCheckMode) -> T.List[str]: # TODO: mode should really be an enum - args = [] # type: T.List[str] + args: T.List[str] = [] args += self.get_always_args() if mode is CompileCheckMode.COMPILE: args += self.get_compile_only_args() @@ -879,8 +885,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): # TODO: There's isn't really any reason for this to be a context manager # Calculate the key - textra_args = tuple(extra_args) if extra_args is not None else tuple() # type: T.Tuple[str, ...] - key = (tuple(self.exelist), self.version, code, textra_args, mode) # type: coredata.CompilerCheckCacheKey + textra_args: T.Tuple[str, ...] = tuple(extra_args) if extra_args is not None else tuple() + key: coredata.CompilerCheckCacheKey = (tuple(self.exelist), self.version, code, textra_args, mode) # Check if not cached, and generate, otherwise get from the cache if key in cdata.compiler_check_cache: -- cgit v1.1 From 1624354f33bf0a33f0e715ba1ca391ae0154ad19 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 15:12:36 -0500 Subject: Use CompileCheckMode enum There were a ton of naked strings with TODOs telling us to use the enum. --- mesonbuild/compilers/compilers.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 286406d..22865d8 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -516,7 +516,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): language: str id: str warn_args: T.Dict[str, T.List[str]] - mode: str = 'COMPILER' + mode = CompileCheckMode.COMPILE def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice, info: 'MachineInfo', @@ -790,21 +790,19 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def has_multi_link_arguments(self, args: T.List[str], env: 'Environment') -> T.Tuple[bool, bool]: return self.linker.has_multi_arguments(args, env) - def _get_compile_output(self, dirname: str, mode: str) -> str: - # TODO: mode should really be an enum + def _get_compile_output(self, dirname: str, mode: CompileCheckMode) -> str: # In pre-processor mode, the output is sent to stdout and discarded - if mode == 'preprocess': + if mode == CompileCheckMode.PREPROCESS: return None # Extension only matters if running results; '.exe' is # guaranteed to be executable on every platform. - if mode == 'link': + if mode == CompileCheckMode.LINK: suffix = 'exe' else: suffix = 'obj' return os.path.join(dirname, 'output.' + suffix) def get_compiler_args_for_mode(self, mode: CompileCheckMode) -> T.List[str]: - # TODO: mode should really be an enum args: T.List[str] = [] args += self.get_always_args() if mode is CompileCheckMode.COMPILE: @@ -822,7 +820,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): @contextlib.contextmanager def compile(self, code: 'mesonlib.FileOrString', extra_args: T.Union[None, CompilerArgs, T.List[str]] = None, - *, mode: str = 'link', want_output: bool = False, + *, mode: CompileCheckMode = CompileCheckMode.LINK, want_output: bool = False, temp_dir: T.Optional[str] = None) -> T.Iterator[T.Optional[CompileResult]]: # TODO: there isn't really any reason for this to be a contextmanager if extra_args is None: @@ -852,7 +850,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): # Preprocess mode outputs to stdout, so no output args output = self._get_compile_output(tmpdirname, mode) - if mode != 'preprocess': + if mode != CompileCheckMode.PREPROCESS: commands += self.get_output_args(output) commands.extend(self.get_compiler_args_for_mode(CompileCheckMode(mode))) @@ -880,7 +878,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): @contextlib.contextmanager def cached_compile(self, code: 'mesonlib.FileOrString', cdata: coredata.CoreData, *, extra_args: T.Union[None, T.List[str], CompilerArgs] = None, - mode: str = 'link', + mode: CompileCheckMode = CompileCheckMode.LINK, temp_dir: T.Optional[str] = None) -> T.Iterator[T.Optional[CompileResult]]: # TODO: There's isn't really any reason for this to be a context manager @@ -1289,7 +1287,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def _build_wrapper(self, code: 'mesonlib.FileOrString', env: 'Environment', extra_args: T.Union[None, CompilerArgs, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, - mode: str = 'compile', want_output: bool = False, + mode: CompileCheckMode = CompileCheckMode.COMPILE, want_output: bool = False, disable_cache: bool = False, temp_dir: str = None) -> T.Iterator[T.Optional[CompileResult]]: """Helper for getting a cached value when possible. @@ -1297,7 +1295,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): This method isn't meant to be called externally, it's mean to be wrapped by other methods like compiles() and links(). """ - args = self.build_wrapper_args(env, extra_args, dependencies, CompileCheckMode(mode)) + args = self.build_wrapper_args(env, extra_args, dependencies, mode) if disable_cache or want_output: with self.compile(code, extra_args=args, mode=mode, want_output=want_output, temp_dir=env.scratch_dir) as r: yield r @@ -1308,7 +1306,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def compiles(self, code: 'mesonlib.FileOrString', env: 'Environment', *, extra_args: T.Union[None, T.List[str], CompilerArgs, T.Callable[[CompileCheckMode], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, - mode: str = 'compile', + mode: CompileCheckMode = CompileCheckMode.COMPILE, disable_cache: bool = False) -> T.Tuple[bool, bool]: with self._build_wrapper(code, env, extra_args, dependencies, mode, disable_cache=disable_cache) as p: return p.returncode == 0, p.cached @@ -1317,16 +1315,15 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): compiler: T.Optional['Compiler'] = None, extra_args: T.Union[None, T.List[str], CompilerArgs, T.Callable[[CompileCheckMode], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, - mode: str = 'compile', disable_cache: bool = False) -> T.Tuple[bool, bool]: if compiler: with compiler._build_wrapper(code, env, dependencies=dependencies, want_output=True) as r: objfile = mesonlib.File.from_absolute_file(r.output_name) return self.compiles(objfile, env, extra_args=extra_args, - dependencies=dependencies, mode='link', disable_cache=True) + dependencies=dependencies, mode=CompileCheckMode.LINK, disable_cache=True) return self.compiles(code, env, extra_args=extra_args, - dependencies=dependencies, mode='link', disable_cache=disable_cache) + dependencies=dependencies, mode=CompileCheckMode.LINK, disable_cache=disable_cache) def get_feature_args(self, kwargs: T.Dict[str, T.Any], build_to_src: str) -> T.List[str]: """Used by D for extra language features.""" -- cgit v1.1 From 921c2370a722cbaa42bd256c699fae3185084939 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:36:25 -0500 Subject: Replace some type comments with annotations --- mesonbuild/compilers/compilers.py | 135 ++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 63 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 22865d8..3789363 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -190,68 +190,77 @@ class CompileCheckMode(enum.Enum): LINK = 'link' -cuda_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': ['-g', '-G'], - 'debugoptimized': ['-g', '-lineinfo'], - 'release': [], - 'minsize': [], - 'custom': [], - } -java_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': ['-g'], - 'debugoptimized': ['-g'], - 'release': [], - 'minsize': [], - 'custom': [], - } - -rust_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': [], - 'release': [], - 'minsize': [], - 'custom': [], - } - -d_gdc_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-finline-functions'], - 'release': ['-finline-functions'], - 'minsize': [], - 'custom': [], - } - -d_ldc_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'], - 'release': ['-enable-inlining', '-Hkeep-all-bodies'], - 'minsize': [], - 'custom': [], - } - -d_dmd_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-inline'], - 'release': ['-inline'], - 'minsize': [], - 'custom': [], - } - -mono_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': ['-optimize+'], - 'release': ['-optimize+'], - 'minsize': [], - 'custom': [], - } - -swift_buildtype_args: T.Dict[str, T.List[str]] = {'plain': [], - 'debug': [], - 'debugoptimized': [], - 'release': [], - 'minsize': [], - 'custom': [], - } +cuda_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': ['-g', '-G'], + 'debugoptimized': ['-g', '-lineinfo'], + 'release': [], + 'minsize': [], + 'custom': [], +} + +java_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': ['-g'], + 'debugoptimized': ['-g'], + 'release': [], + 'minsize': [], + 'custom': [], +} + +rust_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': [], + 'release': [], + 'minsize': [], + 'custom': [], +} + +d_gdc_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-finline-functions'], + 'release': ['-finline-functions'], + 'minsize': [], + 'custom': [], +} + +d_ldc_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'], + 'release': ['-enable-inlining', '-Hkeep-all-bodies'], + 'minsize': [], + 'custom': [], +} + +d_dmd_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-inline'], + 'release': ['-inline'], + 'minsize': [], + 'custom': [], +} + +mono_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': ['-optimize+'], + 'release': ['-optimize+'], + 'minsize': [], + 'custom': [], +} + +swift_buildtype_args: T.Dict[str, T.List[str]] = { + 'plain': [], + 'debug': [], + 'debugoptimized': [], + 'release': [], + 'minsize': [], + 'custom': [], +} gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32', '-lole32', '-loleaut32', '-luuid', '-lcomdlg32', '-ladvapi32'] @@ -1017,7 +1026,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): rm_exact = ('-headerpad_max_install_names',) rm_prefixes = ('-Wl,', '-L',) rm_next = ('-L', '-framework',) - ret = [] # T.List[str] + ret: T.List[str] = [] iargs = iter(args) for arg in iargs: # Remove this argument -- cgit v1.1 From d4bcf05c39e650d9651b5f2c60e7c12d59367e9c Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:47:12 -0500 Subject: Annotate naked fundamental Python types Although mypy wasn't complaining, pyright was. --- mesonbuild/compilers/compilers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 3789363..56ed2d5 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -537,7 +537,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): if not hasattr(self, 'file_suffixes'): self.file_suffixes = lang_suffixes[self.language] if not hasattr(self, 'can_compile_suffixes'): - self.can_compile_suffixes = set(self.file_suffixes) + self.can_compile_suffixes: T.Set[str] = set(self.file_suffixes) self.default_suffix = self.file_suffixes[0] self.version = version self.full_version = full_version -- cgit v1.1 From 9e8a034ade51d45cd43268b38c15a73786e15d05 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:50:50 -0500 Subject: Fix the typing around Compiler._get_compile_output() This function says it returns a string, but was returning None in some cases. --- mesonbuild/compilers/compilers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 56ed2d5..7873ea8 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -800,9 +800,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): return self.linker.has_multi_arguments(args, env) def _get_compile_output(self, dirname: str, mode: CompileCheckMode) -> str: - # In pre-processor mode, the output is sent to stdout and discarded - if mode == CompileCheckMode.PREPROCESS: - return None + assert mode != CompileCheckMode.PREPROCESS, 'In pre-processor mode, the output is sent to stdout and discarded' # Extension only matters if running results; '.exe' is # guaranteed to be executable on every platform. if mode == CompileCheckMode.LINK: @@ -832,6 +830,10 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): *, mode: CompileCheckMode = CompileCheckMode.LINK, want_output: bool = False, temp_dir: T.Optional[str] = None) -> T.Iterator[T.Optional[CompileResult]]: # TODO: there isn't really any reason for this to be a contextmanager + + if mode == CompileCheckMode.PREPROCESS: + assert not want_output, 'In pre-processor mode, the output is sent to stdout and discarded' + if extra_args is None: extra_args = [] @@ -858,8 +860,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): commands.append(srcname) # Preprocess mode outputs to stdout, so no output args - output = self._get_compile_output(tmpdirname, mode) if mode != CompileCheckMode.PREPROCESS: + output = self._get_compile_output(tmpdirname, mode) commands += self.get_output_args(output) commands.extend(self.get_compiler_args_for_mode(CompileCheckMode(mode))) -- cgit v1.1 From c1863f781bf56190ff00f081733c2cb1f2f73884 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 17:58:35 -0500 Subject: Remove Compiler._build_wrapper(temp_dir:) The function wasn't using the keyword argument and all the callers were using env.scratch_dir anyway. --- mesonbuild/compilers/compilers.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 7873ea8..4cbdb1f 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1299,8 +1299,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): extra_args: T.Union[None, CompilerArgs, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]] = None, dependencies: T.Optional[T.List['Dependency']] = None, mode: CompileCheckMode = CompileCheckMode.COMPILE, want_output: bool = False, - disable_cache: bool = False, - temp_dir: str = None) -> T.Iterator[T.Optional[CompileResult]]: + disable_cache: bool = False) -> T.Iterator[T.Optional[CompileResult]]: """Helper for getting a cached value when possible. This method isn't meant to be called externally, it's mean to be -- cgit v1.1 From 24edddb412dfa6cbf48d1c31b73d4d4903aa0fa0 Mon Sep 17 00:00:00 2001 From: Tristan Partin Date: Wed, 12 Jul 2023 18:15:27 -0500 Subject: Fix return type of debugfile functions It was returning None in some cases while being marked as returning string. --- mesonbuild/compilers/compilers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesonbuild/compilers/compilers.py') diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 4cbdb1f..cb8eae5 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -921,7 +921,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta): def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]: return [] - def get_link_debugfile_name(self, targetfile: str) -> str: + def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]: return self.linker.get_debugfile_name(targetfile) def get_link_debugfile_args(self, targetfile: str) -> T.List[str]: -- cgit v1.1