aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/meson_exe.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-12-07 07:03:15 +0530
committerJussi Pakkanen <jpakkane@gmail.com>2016-12-11 01:59:58 +0200
commit60716fcd6debd9f1ebca0091c945df16a3bd3715 (patch)
tree75b1444898aabcd90b9e4731f4eb1d56a078c790 /mesonbuild/scripts/meson_exe.py
parentbe04aa2a0b00d123aae78da2448a216f7e3201b9 (diff)
downloadmeson-60716fcd6debd9f1ebca0091c945df16a3bd3715.zip
meson-60716fcd6debd9f1ebca0091c945df16a3bd3715.tar.gz
meson-60716fcd6debd9f1ebca0091c945df16a3bd3715.tar.bz2
Use universal_newlines=True for all Popen calls
Instead of adding it everywhere manually, create a wrapper called mesonlib.Popen_safe and use that everywhere that we call an executable and extract its output. This will also allow us to tweak it to do more/different things if needed for some locales and/or systems. Closes #1079
Diffstat (limited to 'mesonbuild/scripts/meson_exe.py')
-rwxr-xr-xmesonbuild/scripts/meson_exe.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/mesonbuild/scripts/meson_exe.py b/mesonbuild/scripts/meson_exe.py
index 3ea3926..d412e01 100755
--- a/mesonbuild/scripts/meson_exe.py
+++ b/mesonbuild/scripts/meson_exe.py
@@ -21,7 +21,7 @@ import pickle
import platform
import subprocess
-import mesonbuild
+from ..mesonlib import MesonException, Popen_safe
options = None
@@ -45,7 +45,7 @@ def run_exe(exe):
else:
if exe.is_cross:
if exe.exe_runner is None:
- raise Exception('BUG: Trying to run cross-compiled exes with no wrapper')
+ raise AssertionError('BUG: Trying to run cross-compiled exes with no wrapper')
else:
cmd = [exe.exe_runner] + exe.fname
else:
@@ -55,17 +55,12 @@ def run_exe(exe):
if len(exe.extra_paths) > 0:
child_env['PATH'] = (os.pathsep.join(exe.extra_paths + ['']) +
child_env['PATH'])
- p = subprocess.Popen(cmd + exe.cmd_args,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- env=child_env,
- cwd=exe.workdir)
- stdout, stderr = p.communicate()
+ p, stdout, stderr = Popen_safe(cmd + exe.cmd_args, env=child_env, cwd=exe.workdir)
if exe.capture and p.returncode == 0:
- with open(exe.capture, 'wb') as output:
+ with open(exe.capture, 'w') as output:
output.write(stdout)
if stderr:
- sys.stderr.buffer.write(stderr)
+ sys.stderr.write(stderr)
return p.returncode
def run(args):