aboutsummaryrefslogtreecommitdiff
path: root/meson.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-11-26 12:57:17 -0500
committerGitHub <noreply@github.com>2016-11-26 12:57:17 -0500
commit88d7898bb4b52e3e3dc2af58c8a346b7592c894e (patch)
tree9a7a5ad28d86e22d8213f583f97f875d402bd8bf /meson.py
parent09fd24ea78876924c16d9d029f4ade6d53e85c8b (diff)
parent34394afce6db988800cfecbfa32b67301fd7ba3d (diff)
downloadmeson-88d7898bb4b52e3e3dc2af58c8a346b7592c894e.zip
meson-88d7898bb4b52e3e3dc2af58c8a346b7592c894e.tar.gz
meson-88d7898bb4b52e3e3dc2af58c8a346b7592c894e.tar.bz2
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
Diffstat (limited to 'meson.py')
-rwxr-xr-xmeson.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/meson.py b/meson.py
index 8c223e5..6dc5c7a 100755
--- a/meson.py
+++ b/meson.py
@@ -14,10 +14,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from mesonbuild import mesonmain
-import sys, os
+from mesonbuild import mlog, mesonmain
+import sys, os, locale
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.
launcher = os.path.realpath(sys.argv[0])
return mesonmain.run(launcher, sys.argv[1:])