diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 56ed2d52b..7873ea8a9 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))) diff --git a/mesonbuild/compilers/mixins/emscripten.py b/mesonbuild/compilers/mixins/emscripten.py index a07cff3cd..fef22b907 100644 --- a/mesonbuild/compilers/mixins/emscripten.py +++ b/mesonbuild/compilers/mixins/emscripten.py @@ -48,9 +48,7 @@ def wrap_js_includes(args: T.List[str]) -> T.List[str]: class EmscriptenMixin(Compiler): 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' # Unlike sane toolchains, emcc infers the kind of output from its name. # This is the only reason why this method is overridden; compiler tests # do not work well with the default exe/obj suffices.