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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. 'BePC': 'x86',
  28. 'Intel': 'x86',
  29. 'ppc' : 'ppc',
  30. 'BeBox': 'ppc',
  31. 'BeMac': 'ppc',
  32. 'AMD64': 'x86_64',
  33. 'x86_64': 'x86_64',
  34. 'sparc': 'sparc',
  35. 'sun4u': 'sparc',
  36. }
  37. # find host_machine value
  38. if 'PROCESSOR_ARCHITECTURE' in os.environ:
  39. host_machine = os.environ['PROCESSOR_ARCHITECTURE']
  40. else:
  41. host_machine = _platform.machine()
  42. host_machine = _machine_map.get(host_machine, 'generic')
  43. default_machine = host_machine
  44. default_toolchain = 'default'
  45. if target_platform == 'windows' and host_platform != 'windows':
  46. default_machine = 'x86'
  47. default_toolchain = 'crossmingw'
  48. # find default_llvm value
  49. if 'LLVM' in os.environ:
  50. default_llvm = 'yes'
  51. else:
  52. default_llvm = 'no'
  53. try:
  54. if target_platform != 'windows' and \
  55. subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
  56. default_llvm = 'yes'
  57. except:
  58. pass
  59. #######################################################################
  60. # Common options
  61. def AddOptions(opts):
  62. try:
  63. from SCons.Variables.BoolVariable import BoolVariable as BoolOption
  64. except ImportError:
  65. from SCons.Options.BoolOption import BoolOption
  66. try:
  67. from SCons.Variables.EnumVariable import EnumVariable as EnumOption
  68. except ImportError:
  69. from SCons.Options.EnumOption import EnumOption
  70. opts.Add(EnumOption('build', 'build type', 'debug',
  71. allowed_values=('debug', 'checked', 'profile', 'release')))
  72. opts.Add(BoolOption('verbose', 'verbose output', 'no'))
  73. opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
  74. allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
  75. opts.Add(EnumOption('platform', 'target platform', host_platform,
  76. allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku', 'linux', 'sunos', 'windows')))
  77. opts.Add(BoolOption('embedded', 'embedded build', 'no'))
  78. opts.Add(BoolOption('analyze', 'enable static code analysis where available', 'no'))
  79. opts.Add('toolchain', 'compiler toolchain', default_toolchain)
  80. opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
  81. opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
  82. opts.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)', 'no'))
  83. opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
  84. opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
  85. opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes'))
  86. opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no'))
  87. if host_platform == 'windows':
  88. opts.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version')