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.

common.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #######################################################################
  2. # Common SCons code
  3. import os
  4. import os.path
  5. import subprocess
  6. import sys
  7. import platform as _platform
  8. #######################################################################
  9. # Defaults
  10. _platform_map = {
  11. 'linux2': 'linux',
  12. 'win32': 'windows',
  13. }
  14. default_platform = sys.platform
  15. default_platform = _platform_map.get(default_platform, default_platform)
  16. _machine_map = {
  17. 'x86': 'x86',
  18. 'i386': 'x86',
  19. 'i486': 'x86',
  20. 'i586': 'x86',
  21. 'i686': 'x86',
  22. 'ppc' : 'ppc',
  23. 'x86_64': 'x86_64',
  24. }
  25. if 'PROCESSOR_ARCHITECTURE' in os.environ:
  26. default_machine = os.environ['PROCESSOR_ARCHITECTURE']
  27. else:
  28. default_machine = _platform.machine()
  29. default_machine = _machine_map.get(default_machine, 'generic')
  30. if 'LLVM' in os.environ:
  31. default_llvm = 'yes'
  32. else:
  33. default_llvm = 'no'
  34. try:
  35. if subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
  36. default_llvm = 'yes'
  37. except:
  38. pass
  39. if default_platform in ('linux', 'freebsd'):
  40. default_dri = 'yes'
  41. elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
  42. default_dri = 'no'
  43. else:
  44. default_dri = 'no'
  45. #######################################################################
  46. # Common options
  47. def AddOptions(opts):
  48. try:
  49. from SCons.Variables.BoolVariable import BoolVariable as BoolOption
  50. except ImportError:
  51. from SCons.Options.BoolOption import BoolOption
  52. try:
  53. from SCons.Variables.EnumVariable import EnumVariable as EnumOption
  54. except ImportError:
  55. from SCons.Options.EnumOption import EnumOption
  56. opts.Add(BoolOption('debug', 'debug build', 'yes'))
  57. opts.Add(BoolOption('profile', 'profile build', 'no'))
  58. opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
  59. opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
  60. allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
  61. opts.Add(EnumOption('platform', 'target platform', default_platform,
  62. allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded')))
  63. opts.Add('toolchain', 'compiler toolchain', 'default')
  64. opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
  65. opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))