[libc++] Make sure platform detection works in both Python 2 and 3

19123a3e08 was too naive -- we really want to handle both Python 2 and
Python 3, not only Python 3.
This commit is contained in:
Louis Dionne 2020-04-30 15:30:39 -04:00
parent e9827f0b82
commit ecd3ce0e5a
1 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ import re
import subprocess
import sys
from libcxx.util import executeCommand
from libcxx.util import executeCommand, to_string
class DefaultTargetInfo(object):
def __init__(self, full_config):
@ -91,12 +91,12 @@ class DarwinLocalTI(DefaultTargetInfo):
super(DarwinLocalTI, self).__init__(full_config)
def is_host_macosx(self):
name = subprocess.check_output(['sw_vers', '-productName']).decode().strip()
name = to_string(subprocess.check_output(['sw_vers', '-productName'])).strip()
return name == "Mac OS X"
def get_macosx_version(self):
assert self.is_host_macosx()
version = subprocess.check_output(['sw_vers', '-productVersion']).decode().strip()
version = to_string(subprocess.check_output(['sw_vers', '-productVersion'])).strip()
version = re.sub(r'([0-9]+\.[0-9]+)(\..*)?', r'\1', version)
return version