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.

SConstruct 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. #######################################################################
  2. # Top-level SConstruct
  3. #
  4. # For example, invoke scons as
  5. #
  6. # scons debug=1 dri=0 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. # debug=1
  13. # dri=0
  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. default_statetrackers = 'mesa'
  30. if common.default_platform in ('linux', 'freebsd', 'darwin'):
  31. default_drivers = 'softpipe,failover,svga,i915,i965,trace,identity,llvmpipe'
  32. default_winsys = 'xlib'
  33. elif common.default_platform in ('winddk',):
  34. default_drivers = 'softpipe,svga,i915,i965,trace,identity'
  35. default_winsys = 'all'
  36. elif common.default_platform in ('embedded',):
  37. default_drivers = 'softpipe,llvmpipe'
  38. default_winsys = 'xlib'
  39. else:
  40. default_drivers = 'all'
  41. default_winsys = 'all'
  42. opts = Variables('config.py')
  43. common.AddOptions(opts)
  44. opts.Add(ListVariable('statetrackers', 'state trackers to build', default_statetrackers,
  45. ['mesa', 'python', 'xorg']))
  46. opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
  47. ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe', 'nouveau', 'nv50', 'nvfx']))
  48. opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
  49. ['xlib', 'vmware', 'i915', 'i965', 'gdi', 'radeon', 'graw-xlib']))
  50. opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
  51. env = Environment(
  52. options = opts,
  53. tools = ['gallium'],
  54. toolpath = ['#scons'],
  55. ENV = os.environ,
  56. )
  57. if os.environ.has_key('CC'):
  58. env['CC'] = os.environ['CC']
  59. if os.environ.has_key('CFLAGS'):
  60. env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
  61. if os.environ.has_key('CXX'):
  62. env['CXX'] = os.environ['CXX']
  63. if os.environ.has_key('CXXFLAGS'):
  64. env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
  65. if os.environ.has_key('LDFLAGS'):
  66. env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
  67. Help(opts.GenerateHelpText(env))
  68. # replicate options values in local variables
  69. debug = env['debug']
  70. dri = env['dri']
  71. machine = env['machine']
  72. platform = env['platform']
  73. # derived options
  74. x86 = machine == 'x86'
  75. ppc = machine == 'ppc'
  76. gcc = platform in ('linux', 'freebsd', 'darwin', 'embedded')
  77. msvc = platform in ('windows', 'winddk')
  78. Export([
  79. 'debug',
  80. 'x86',
  81. 'ppc',
  82. 'dri',
  83. 'platform',
  84. 'gcc',
  85. 'msvc',
  86. ])
  87. #######################################################################
  88. # Environment setup
  89. # Always build trace, rbug, identity, softpipe, and llvmpipe (where possible)
  90. if 'trace' not in env['drivers']:
  91. env['drivers'].append('trace')
  92. if 'rbug' not in env['drivers']:
  93. env['drivers'].append('rbug')
  94. if 'identity' not in env['drivers']:
  95. env['drivers'].append('identity')
  96. if 'softpipe' not in env['drivers']:
  97. env['drivers'].append('softpipe')
  98. if env['llvm'] and 'llvmpipe' not in env['drivers']:
  99. env['drivers'].append('llvmpipe')
  100. # Includes
  101. env.Prepend(CPPPATH = [
  102. '#/include',
  103. ])
  104. env.Append(CPPPATH = [
  105. '#/src/gallium/include',
  106. '#/src/gallium/auxiliary',
  107. '#/src/gallium/drivers',
  108. '#/src/gallium/winsys',
  109. ])
  110. if env['msvc']:
  111. env.Append(CPPPATH = ['#include/c99'])
  112. # Embedded
  113. if platform == 'embedded':
  114. env.Append(CPPDEFINES = [
  115. '_POSIX_SOURCE',
  116. ('_POSIX_C_SOURCE', '199309L'),
  117. '_SVID_SOURCE',
  118. '_BSD_SOURCE',
  119. '_GNU_SOURCE',
  120. 'PTHREADS',
  121. ])
  122. env.Append(LIBS = [
  123. 'm',
  124. 'pthread',
  125. 'dl',
  126. ])
  127. # Posix
  128. if platform in ('posix', 'linux', 'freebsd', 'darwin'):
  129. env.Append(CPPDEFINES = [
  130. '_POSIX_SOURCE',
  131. ('_POSIX_C_SOURCE', '199309L'),
  132. '_SVID_SOURCE',
  133. '_BSD_SOURCE',
  134. '_GNU_SOURCE',
  135. 'PTHREADS',
  136. 'HAVE_POSIX_MEMALIGN',
  137. ])
  138. if gcc:
  139. env.Append(CFLAGS = ['-fvisibility=hidden'])
  140. if platform == 'darwin':
  141. env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
  142. env.Append(LIBS = [
  143. 'm',
  144. 'pthread',
  145. 'dl',
  146. ])
  147. # for debugging
  148. #print env.Dump()
  149. Export('env')
  150. #######################################################################
  151. # Invoke SConscripts
  152. # TODO: Build several variants at the same time?
  153. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  154. if env['platform'] != common.default_platform:
  155. # GLSL code has to be built twice -- one for the host OS, another for the target OS...
  156. host_env = Environment(
  157. # options are ignored
  158. # default tool is used
  159. tools = ['default', 'custom'],
  160. toolpath = ['#scons'],
  161. ENV = os.environ,
  162. )
  163. host_env['platform'] = common.default_platform
  164. host_env['machine'] = common.default_machine
  165. host_env['debug'] = env['debug']
  166. SConscript(
  167. 'src/glsl/SConscript',
  168. variant_dir = os.path.join(env['build'], 'host'),
  169. duplicate = 0, # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  170. exports={'env':host_env},
  171. )
  172. SConscript(
  173. 'src/SConscript',
  174. variant_dir = env['build'],
  175. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  176. )
  177. env.Default('src')
  178. SConscript(
  179. 'progs/SConscript',
  180. variant_dir = os.path.join('progs', env['build']),
  181. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  182. )