Clone of mesa.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

SConstruct 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. #######################################################################
  2. # Top-level SConstruct
  3. import os
  4. import os.path
  5. import sys
  6. #######################################################################
  7. # Configuration options
  8. #
  9. # For example, invoke scons as
  10. #
  11. # scons debug=1 dri=0 machine=x86
  12. #
  13. # to set configuration variables. Or you can write those options to a file
  14. # named config.py:
  15. #
  16. # # config.py
  17. # debug=1
  18. # dri=0
  19. # machine='x86'
  20. #
  21. # Invoke
  22. #
  23. # scons -h
  24. #
  25. # to get the full list of options. See scons manpage for more info.
  26. #
  27. platform_map = {
  28. 'linux2': 'linux',
  29. 'win32': 'winddk',
  30. }
  31. platform = platform_map.get(sys.platform, sys.platform)
  32. # TODO: auto-detect defaults
  33. opts = Options('config.py')
  34. opts.Add(BoolOption('debug', 'build debug version', False))
  35. opts.Add(BoolOption('dri', 'build dri drivers', False))
  36. opts.Add(BoolOption('llvm', 'use llvm', False))
  37. opts.Add(EnumOption('machine', 'use machine-specific assembly code', 'x86',
  38. allowed_values=('generic', 'x86', 'x86-64')))
  39. opts.Add(EnumOption('platform', 'target platform', platform,
  40. allowed_values=('linux', 'cell', 'winddk')))
  41. env = Environment(
  42. options = opts,
  43. ENV = os.environ)
  44. Help(opts.GenerateHelpText(env))
  45. # for debugging
  46. #print env.Dump()
  47. # replicate options values in local variables
  48. debug = env['debug']
  49. dri = env['dri']
  50. llvm = env['llvm']
  51. machine = env['machine']
  52. platform = env['platform']
  53. # derived options
  54. x86 = machine == 'x86'
  55. gcc = platform in ('linux', 'freebsd', 'darwin')
  56. msvc = platform in ('win32', 'winddk')
  57. Export([
  58. 'debug',
  59. 'x86',
  60. 'dri',
  61. 'llvm',
  62. 'platform',
  63. 'gcc',
  64. 'msvc',
  65. ])
  66. #######################################################################
  67. # Environment setup
  68. #
  69. # TODO: put the compiler specific settings in separate files
  70. # TODO: auto-detect as much as possible
  71. if platform == 'winddk':
  72. import ntpath
  73. escape = env['ESCAPE']
  74. env.Tool('msvc')
  75. if 'BASEDIR' in os.environ:
  76. WINDDK = os.environ['BASEDIR']
  77. else:
  78. WINDDK = "C:\\WINDDK\\3790.1830"
  79. # NOTE: We need this elaborate construct to get the absolute paths and
  80. # forward slashes to msvc unharmed when cross compiling from posix platforms
  81. env.Append(CPPFLAGS = [
  82. escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wxp')),
  83. escape('/I' + ntpath.join(WINDDK, 'inc\\ddk\\wdm\\wxp')),
  84. escape('/I' + ntpath.join(WINDDK, 'inc\\crt')),
  85. ])
  86. env.Append(CPPDEFINES = [
  87. ('i386', '1'),
  88. ])
  89. if debug:
  90. env.Append(CPPDEFINES = ['DBG'])
  91. # Optimization flags
  92. if gcc:
  93. if debug:
  94. env.Append(CFLAGS = '-O0 -g3')
  95. env.Append(CXXFLAGS = '-O0 -g3')
  96. else:
  97. env.Append(CFLAGS = '-O3 -g3')
  98. env.Append(CXXFLAGS = '-O3 -g3')
  99. env.Append(CFLAGS = '-Wall -Wmissing-prototypes -std=c99 -ffast-math -pedantic')
  100. env.Append(CXXFLAGS = '-Wall -pedantic')
  101. # Be nice to Eclipse
  102. env.Append(CFLAGS = '-fmessage-length=0')
  103. env.Append(CXXFLAGS = '-fmessage-length=0')
  104. # Defines
  105. if debug:
  106. env.Append(CPPDEFINES = ['DEBUG'])
  107. else:
  108. env.Append(CPPDEFINES = ['NDEBUG'])
  109. # Includes
  110. env.Append(CPPPATH = [
  111. '#/include',
  112. '#/src/gallium/include',
  113. '#/src/gallium/auxiliary',
  114. '#/src/gallium/drivers',
  115. ])
  116. # x86 assembly
  117. if x86:
  118. env.Append(CPPDEFINES = [
  119. 'USE_X86_ASM',
  120. 'USE_MMX_ASM',
  121. 'USE_3DNOW_ASM',
  122. 'USE_SSE_ASM',
  123. ])
  124. if gcc:
  125. env.Append(CFLAGS = '-m32')
  126. env.Append(CXXFLAGS = '-m32')
  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. env.Append(CPPPATH = ['/usr/X11R6/include'])
  139. env.Append(LIBPATH = ['/usr/X11R6/lib'])
  140. env.Append(LIBS = [
  141. 'm',
  142. 'pthread',
  143. 'expat',
  144. 'dl',
  145. ])
  146. # DRI
  147. if dri:
  148. env.ParseConfig('pkg-config --cflags --libs libdrm')
  149. env.Append(CPPDEFINES = [
  150. ('USE_EXTERNAL_DXTN_LIB', '1'),
  151. 'IN_DRI_DRIVER',
  152. 'GLX_DIRECT_RENDERING',
  153. 'GLX_INDIRECT_RENDERING',
  154. ])
  155. # LLVM
  156. if llvm:
  157. # See also http://www.scons.org/wiki/UsingPkgConfig
  158. env.ParseConfig('llvm-config --cflags --ldflags --libs')
  159. env.Append(CPPDEFINES = ['MESA_LLVM'])
  160. env.Append(CXXFLAGS = ['-Wno-long-long'])
  161. # libGL
  162. if 1:
  163. env.Append(LIBS = [
  164. 'X11',
  165. 'Xext',
  166. 'Xxf86vm',
  167. 'Xdamage',
  168. 'Xfixes',
  169. ])
  170. Export('env')
  171. #######################################################################
  172. # Convenience Library Builder
  173. # based on the stock StaticLibrary and SharedLibrary builders
  174. def createConvenienceLibBuilder(env):
  175. """This is a utility function that creates the ConvenienceLibrary
  176. Builder in an Environment if it is not there already.
  177. If it is already there, we return the existing one.
  178. """
  179. try:
  180. convenience_lib = env['BUILDERS']['ConvenienceLibrary']
  181. except KeyError:
  182. action_list = [ Action("$ARCOM", "$ARCOMSTR") ]
  183. if env.Detect('ranlib'):
  184. ranlib_action = Action("$RANLIBCOM", "$RANLIBCOMSTR")
  185. action_list.append(ranlib_action)
  186. convenience_lib = Builder(action = action_list,
  187. emitter = '$LIBEMITTER',
  188. prefix = '$LIBPREFIX',
  189. suffix = '$LIBSUFFIX',
  190. src_suffix = '$SHOBJSUFFIX',
  191. src_builder = 'SharedObject')
  192. env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
  193. env['BUILDERS']['Library'] = convenience_lib
  194. return convenience_lib
  195. createConvenienceLibBuilder(env)
  196. #######################################################################
  197. # Invoke SConscripts
  198. # Put build output in a separate dir, which depends on the current configuration
  199. # See also http://www.scons.org/wiki/AdvancedBuildExample
  200. build_topdir = 'build'
  201. build_subdir = platform
  202. if dri:
  203. build_subdir += "-dri"
  204. if llvm:
  205. build_subdir += "-llvm"
  206. if x86:
  207. build_subdir += "-x86"
  208. if debug:
  209. build_subdir += "-debug"
  210. build_dir = os.path.join(build_topdir, build_subdir)
  211. # TODO: Build several variants at the same time?
  212. # http://www.scons.org/wiki/SimultaneousVariantBuilds
  213. SConscript(
  214. 'src/SConscript',
  215. build_dir = build_dir,
  216. duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html
  217. )