Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

meson-options.py 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env python3
  2. from os import get_terminal_size
  3. from textwrap import wrap
  4. from mesonbuild import coredata
  5. from mesonbuild import optinterpreter
  6. (COLUMNS, _) = get_terminal_size()
  7. def describe_option(option_name: str, option_default_value: str,
  8. option_type: str, option_message: str) -> None:
  9. print('name: ' + option_name)
  10. print('default: ' + option_default_value)
  11. print('type: ' + option_type)
  12. for line in wrap(option_message, width=COLUMNS - 9):
  13. print(' ' + line)
  14. print('---')
  15. oi = optinterpreter.OptionInterpreter('')
  16. oi.process('meson_options.txt')
  17. for (name, value) in oi.options.items():
  18. if isinstance(value, coredata.UserStringOption):
  19. describe_option(name,
  20. value.value,
  21. 'string',
  22. "You can type what you want, but make sure it makes sense")
  23. elif isinstance(value, coredata.UserBooleanOption):
  24. describe_option(name,
  25. 'true' if value.value else 'false',
  26. 'boolean',
  27. "You can set it to 'true' or 'false'")
  28. elif isinstance(value, coredata.UserIntegerOption):
  29. describe_option(name,
  30. str(value.value),
  31. 'integer',
  32. "You can set it to any integer value between '{}' and '{}'".format(value.min_value, value.max_value))
  33. elif isinstance(value, coredata.UserUmaskOption):
  34. describe_option(name,
  35. str(value.value),
  36. 'umask',
  37. "You can set it to 'preserve' or a value between '0000' and '0777'")
  38. elif isinstance(value, coredata.UserComboOption):
  39. choices = '[' + ', '.join(["'" + v + "'" for v in value.choices]) + ']'
  40. describe_option(name,
  41. value.value,
  42. 'combo',
  43. "You can set it to any one of those values: " + choices)
  44. elif isinstance(value, coredata.UserArrayOption):
  45. choices = '[' + ', '.join(["'" + v + "'" for v in value.choices]) + ']'
  46. value = '[' + ', '.join(["'" + v + "'" for v in value.value]) + ']'
  47. describe_option(name,
  48. value,
  49. 'array',
  50. "You can set it to one or more of those values: " + choices)
  51. elif isinstance(value, coredata.UserFeatureOption):
  52. describe_option(name,
  53. value.value,
  54. 'feature',
  55. "You can set it to 'auto', 'enabled', or 'disabled'")
  56. else:
  57. print(name + ' is an option of a type unknown to this script')
  58. print('---')