meson.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python3
  2. # Copyright 2016 The Meson development team
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. from mesonbuild import mesonmain, mesonlib
  13. import sys, os, locale
  14. def main():
  15. # Warn if the locale is not UTF-8. This can cause various unfixable issues
  16. # such as os.stat not being able to decode filenames with unicode in them.
  17. # There is no way to reset both the preferred encoding and the filesystem
  18. # encoding, so we can just warn about it.
  19. e = locale.getpreferredencoding()
  20. if e.upper() != 'UTF-8' and not mesonlib.is_windows():
  21. print('Warning: You are using {!r} which is not a Unicode-compatible '
  22. 'locale.'.format(e), file=sys.stderr)
  23. print('You might see errors if you use UTF-8 strings as '
  24. 'filenames, as strings, or as file contents.', file=sys.stderr)
  25. print('Please switch to a UTF-8 locale for your platform.', file=sys.stderr)
  26. # Always resolve the command path so Ninja can find it for regen, tests, etc.
  27. launcher = os.path.realpath(sys.argv[0])
  28. return mesonmain.run(sys.argv[1:], launcher)
  29. if __name__ == '__main__':
  30. sys.exit(main())