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 3.1KB

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