Bug 1362872 - Use mbcs encoding for vswhere output. r=gps

We add vswhere.exe to support VS2017.  But the description output of this command is localized, so it causes UnicodeDecodeError.

So we should use 'mbcs' encoding for this output on Windows platform. And for minor languages, we should also use replace to avoid decode error.

test_toolchain_configure.py calls vc_compiler_path without correct host.kernel, so we should check current python platform.


MozReview-Commit-ID: AkryAzrgSzs

--HG--
extra : rebase_source : 76f2584fa3890e3c11f5ee023b2359a9a19beb16
This commit is contained in:
Makoto Kato 2017-05-08 15:31:44 +09:00
Родитель 5c07c624f4
Коммит b6736b3728
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -413,9 +413,11 @@ def check_compiler(compiler, language, target):
@imports(_from='__builtin__', _import='open')
@imports('json')
@imports('subprocess')
@imports('sys')
def get_vc_paths(topsrcdir):
def vswhere(args):
return json.loads(subprocess.check_output([os.path.join(topsrcdir, 'build/win32/vswhere.exe'), '-format', 'json'] + args))
encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
return json.loads(subprocess.check_output([os.path.join(topsrcdir, 'build/win32/vswhere.exe'), '-format', 'json'] + args).decode(encoding, 'replace'))
# Can't pass -requires with -legacy, so query each separately.
# Legacy versions first (VS2015)