Clone of mesa.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

SConstruct 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #######################################################################
  2. # Top-level SConstruct
  3. #
  4. # For example, invoke scons as
  5. #
  6. # scons build=debug llvm=yes machine=x86
  7. #
  8. # to set configuration variables. Or you can write those options to a file
  9. # named config.py:
  10. #
  11. # # config.py
  12. # build='debug'
  13. # llvm=True
  14. # machine='x86'
  15. #
  16. # Invoke
  17. #
  18. # scons -h
  19. #
  20. # to get the full list of options. See scons manpage for more info.
  21. #
  22. import os
  23. import os.path
  24. import sys
  25. import SCons.Util
  26. import common
  27. #######################################################################
  28. # Configuration options
  29. opts = Variables('config.py')
  30. common.AddOptions(opts)
  31. env = Environment(
  32. options = opts,
  33. tools = ['gallium'],
  34. toolpath = ['#scons'],
  35. ENV = os.environ,
  36. )
  37. # Backwards compatability with old target configuration variable
  38. try:
  39. targets = ARGUMENTS['targets']
  40. except KeyError:
  41. pass
  42. else:
  43. targets = targets.split(',')
  44. print 'scons: warning: targets option is deprecated; pass the targets on their own such as'
  45. print
  46. print ' scons %s' % ' '.join(targets)
  47. print
  48. COMMAND_LINE_TARGETS.append(targets)
  49. Help(opts.GenerateHelpText(env))
  50. # fail early for a common error on windows
  51. if env['gles']:
  52. try:
  53. import libxml2
  54. except ImportError:
  55. raise SCons.Errors.UserError, "GLES requires libxml2-python to build"
  56. #######################################################################
  57. # Environment setup
  58. # Includes
  59. env.Prepend(CPPPATH = [
  60. '#/include',
  61. ])
  62. env.Append(CPPPATH = [
  63. '#/src/gallium/include',
  64. '#/src/gallium/auxiliary',
  65. '#/src/gallium/drivers',
  66. '#/src/gallium/winsys',
  67. ])
  68. if env['msvc']:
  69. env.Append(CPPPATH = ['#include/c99'])
  70. # Embedded
  71. if env['platform'] == 'embedded':
  72. env.Append(CPPDEFINES = [
  73. '_POSIX_SOURCE',
  74. ('_POSIX_C_SOURCE', '199309L'),
  75. '_SVID_SOURCE',
  76. '_BSD_SOURCE',
  77. '_GNU_SOURCE',
  78. 'PTHREADS',
  79. ])
  80. env.Append(LIBS = [
  81. 'm',
  82. 'pthread',
  83. 'dl',
  84. ])
  85. # Posix
  86. if env['platform'] in ('posix', 'linux', 'freebsd', 'darwin'):
  87. env.Append(CPPDEFINES = [
  88. '_POSIX_SOURCE',
  89. ('_POSIX_C_SOURCE', '199309L'),
  90. '_SVID_SOURCE',
  91. '_BSD_SOURCE',
  92. '_GNU_SOURCE',
  93. 'PTHREADS',
  94. 'HAVE_POSIX_MEMALIGN',
  95. ])
  96. if env['gcc']:
  97. env.Append(CFLAGS = ['-fvisibility=hidden'])
  98. if env['platform'] == 'darwin':
  99. env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
  100. env.Append(LIBS = [
  101. 'm',
  102. 'pthread',
  103. 'dl',
  104. ])
  105. # for debugging
  106. #print env.Dump()
  107. #######################################################################
  108. # Invoke host SConscripts
  109. #
  110. # For things that are meant to be run on the native host build machine, instead
  111. # of the target machine.
  112. #
  113. # Create host environent
  114. if env['crosscompile'] and env['platform'] != 'embedded':
  115. host_env = Environment(
  116. options = opts,
  117. # no tool used
  118. tools = [],
  119. toolpath = ['#scons'],
  120. ENV = os.environ,
  121. )
  122. # Override options
  123. host_env['platform'] = common.host_platform
  124. host_env['machine'] = common.host_machine
  125. host_env['toolchain'] = 'default'
  126. host_env['llvm'] = False
  127. host_env.Tool('gallium')
  128. host_env['hostonly'] = True
  129. assert host_env['crosscompile'] == False
  130. if host_env['msvc']:
  131. host_env.Append(CPPPATH = ['#include/c99'])
  132. target_env = env
  133. env = host_env
  134. Export('env')
  135. SConscript(
  136. 'src/SConscript',
  137. variant_dir = host_env['build_dir'],
  138. duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  139. )
  140. env = target_env
  141. Export('env')
  142. #######################################################################
  143. # Invoke SConscripts
  144. # TODO: Build several variants at the same time?
  145. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  146. SConscript(
  147. 'src/SConscript',
  148. variant_dir = env['build_dir'],
  149. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  150. )