Bug 1575135 - Define whether the system encoding is mbcs or utf-8 once. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D42601
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
|
||||
@imports('codecs')
|
||||
@imports('sys')
|
||||
@imports(_from='mozbuild.util', _import='system_encoding')
|
||||
def encoded_open(path, mode):
|
||||
encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
|
||||
return codecs.open(path, mode, encoding)
|
||||
return codecs.open(path, mode, system_encoding)
|
||||
|
||||
|
||||
option(env='AUTOCONF', nargs=1, help='Path to autoconf 2.13')
|
||||
|
||||
@@ -604,10 +604,9 @@ def check_compiler(compiler, language, target):
|
||||
@imports('json')
|
||||
@imports('os')
|
||||
@imports('subprocess')
|
||||
@imports('sys')
|
||||
@imports(_from='mozbuild.util', _import='system_encoding')
|
||||
def get_vc_paths(topsrcdir):
|
||||
def vswhere(args):
|
||||
encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
|
||||
program_files = (os.environ.get('PROGRAMFILES(X86)') or
|
||||
os.environ.get('PROGRAMFILES'))
|
||||
if not program_files:
|
||||
@@ -618,7 +617,7 @@ def get_vc_paths(topsrcdir):
|
||||
return []
|
||||
return json.loads(
|
||||
subprocess.check_output([vswhere, '-format', 'json'] + args)
|
||||
.decode(encoding, 'replace'))
|
||||
.decode(system_encoding, 'replace'))
|
||||
|
||||
for install in vswhere(['-products', '*', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']):
|
||||
path = install['installationPath']
|
||||
|
||||
@@ -24,6 +24,7 @@ from mozbuild.backend.configenvironment import PartialConfigEnvironment
|
||||
from mozbuild.util import (
|
||||
indented_repr,
|
||||
encode,
|
||||
system_encoding,
|
||||
)
|
||||
import mozpack.path as mozpath
|
||||
|
||||
@@ -74,15 +75,14 @@ def config_status(config):
|
||||
# here, when we're able to skip configure tests/use cached results/not rely
|
||||
# on autoconf.
|
||||
logging.getLogger('moz.configure').info('Creating config.status')
|
||||
encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
|
||||
with codecs.open('config.status', 'w', encoding) as fh:
|
||||
with codecs.open('config.status', 'w', system_encoding) as fh:
|
||||
fh.write(textwrap.dedent('''\
|
||||
#!%(python)s
|
||||
# coding=%(encoding)s
|
||||
from __future__ import unicode_literals
|
||||
from mozbuild.util import encode
|
||||
encoding = '%(encoding)s'
|
||||
''') % {'python': config['PYTHON'], 'encoding': encoding})
|
||||
''') % {'python': config['PYTHON'], 'encoding': system_encoding})
|
||||
# A lot of the build backend code is currently expecting byte
|
||||
# strings and breaks in subtle ways with unicode strings. (bug 1296508)
|
||||
for k, v in sanitized_config.iteritems():
|
||||
@@ -125,7 +125,7 @@ def config_status(config):
|
||||
|
||||
# A lot of the build backend code is currently expecting byte strings
|
||||
# and breaks in subtle ways with unicode strings.
|
||||
return config_status(args=[], **encode(sanitized_config, encoding))
|
||||
return config_status(args=[], **encode(sanitized_config, system_encoding))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ from mozbuild.util import (
|
||||
FileAvoidWrite,
|
||||
memoized_property,
|
||||
ReadOnlyDict,
|
||||
system_encoding,
|
||||
)
|
||||
from mozbuild.shellutil import quote as shell_quote
|
||||
|
||||
@@ -252,10 +253,9 @@ class PartialConfigDict(object):
|
||||
return existing_files
|
||||
|
||||
def _write_file(self, key, value):
|
||||
encoding = 'mbcs' if sys.platform == 'win32' else 'utf-8'
|
||||
filename = mozpath.join(self._datadir, key)
|
||||
with FileAvoidWrite(filename) as fh:
|
||||
json.dump(value, fh, indent=4, encoding=encoding)
|
||||
json.dump(value, fh, indent=4, encoding=system_encoding)
|
||||
return filename
|
||||
|
||||
def _fill_group(self, values):
|
||||
|
||||
@@ -12,6 +12,7 @@ import subprocess
|
||||
import traceback
|
||||
|
||||
from mozpack import path as mozpath
|
||||
from mozbuild.util import system_encoding
|
||||
|
||||
|
||||
MOZ_MYCONFIG_ERROR = '''
|
||||
@@ -356,8 +357,7 @@ class MozconfigLoader(object):
|
||||
# XXX This is an ugly hack. Data may be lost from things
|
||||
# like environment variable values.
|
||||
# See https://bugzilla.mozilla.org/show_bug.cgi?id=831381
|
||||
line = line.decode('mbcs' if sys.platform == 'win32' else 'utf-8',
|
||||
'ignore')
|
||||
line = line.decode(system_encoding, 'ignore')
|
||||
|
||||
if not line:
|
||||
continue
|
||||
|
||||
@@ -35,6 +35,9 @@ from io import (
|
||||
if sys.platform == 'win32':
|
||||
_kernel32 = ctypes.windll.kernel32
|
||||
_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x2000
|
||||
system_encoding = 'mbcs'
|
||||
else:
|
||||
system_encoding = 'utf-8'
|
||||
|
||||
|
||||
def exec_(object, globals=None, locals=None):
|
||||
|
||||
Reference in New Issue
Block a user