aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend
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/backend
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/backend')
-rw-r--r--mesonbuild/backend/ninjabackend.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index e11491f..c95ee18 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -18,7 +18,7 @@ from .. import build
from .. import mlog
from .. import dependencies
from .. import compilers
-from ..mesonlib import File, MesonException, get_compiler_for_source
+from ..mesonlib import File, MesonException, get_compiler_for_source, Popen_safe
from .backends import InstallData
from ..build import InvalidArguments
import os, sys, pickle, re
@@ -159,18 +159,14 @@ class NinjaBackend(backends.Backend):
int dummy;
''')
- pc = subprocess.Popen(['cl', '/showIncludes', '/c', 'incdetect.c'],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- cwd=self.environment.get_scratch_dir())
+ pc, stdo = Popen_safe(['cl', '/showIncludes', '/c', 'incdetect.c'],
+ cwd=self.environment.get_scratch_dir())[0:2]
- (stdo, _) = pc.communicate()
-
- for line in stdo.split(b'\r\n'):
- if line.endswith(b'stdio.h'):
- matchstr = b':'.join(line.split(b':')[0:2]) + b':'
- with open(tempfilename, 'ab') as binfile:
- binfile.write(b'msvc_deps_prefix = ' + matchstr + b'\r\n')
+ for line in stdo.split('\n'):
+ if line.endswith('stdio.h'):
+ matchstr = ':'.join(line.split(':')[0:2]) + ':'
+ with open(tempfilename, 'a') as binfile:
+ binfile.write('msvc_deps_prefix = ' + matchstr + '\n')
return open(tempfilename, 'a')
raise MesonException('Could not determine vs dep dependency prefix string.')