diff options
author | Michael Hirsch, Ph.D <scivision@users.noreply.github.com> | 2019-12-09 21:15:24 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-12-10 19:57:51 +0200 |
commit | 5da1a6e5867bda70fcdc371933b74fea6adc3f86 (patch) | |
tree | 85dee6370256a95942e8191e18daa94bd0aaf4dc | |
parent | f2ad800408d5d6ec557c81442194ab9f98e0b40f (diff) | |
download | meson-5da1a6e5867bda70fcdc371933b74fea6adc3f86.zip meson-5da1a6e5867bda70fcdc371933b74fea6adc3f86.tar.gz meson-5da1a6e5867bda70fcdc371933b74fea6adc3f86.tar.bz2 |
cmake: subprocess external .decode(errors='ignore') to avoid traceback
mesonlib.Popen_safe() doesn't work with the case where undecodeable
binary data comes back from CMake or compiler, so we use subprocess.run()
-rw-r--r-- | mesonbuild/cmake/executor.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index 1271390..4300656 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -15,20 +15,21 @@ # This class contains the basic functionality needed to run any interpreter # or an interpreter-based tool. +import subprocess +from pathlib import Path +from typing import List, Tuple, Optional, TYPE_CHECKING +import re +import os +import shutil +import ctypes + from .. import mlog, mesonlib from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice from ..environment import Environment -from pathlib import Path -from typing import List, Tuple, Optional, TYPE_CHECKING - if TYPE_CHECKING: from ..dependencies.base import ExternalProgram -import re -import os -import shutil -import ctypes class CMakeExecutor: # The class's copy of the CMake path. Avoids having to search for it @@ -137,8 +138,12 @@ class CMakeExecutor: def _call_real(self, args: List[str], build_dir: str, env) -> Tuple[int, str, str]: os.makedirs(build_dir, exist_ok=True) cmd = self.cmakebin.get_command() + args - p, out, err = Popen_safe(cmd, env=env, cwd=build_dir) - rc = p.returncode + ret = subprocess.run(cmd, env=env, cwd=build_dir, close_fds=False, + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=False) + rc = ret.returncode + out = ret.stdout.decode(errors='ignore') + err = ret.stderr.decode(errors='ignore') call = ' '.join(cmd) mlog.debug("Called `{}` in {} -> {}".format(call, build_dir, rc)) return rc, out, err |