rust: Use Popen_safe() for sanity checks

pull/10714/merge
Xavier Claessens 2 years ago committed by Xavier Claessens
parent 6f4973abad
commit 01bb756484
  1. 13
      mesonbuild/compilers/rust.py

@ -80,16 +80,7 @@ class RustCompiler(Compiler):
''')) '''))
cmdlist = self.exelist + ['-o', output_name, source_name] cmdlist = self.exelist + ['-o', output_name, source_name]
pc = subprocess.Popen(cmdlist, pc, stdo, stde = Popen_safe(cmdlist, cwd=work_dir)
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=work_dir)
_stdo, _stde = pc.communicate()
assert isinstance(_stdo, bytes)
assert isinstance(_stde, bytes)
stdo = _stdo.decode('utf-8', errors='replace')
stde = _stde.decode('utf-8', errors='replace')
mlog.debug('Sanity check compiler command line:', join_args(cmdlist)) mlog.debug('Sanity check compiler command line:', join_args(cmdlist))
mlog.debug('Sanity check compile stdout:') mlog.debug('Sanity check compile stdout:')
mlog.debug(stdo) mlog.debug(stdo)
@ -108,7 +99,7 @@ class RustCompiler(Compiler):
pe = subprocess.Popen(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) pe = subprocess.Popen(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
pe.wait() pe.wait()
if pe.returncode != 0: if pe.returncode != 0:
raise EnvironmentException('Executables created by Rust compiler %s are not runnable.' % self.name_string()) raise EnvironmentException(f'Executables created by Rust compiler {self.name_string()} are not runnable.')
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]: def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return ['--dep-info', outfile] return ['--dep-info', outfile]

Loading…
Cancel
Save