configure: always use shlex instead of split

Use shlex module instead of builtin string split to parse CC.
This commit is contained in:
Alex Xu 2012-09-14 21:06:25 -04:00 committed by Ben Noordhuis
parent 3806cf0d64
commit fb6c314b6d

8
configure vendored
View File

@ -3,6 +3,7 @@ import optparse
import os import os
import pprint import pprint
import re import re
import shlex
import subprocess import subprocess
import sys import sys
@ -205,7 +206,7 @@ def cc_macros():
"""Checks predefined macros using the CC command.""" """Checks predefined macros using the CC command."""
try: try:
p = subprocess.Popen(CC.split() + ['-dM', '-E', '-'], p = subprocess.Popen(shlex.split(CC) + ['-dM', '-E', '-'],
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
@ -225,7 +226,6 @@ def cc_macros():
k = {} k = {}
for line in out: for line in out:
import shlex
lst = shlex.split(line) lst = shlex.split(line)
if len(lst) > 2: if len(lst) > 2:
key = lst[1] key = lst[1]
@ -310,13 +310,13 @@ def host_arch_win():
def compiler_version(): def compiler_version():
try: try:
proc = subprocess.Popen(CC.split() + ['--version'], stdout=subprocess.PIPE) proc = subprocess.Popen(shlex.split(CC) + ['--version'], stdout=subprocess.PIPE)
except WindowsError: except WindowsError:
return (0, False) return (0, False)
is_clang = 'clang' in proc.communicate()[0].split('\n')[0] is_clang = 'clang' in proc.communicate()[0].split('\n')[0]
proc = subprocess.Popen(CC.split() + ['-dumpversion'], stdout=subprocess.PIPE) proc = subprocess.Popen(shlex.split(CC) + ['-dumpversion'], stdout=subprocess.PIPE)
version = tuple(map(int, proc.communicate()[0].split('.'))) version = tuple(map(int, proc.communicate()[0].split('.')))
return (version, is_clang) return (version, is_clang)