Clone of mesa.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

common.py 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #######################################################################
  2. # Common SCons code
  3. import os
  4. import os.path
  5. import re
  6. import subprocess
  7. import sys
  8. import platform as _platform
  9. #######################################################################
  10. # Defaults
  11. _platform_map = {
  12. 'linux2': 'linux',
  13. 'win32': 'windows',
  14. }
  15. default_platform = sys.platform
  16. default_platform = _platform_map.get(default_platform, default_platform)
  17. _machine_map = {
  18. 'x86': 'x86',
  19. 'i386': 'x86',
  20. 'i486': 'x86',
  21. 'i586': 'x86',
  22. 'i686': 'x86',
  23. 'ppc' : 'ppc',
  24. 'x86_64': 'x86_64',
  25. }
  26. # find default_machine value
  27. if 'PROCESSOR_ARCHITECTURE' in os.environ:
  28. default_machine = os.environ['PROCESSOR_ARCHITECTURE']
  29. else:
  30. default_machine = _platform.machine()
  31. default_machine = _machine_map.get(default_machine, 'generic')
  32. # find default_llvm value
  33. if 'LLVM' in os.environ:
  34. default_llvm = 'yes'
  35. else:
  36. # Search sys.argv[] for a "platform=foo" argument since we don't have
  37. # an 'env' variable at this point.
  38. platform = default_platform
  39. pattern = re.compile("(platform=)(.*)")
  40. for arg in sys.argv:
  41. m = pattern.match(arg)
  42. if m:
  43. platform = m.group(2)
  44. default_llvm = 'no'
  45. try:
  46. if platform != 'windows' and subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
  47. default_llvm = 'yes'
  48. except:
  49. pass
  50. # find default_dri value
  51. if default_platform in ('linux', 'freebsd'):
  52. default_dri = 'yes'
  53. elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
  54. default_dri = 'no'
  55. else:
  56. default_dri = 'no'
  57. #######################################################################
  58. # Common options
  59. def AddOptions(opts):
  60. try:
  61. from SCons.Variables.BoolVariable import BoolVariable as BoolOption
  62. except ImportError:
  63. from SCons.Options.BoolOption import BoolOption
  64. try:
  65. from SCons.Variables.EnumVariable import EnumVariable as EnumOption
  66. except ImportError:
  67. from SCons.Options.EnumOption import EnumOption
  68. opts.Add(BoolOption('debug', 'debug build', 'yes'))
  69. opts.Add(BoolOption('profile', 'profile build', 'no'))
  70. opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
  71. opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
  72. allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
  73. opts.Add(EnumOption('platform', 'target platform', default_platform,
  74. allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded', 'cygwin')))
  75. opts.Add('toolchain', 'compiler toolchain', 'default')
  76. opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
  77. opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))