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()
This commit is contained in:
parent
f2ad800408
commit
5da1a6e586
|
@ -15,21 +15,22 @@
|
||||||
# This class contains the basic functionality needed to run any interpreter
|
# This class contains the basic functionality needed to run any interpreter
|
||||||
# or an interpreter-based tool.
|
# or an interpreter-based tool.
|
||||||
|
|
||||||
from .. import mlog, mesonlib
|
import subprocess
|
||||||
from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice
|
|
||||||
from ..environment import Environment
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Tuple, Optional, TYPE_CHECKING
|
from typing import List, Tuple, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from ..dependencies.base import ExternalProgram
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
||||||
|
from .. import mlog, mesonlib
|
||||||
|
from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice
|
||||||
|
from ..environment import Environment
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..dependencies.base import ExternalProgram
|
||||||
|
|
||||||
|
|
||||||
class CMakeExecutor:
|
class CMakeExecutor:
|
||||||
# The class's copy of the CMake path. Avoids having to search for it
|
# The class's copy of the CMake path. Avoids having to search for it
|
||||||
# multiple times in the same Meson invocation.
|
# multiple times in the same Meson invocation.
|
||||||
|
@ -137,8 +138,12 @@ class CMakeExecutor:
|
||||||
def _call_real(self, args: List[str], build_dir: str, env) -> Tuple[int, str, str]:
|
def _call_real(self, args: List[str], build_dir: str, env) -> Tuple[int, str, str]:
|
||||||
os.makedirs(build_dir, exist_ok=True)
|
os.makedirs(build_dir, exist_ok=True)
|
||||||
cmd = self.cmakebin.get_command() + args
|
cmd = self.cmakebin.get_command() + args
|
||||||
p, out, err = Popen_safe(cmd, env=env, cwd=build_dir)
|
ret = subprocess.run(cmd, env=env, cwd=build_dir, close_fds=False,
|
||||||
rc = p.returncode
|
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)
|
call = ' '.join(cmd)
|
||||||
mlog.debug("Called `{}` in {} -> {}".format(call, build_dir, rc))
|
mlog.debug("Called `{}` in {} -> {}".format(call, build_dir, rc))
|
||||||
return rc, out, err
|
return rc, out, err
|
||||||
|
|
Loading…
Reference in New Issue