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

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