Merge pull request #1092 from centricular/always-use-utf-8-py3
Always use utf-8 to write configured file and warn if the encoding is not UTF-8 compatible
This commit is contained in:
commit
88d7898bb4
15
meson.py
15
meson.py
|
@ -14,10 +14,21 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from mesonbuild import mesonmain
|
from mesonbuild import mlog, mesonmain
|
||||||
import sys, os
|
import sys, os, locale
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# Warn if the locale is not UTF-8. This can cause various unfixable issues
|
||||||
|
# such as os.stat not being able to decode filenames with unicode in them.
|
||||||
|
# There is no way to reset both the preferred encoding and the filesystem
|
||||||
|
# encoding, so we can just warn about it.
|
||||||
|
e = locale.getpreferredencoding()
|
||||||
|
if e.upper() != 'UTF-8':
|
||||||
|
mlog.warning('You are using {!r} which is not a a Unicode-compatible '
|
||||||
|
'locale.'.format(e))
|
||||||
|
mlog.warning('You might see errors if you use UTF-8 strings as '
|
||||||
|
'filenames, as strings, or as file contents.')
|
||||||
|
mlog.warning('Please switch to a UTF-8 locale for your platform.')
|
||||||
# Always resolve the command path so Ninja can find it for regen, tests, etc.
|
# Always resolve the command path so Ninja can find it for regen, tests, etc.
|
||||||
launcher = os.path.realpath(sys.argv[0])
|
launcher = os.path.realpath(sys.argv[0])
|
||||||
return mesonmain.run(launcher, sys.argv[1:])
|
return mesonmain.run(launcher, sys.argv[1:])
|
||||||
|
|
|
@ -303,7 +303,7 @@ def do_conf_file(src, dst, confdata):
|
||||||
replace_if_different(dst, dst_tmp)
|
replace_if_different(dst, dst_tmp)
|
||||||
|
|
||||||
def dump_conf_header(ofilename, cdata):
|
def dump_conf_header(ofilename, cdata):
|
||||||
with open(ofilename, 'w') as ofile:
|
with open(ofilename, 'w', encoding='utf-8') as ofile:
|
||||||
ofile.write('''/*
|
ofile.write('''/*
|
||||||
* Autogenerated by the Meson build system.
|
* Autogenerated by the Meson build system.
|
||||||
* Do not edit, your changes will be lost.
|
* Do not edit, your changes will be lost.
|
||||||
|
|
Loading…
Reference in New Issue