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.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. import SCons.Script.SConscript
  10. #######################################################################
  11. # Defaults
  12. host_platform = _platform.system().lower()
  13. # Search sys.argv[] for a "platform=foo" argument since we don't have
  14. # an 'env' variable at this point.
  15. if 'platform' in SCons.Script.ARGUMENTS:
  16. target_platform = SCons.Script.ARGUMENTS['platform']
  17. else:
  18. target_platform = host_platform
  19. _machine_map = {
  20. 'x86': 'x86',
  21. 'i386': 'x86',
  22. 'i486': 'x86',
  23. 'i586': 'x86',
  24. 'i686': 'x86',
  25. 'ppc' : 'ppc',
  26. 'x86_64': 'x86_64',
  27. }
  28. # find host_machine value
  29. if 'PROCESSOR_ARCHITECTURE' in os.environ:
  30. host_machine = os.environ['PROCESSOR_ARCHITECTURE']
  31. else:
  32. host_machine = _platform.machine()
  33. host_machine = _machine_map.get(host_machine, 'generic')
  34. default_machine = host_machine
  35. default_toolchain = 'default'
  36. if target_platform == 'windows' and host_platform != 'windows':
  37. default_machine = 'x86'
  38. default_toolchain = 'crossmingw'
  39. # find default_llvm value
  40. if 'LLVM' in os.environ:
  41. default_llvm = 'yes'
  42. else:
  43. default_llvm = 'no'
  44. try:
  45. if target_platform != 'windows' and \
  46. subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
  47. default_llvm = 'yes'
  48. except:
  49. pass
  50. #######################################################################
  51. # Common options
  52. def AddOptions(opts):
  53. try:
  54. from SCons.Variables.BoolVariable import BoolVariable as BoolOption
  55. except ImportError:
  56. from SCons.Options.BoolOption import BoolOption
  57. try:
  58. from SCons.Variables.EnumVariable import EnumVariable as EnumOption
  59. except ImportError:
  60. from SCons.Options.EnumOption import EnumOption
  61. opts.Add(EnumOption('build', 'build type', 'debug',
  62. allowed_values=('debug', 'checked', 'profile', 'release')))
  63. opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
  64. opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
  65. allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
  66. opts.Add(EnumOption('platform', 'target platform', host_platform,
  67. allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded', 'cygwin', 'sunos5', 'freebsd8')))
  68. opts.Add('toolchain', 'compiler toolchain', default_toolchain)
  69. opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
  70. opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
  71. opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
  72. opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
  73. opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))